Skip to content

Commit

Permalink
libffi: hide platform-ignorant FFI ABI enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
drcicero committed Jan 30, 2023
1 parent 1ca5630 commit ff812ab
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 150 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi;

Expand Down
2 changes: 1 addition & 1 deletion libffi/src/gen/java/org/bytedeco/libffi/ffi_cif.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi;

Expand Down
2 changes: 1 addition & 1 deletion libffi/src/gen/java/org/bytedeco/libffi/ffi_closure.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi;

Expand Down
2 changes: 1 addition & 1 deletion libffi/src/gen/java/org/bytedeco/libffi/ffi_java_raw.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi;

Expand Down
2 changes: 1 addition & 1 deletion libffi/src/gen/java/org/bytedeco/libffi/ffi_raw.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi;

Expand Down
2 changes: 1 addition & 1 deletion libffi/src/gen/java/org/bytedeco/libffi/ffi_type.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi;

Expand Down
129 changes: 1 addition & 128 deletions libffi/src/gen/java/org/bytedeco/libffi/global/ffi.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
// Targeted by JavaCPP version 1.5.9-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.libffi.global;

Expand All @@ -13,133 +13,6 @@
public class ffi extends org.bytedeco.libffi.presets.ffi {
static { Loader.load(); }

// Parsed from ffitarget.h

/* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 2012, 2014, 2018 Anthony Green
Copyright (c) 1996-2003, 2010 Red Hat, Inc.
Copyright (C) 2008 Free Software Foundation, Inc.
Target configuration macros for x86 and x86-64.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */

// #ifndef LIBFFI_TARGET_H
// #define LIBFFI_TARGET_H

// #ifndef LIBFFI_H
// #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
// #endif

/* ---- System specific configurations ----------------------------------- */

/* For code common to all platforms on x86 and x86_64. */
// #define X86_ANY

// #if defined (X86_64) && defined (__i386__)
// #undef X86_64
// #warning ******************************************************
// #warning ********** X86 IS DEFINED ****************************
// #warning ******************************************************
// #define X86
// #endif

// #ifdef X86_WIN64
// #endif

// #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
// #ifndef _MSC_VER
// #define FFI_TARGET_HAS_COMPLEX_TYPE
// #endif

/* ---- Generic type definitions ----------------------------------------- */

// #ifndef LIBFFI_ASM
// #ifdef X86_WIN64
// #else
// #if defined __x86_64__ && defined __ILP32__
// #else
// #endif
// #endif

/** enum ffi_abi */
public static final int
// #if defined(X86_WIN64)

// #elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))

// #elif defined(X86_WIN32)
// #else
FFI_FIRST_ABI = 0,
FFI_SYSV = 1,
FFI_THISCALL = 3,
FFI_FASTCALL = 4,
FFI_STDCALL = 5,
FFI_PASCAL = 6,
FFI_REGISTER = 7,
FFI_MS_CDECL = 8,
FFI_LAST_ABI = 9,
FFI_DEFAULT_ABI = FFI_SYSV;
// #endif
// #endif

/* ---- Definitions for closures ----------------------------------------- */

public static final int FFI_CLOSURES = 1;
public static final int FFI_GO_CLOSURES = 1;

// #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
// #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
// #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
// #define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4)

// #if defined (X86_64) || defined(X86_WIN64)
// || (defined (__x86_64__) && defined (X86_DARWIN))
/* 4 bytes of ENDBR64 + 7 bytes of LEA + 6 bytes of JMP + 7 bytes of NOP
+ 8 bytes of pointer. */
public static native @MemberGetter int FFI_TRAMPOLINE_SIZE();
public static final int FFI_TRAMPOLINE_SIZE = FFI_TRAMPOLINE_SIZE();
// # define FFI_NATIVE_RAW_API 0
// #else
/* 4 bytes of ENDBR32 + 5 bytes of MOV + 5 bytes of JMP + 2 unused
bytes. */
// # define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
// #endif

// #if !defined(GENERATE_LIBFFI_MAP) && defined(__CET__)
// # include <cet.h>
// # if (__CET__ & 1) != 0
// # define ENDBR_PRESENT
// # endif
// # define _CET_NOTRACK notrack
// #else
// # define _CET_ENDBR
// # define _CET_NOTRACK
// #endif

// #endif


// Parsed from ffi.h

/* -----------------------------------------------------------------*-C-*-
Expand Down
36 changes: 24 additions & 12 deletions libffi/src/main/java/org/bytedeco/libffi/presets/ffi.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
inherit = javacpp.class,
value = {
@Platform(
include = {"ffitarget.h", "ffi.h"},
exclude = "ffitarget.h",
include = { // "ffitarget.h",
"ffi.h"},
link = "ffi@.8",
resource = {"include", "lib"}
),
Expand All @@ -62,23 +62,33 @@ public void map(InfoMap infoMap) {
"FFI_LONG_LONG_MAX", "FFI_API", "FFI_EXTERN").cppTypes().annotations())
.put(new Info("defined (POWERPC64)", "LONG_LONG_MAX", "1").define(true))
.put(new Info("FFI_GO_CLOSURES", "!FFI_NATIVE_RAW_API", "FFI_TARGET_HAS_COMPLEX_TYPE",
"defined(_WIN32)", "defined(X86_WIN32)", "defined(X86_WIN64)", "X86_WIN64",
"defined(_MSC_VER) && defined(_M_IX86)",
"defined __x86_64__ && defined __ILP32__",
"defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))",
"defined(__ARM_PCS_VFP) || defined(_M_ARM)",
"defined(__ARM_PCS_VFP) || defined(_WIN32)",
"defined(POWERPC_DARWIN) || defined(POWERPC_AIX)",
"defined (POWERPC_AIX)", "defined (POWERPC_DARWIN)").define(false).translate(true))
.put(new Info("FFI_TYPE_SMALL_STRUCT_1B", "FFI_TYPE_SMALL_STRUCT_2B",
"FFI_TYPE_SMALL_STRUCT_4B", "FFI_TYPE_MS_STRUCT", "FFI_PPC_TYPE_LAST").cppTypes())
"defined(_MSC_VER) && defined(_M_IX86)").define(false).translate(true))
.put(new Info("FFI_TRAMPOLINE_SIZE", "FFI_SIZEOF_ARG", "FFI_SIZEOF_JAVA_RAW").translate(false))
.put(new Info("ffi_type_uchar", "ffi_type_schar", "ffi_type_ushort", "ffi_type_sshort",
"ffi_type_uint", "ffi_type_sint", "ffi_type_ulong", "ffi_type_slong",
"ffi_type_longdouble").cppTypes("ffi_type").translate(false))
.put(new Info("_ffi_type").pointerTypes("ffi_type"))
.put(new Info("void (*)(void)").cast().pointerTypes("Pointer"))
.put(new Info("__attribute__((deprecated))").annotations("@Deprecated"))

// without parsing ffitarget.h we need to define these
.put(new Info("ffi_abi").cast().valueTypes("int"))
.put(new Info("ffi_arg", "ffi_sarg").cast().valueTypes("long"))

// to get ffitarget.h to parse we would need these
// .put(new Info("FFI_TYPE_SMALL_STRUCT_1B", "FFI_TYPE_SMALL_STRUCT_2B",
// "FFI_TYPE_SMALL_STRUCT_4B", "FFI_TYPE_MS_STRUCT", "FFI_PPC_TYPE_LAST").cppTypes())
// .put(new Info("defined(_WIN32)",
// "defined(X86_WIN32)",
// "defined(X86_WIN64)",
// "X86_WIN64",
// "defined __x86_64__ && defined __ILP32__",
// "defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))",
// "defined(__ARM_PCS_VFP) || defined(_M_ARM)",
// "defined(__ARM_PCS_VFP) || defined(_WIN32)",
// "defined(POWERPC_DARWIN) || defined(POWERPC_AIX)",
// "defined (POWERPC_AIX)", "defined (POWERPC_DARWIN)"
// ).define(false).translate(true))
;
}

Expand All @@ -101,4 +111,6 @@ public void map(InfoMap infoMap) {
public static native @MemberGetter @Platform(pattern = ".*-ppc64.*") int FFI_LINUX_LONG_DOUBLE_IEEE128();
public static native @MemberGetter int FFI_LAST_ABI();
public static native @MemberGetter int FFI_DEFAULT_ABI();

public static native @MemberGetter int FFI_TRAMPOLINE_SIZE();
}

0 comments on commit ff812ab

Please sign in to comment.