Skip to content
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

addpkg: libemf #347

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions libemf/add-riscv64-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
From: Bo YU <tsu.yubo@gmail.com>
Date: Mon, 27 Jun 2022 20:11:46 +0800
Subject: add-support-riscv64

add support for riscv64 arch

Original reference e2k code for supporting riscv64 arch
---
include/libEMF/wine/winnt.h | 75 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)

diff --git a/include/libEMF/wine/winnt.h b/include/libEMF/wine/winnt.h
index 39e2f90..1609f38 100644
--- a/include/libEMF/wine/winnt.h
+++ b/include/libEMF/wine/winnt.h
@@ -69,6 +69,10 @@
# define WORDS_BIGENDIAN
# define BITFIELDS_BIGENDIAN
# undef ALLOW_UNALIGNED_ACCESS
+#elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64
+# undef WORDS_BIGENDIAN
+# undef BITFIELDS_BIGENDIAN
+# undef ALLOW_UNALIGNED_ACCESS
#elif !defined(RC_INVOKED)
# error Unknown CPU architecture!
#endif
@@ -1582,6 +1586,77 @@ typedef struct _CONTEXT {

#endif /* __e2k__ */

+#ifdef __riscv && __riscv_xlen==64
+/*
+ * FIXME:
+ *
+ * There is not yet an official CONTEXT structure defined for the
+ * riscv64 architecture (64-bit LE), so I just made one up.
+ *
+ */
+
+#define CONTEXT_RISCV64 0x4000000
+#define CONTEXT_CONTROL (CONTEXT_RISCV64 | 0x00000001)
+#define CONTEXT_INTEGER (CONTEXT_RISCV64 | 0x00000002)
+#define CONTEXT_FLOATING_POINT (CONTEXT_RISCV64 | 0x00000004)
+#define CONTEXT_DEBUG_REGISTERS (CONTEXT_RISCV64 | 0x00000008)
+
+#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
+
+#define EXCEPTION_READ_FAULT 0
+#define EXCEPTION_WRITE_FAULT 1
+#define EXCEPTION_EXECUTE_FAULT 8
+
+typedef struct _CONTEXT {
+ ULONG ContextFlags;
+
+ /* This section is specified/returned if the ContextFlags word contains
+ the flag CONTEXT_INTEGER. */
+ ULONGLONG X0;
+ ULONGLONG X1;
+ ULONGLONG X2;
+ ULONGLONG X3;
+ ULONGLONG X4;
+ ULONGLONG X5;
+ ULONGLONG X6;
+ ULONGLONG X7;
+ ULONGLONG X8;
+ ULONGLONG X9;
+ ULONGLONG X10;
+ ULONGLONG X11;
+ ULONGLONG X12;
+ ULONGLONG X13;
+ ULONGLONG X14;
+ ULONGLONG X15;
+ ULONGLONG X16;
+ ULONGLONG X17;
+ ULONGLONG X18;
+ ULONGLONG X19;
+ ULONGLONG X20;
+ ULONGLONG X21;
+ ULONGLONG X22;
+ ULONGLONG X23;
+ ULONGLONG X24;
+ ULONGLONG X25;
+ ULONGLONG X26;
+ ULONGLONG X27;
+ ULONGLONG X28;
+ ULONGLONG X29;
+ ULONGLONG X30;
+ ULONGLONG X31;
+
+ /* These are selected by CONTEXT_CONTROL */
+ ULONGLONG Sp;
+ ULONGLONG Pc;
+ ULONGLONG PState;
+
+ /* These are selected by CONTEXT_FLOATING_POINT */
+ /* FIXME */
+} CONTEXT;
+
+#endif /* __riscv64__ */
+
+
#if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
#error You need to define a CONTEXT for your CPU
#endif
24 changes: 24 additions & 0 deletions libemf/riscv64.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git PKGBUILD PKGBUILD
index 506b4c5..bc0cf47 100644
--- PKGBUILD
+++ PKGBUILD
@@ -9,8 +9,17 @@ arch=('x86_64')
url='http://libemf.sourceforge.net/'
license=('GPL' 'LGPL')
depends=('gcc-libs')
-source=("https://sourceforge.net/projects/libemf/files/libemf/${pkgver}/${pkgname}-${pkgver}.tar.gz")
-sha256sums=('74d92c017e8beb41730a8be07c2c6e4ff6547660c84bf91f832d8f325dd0cf82')
+source=("https://sourceforge.net/projects/libemf/files/libemf/${pkgver}/${pkgname}-${pkgver}.tar.gz"
+ "add-riscv64-support.patch")
+sha256sums=('74d92c017e8beb41730a8be07c2c6e4ff6547660c84bf91f832d8f325dd0cf82'
+ '0689e5b4a7137483acf13451d729e584e438083bf1a329a7be023a7cc74c2666')
+
+prepare() {
+ cd "${pkgname}-${pkgver}"
+
+ # Patch from https://build.opensuse.org/package/view_file/openSUSE:Factory:RISCV/libEMF/riscv.patch
+ patch -Np1 -i ${srcdir}/add-riscv64-support.patch
+}

build() {
cd "${pkgname}-${pkgver}"