libffi: adapt Python bits to support RISC-V 03/287703/1
authorŁukasz Stelmach <l.stelmach@samsung.com>
Fri, 19 Aug 2022 12:40:44 +0000 (14:40 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 2 Feb 2023 18:24:09 +0000 (19:24 +0100)
Change-Id: Ib3e1b70356b85ad4da137e5aa4d68644b1f71445
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Modules/_ctypes/libffi/configure
Modules/_ctypes/libffi/configure.ac
Modules/_ctypes/libffi/fficonfig.py.in

index 823f5bc..9c4577f 100755 (executable)
@@ -19150,6 +19150,12 @@ ac_config_commands="$ac_config_commands src"
 ac_config_files="$ac_config_files include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile doc/Makefile libffi.pc"
 
 
+ac_config_links="$ac_config_links include/ffi_common.h:include/ffi_common.h include/ffi_cfi.h:include/ffi_cfi.h"
+
+
+ac_config_files="$ac_config_files fficonfig.py"
+
+
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -19752,6 +19758,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 # Files that config.status was made for.
 config_files="$ac_config_files"
 config_headers="$ac_config_headers"
+config_links="$ac_config_links"
 config_commands="$ac_config_commands"
 
 _ACEOF
@@ -19782,6 +19789,9 @@ $config_files
 Configuration headers:
 $config_headers
 
+Configuration links:
+$config_links
+
 Configuration commands:
 $config_commands
 
@@ -20323,6 +20333,9 @@ do
     "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
     "libffi.pc") CONFIG_FILES="$CONFIG_FILES libffi.pc" ;;
+    "include/ffi_common.h") CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;;
+    "include/ffi_cfi.h") CONFIG_LINKS="$CONFIG_LINKS include/ffi_cfi.h:include/ffi_cfi.h" ;;
+    "fficonfig.py") CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
@@ -20336,6 +20349,7 @@ done
 if $ac_need_defaults; then
   test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
   test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_LINKS+set}" = set || CONFIG_LINKS=$config_links
   test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
 fi
 
@@ -20633,7 +20647,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 fi # test -n "$CONFIG_HEADERS"
 
 
-eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS  :L $CONFIG_LINKS  :C $CONFIG_COMMANDS"
 shift
 for ac_tag
 do
@@ -20910,7 +20924,38 @@ $as_echo X"$_am_arg" |
          }
          s/.*/./; q'`/stamp-h$_am_stamp_count
  ;;
+  :L)
+  #
+  # CONFIG_LINK
+  #
 
+  if test "$ac_source" = "$ac_file" && test "$srcdir" = '.'; then
+    :
+  else
+    # Prefer the file from the source tree if names are identical.
+    if test "$ac_source" = "$ac_file" || test ! -r "$ac_source"; then
+      ac_source=$srcdir/$ac_source
+    fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: linking $ac_source to $ac_file" >&5
+$as_echo "$as_me: linking $ac_source to $ac_file" >&6;}
+
+    if test ! -r "$ac_source"; then
+      as_fn_error $? "$ac_source: file not found" "$LINENO" 5
+    fi
+    rm -f "$ac_file"
+
+    # Try a relative symlink, then a hard link, then a copy.
+    case $ac_source in
+    [\\/$]* | ?:[\\/]* ) ac_rel_source=$ac_source ;;
+       *) ac_rel_source=$ac_top_build_prefix$ac_source ;;
+    esac
+    ln -s "$ac_rel_source" "$ac_file" 2>/dev/null ||
+      ln "$ac_source" "$ac_file" 2>/dev/null ||
+      cp -p "$ac_source" "$ac_file" ||
+      as_fn_error $? "cannot link or copy $ac_source to $ac_file" "$LINENO" 5
+  fi
+ ;;
   :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
 $as_echo "$as_me: executing $ac_file commands" >&6;}
  ;;
index b764368..eed2581 100644 (file)
@@ -1,4 +1,7 @@
 dnl Process this with autoconf to create configure
+#
+# file from libffi - slightly patched for Python's ctypes
+#
 
 AC_PREREQ(2.68)
 
@@ -387,6 +390,10 @@ test -d src/$TARGETDIR || mkdir src/$TARGETDIR
 
 AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile doc/Makefile libffi.pc)
 
+AC_CONFIG_LINKS(include/ffi_common.h:include/ffi_common.h include/ffi_cfi.h:include/ffi_cfi.h)
+
+AC_CONFIG_FILES(fficonfig.py)
+
 AC_OUTPUT
 
 # Copy this file instead of using AC_CONFIG_LINK in order to support
index d102498..2894c70 100644 (file)
@@ -28,6 +28,7 @@ ffi_platforms = {
     'PA': ['src/pa/linux.S', 'src/pa/ffi.c'],
     'PA_LINUX': ['src/pa/linux.S', 'src/pa/ffi.c'],
     'PA_HPUX': ['src/pa/hpux32.S', 'src/pa/ffi.c'],
+    'RISCV': ['src/riscv/sysv.S', 'src/riscv/ffi.c'],
 }
 
 ffi_sources += ffi_platforms['@TARGET@']