qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Thorpe <thorpej@me.com>
To: qemu-devel@nongnu.org
Cc: Jason Thorpe <thorpej@me.com>
Subject: [PATCH 1/8] Make qemu-palcode build environment standalone. NFC.
Date: Wed,  2 Jun 2021 20:53:10 -0700	[thread overview]
Message-ID: <20210603035317.6814-2-thorpej@me.com> (raw)
In-Reply-To: <20210603035317.6814-1-thorpej@me.com>

Don't include system headers.  Instead, provide standalone definitions
and declarations of types needed and functions used by the PALcode that
are compatible with the standard Alpha / GCC ABI.

Signed-off-by: Jason Thorpe <thorpej@me.com>
---
 init.c   |  2 --
 memcpy.c |  2 +-
 memset.c |  2 +-
 printf.c |  4 +---
 protos.h | 30 +++++++++++++++++++++++++-----
 5 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/init.c b/init.c
index b53bab6..429a9ad 100644
--- a/init.c
+++ b/init.c
@@ -18,8 +18,6 @@
    along with this program; see the file COPYING.  If not see
    <http://www.gnu.org/licenses/>.  */
 
-#include <string.h>
-#include <stddef.h>
 #include "hwrpb.h"
 #include "osf.h"
 #include "ioport.h"
diff --git a/memcpy.c b/memcpy.c
index b6bbb74..9e1e913 100644
--- a/memcpy.c
+++ b/memcpy.c
@@ -8,7 +8,7 @@
  * This is a reasonably optimized memcpy() routine.
  */
 
-#include <string.h>
+#include "protos.h"
 
 /*
  * Note that the C code is written to be optimized into good assembly. However,
diff --git a/memset.c b/memset.c
index e8481dc..f9b0a6d 100644
--- a/memset.c
+++ b/memset.c
@@ -19,7 +19,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 
-#include <string.h>
+#include "protos.h"
 
 void *memset(void *optr, int ival, unsigned long size)
 {
diff --git a/printf.c b/printf.c
index 469b82c..0e1e128 100644
--- a/printf.c
+++ b/printf.c
@@ -18,10 +18,8 @@
    along with this program; see the file COPYING.  If not see
    <http://www.gnu.org/licenses/>.  */
 
-#include <stdarg.h>
-#include <stdbool.h>
-#include <string.h>
 #include "console.h"
+#include "protos.h"
 
 static int print_buf_pad(char *buf, int buflen, char *p, int width, int pad)
 {
diff --git a/protos.h b/protos.h
index 3ed1381..0d90be8 100644
--- a/protos.h
+++ b/protos.h
@@ -21,11 +21,31 @@
 #ifndef PROTOS_H
 #define PROTOS_H 1
 
-#include <stdint.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <string.h>
-
+/* Stand-alone definitions for various types, compatible with
+   the Alpha Linux ABI and GCC.  This eliminates dependencies
+   on external headers.  */
+typedef unsigned char  uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int   uint32_t;
+typedef unsigned long  uint64_t;
+typedef unsigned long  size_t;
+
+#define bool           _Bool
+#define true           1
+#define false          0
+
+#define offsetof(type, member) __builtin_offsetof(type, member)
+
+typedef __builtin_va_list va_list;
+#define va_start(ap, last)     __builtin_va_start((ap), (last))
+#define va_arg                 __builtin_va_arg
+#define va_end(ap)             __builtin_va_end(ap)
+
+#define NULL                   ((void *)0)
+
+extern void *memset(void *, int, size_t);
+extern void *memcpy(void *, const void *, size_t);
+extern size_t strlen(const char *);
 
 /*
  * Call_Pal functions.
-- 
2.30.2



  reply	other threads:[~2021-06-03  3:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  3:53 [PATCH 0/8] PALcode fixes required to run NetBSD/alpha Jason Thorpe
2021-06-03  3:53 ` Jason Thorpe [this message]
2021-06-05 23:27   ` [PATCH 1/8] Make qemu-palcode build environment standalone. NFC Richard Henderson
2021-06-03  3:53 ` [PATCH 2/8] Fix delivery of unaligned access exceptions Jason Thorpe
2021-06-05 23:28   ` Richard Henderson
2021-06-03  3:53 ` [PATCH 3/8] Fix initialization of the hwrpb.hwrpb.cpuid field Jason Thorpe
2021-06-06  0:28   ` Richard Henderson
2021-06-03  3:53 ` [PATCH 4/8] Make some PCI macros available to other files. NFC Jason Thorpe
2021-06-06  0:32   ` Richard Henderson
2021-06-03  3:53 ` [PATCH 5/8] Fix incorrect initialization of PCI BARs Jason Thorpe
2021-06-03  9:24   ` Philippe Mathieu-Daudé
2021-06-04 18:23     ` Jason Thorpe
2021-06-06  0:41   ` Richard Henderson
2021-06-03  3:53 ` [PATCH 6/8] Provide interrupt mapping information in PCI config registers Jason Thorpe
2021-06-06  1:49   ` Richard Henderson
2021-06-03  3:53 ` [PATCH 7/8] Provide a Console Terminal Block in the HWRPB Jason Thorpe
2021-06-06 19:27   ` Richard Henderson
2021-06-06 20:12     ` Jason Thorpe
2021-06-03  3:53 ` [PATCH 8/8] Fixes for seconday CPU start-up Jason Thorpe
2021-06-06 20:27   ` Richard Henderson
2021-06-03  9:26 ` [PATCH 0/8] PALcode fixes required to run NetBSD/alpha Philippe Mathieu-Daudé
2021-06-06 20:30 ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210603035317.6814-2-thorpej@me.com \
    --to=thorpej@me.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).