[prev in list] [next in list] [prev in thread] [next in thread]
List: sbcl-devel
Subject: [Sbcl-devel] os_vm_offset_t to int64_t attempt
From: Manuel Giraud <manuel () ledu-giraud ! fr>
Date: 2020-07-02 14:02:01
Message-ID: 87lfk2hv6u.fsf () elite ! giraud
[Download RAW message or body]
Hi,
The following patch switches runtime's os_vm_offset_t to int64_t. I have
tested it (build + run-tests.sh) on Linux x86/x86-64 and OpenBSD
x86/x86-64. I'd like to try it on Windows too but so far I've try to
build sbcl with msys2 following :
https://solarianprogrammer.com/2019/08/20/building-sbcl-steel-bank-common-lisp-windows/
and only get "multiple type definition" errors from various headers.
So how can I build sbcl on Windows? Is there others relevant OS/arch I
should test?
[Attachment #3 (text/x-patch)]
From 30b7fd970468f599ddbfcbdb2a3f7a8ea127d9a9 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Thu, 2 Jul 2020 15:36:54 +0200
Subject: [PATCH] switch os_vm_offset_t to int64_t.
---
src/runtime/GNUmakefile | 2 +-
src/runtime/android-os.h | 1 -
src/runtime/bsd-os.h | 1 -
src/runtime/core.h | 4 ++--
src/runtime/coreparse.c | 27 +++++++++++++--------------
src/runtime/gc-common.c | 2 +-
src/runtime/gencgc.c | 2 +-
src/runtime/haiku-os.h | 1 -
src/runtime/hpux-os.h | 1 -
src/runtime/linux-os.h | 1 -
src/runtime/os-common.c | 4 ++--
src/runtime/os.h | 2 +-
src/runtime/runtime.c | 6 +++---
src/runtime/save.c | 10 +++++-----
src/runtime/sunos-os.h | 1 -
src/runtime/win32-os.c | 2 +-
src/runtime/win32-os.h | 1 -
17 files changed, 30 insertions(+), 38 deletions(-)
diff --git a/src/runtime/GNUmakefile b/src/runtime/GNUmakefile
index d9ad52f82..8bbb6ebc1 100644
--- a/src/runtime/GNUmakefile
+++ b/src/runtime/GNUmakefile
@@ -34,7 +34,7 @@ __LDFLAGS__ =
include ../../output/prefix.def
-CFLAGS += -g -Wall -Wundef -Wsign-compare -Wpointer-arith -O3
+CFLAGS += -g -Wall -Werror -Wundef -Wsign-compare -Wpointer-arith -O3
ASFLAGS += $(CFLAGS)
CPPFLAGS += -I.
diff --git a/src/runtime/android-os.h b/src/runtime/android-os.h
index a2f661130..812ceccc3 100644
--- a/src/runtime/android-os.h
+++ b/src/runtime/android-os.h
@@ -25,7 +25,6 @@
// Needs to be defined before including target-arch.h
typedef caddr_t os_vm_address_t;
typedef size_t os_vm_size_t;
-typedef off_t os_vm_offset_t;
typedef int os_vm_prot_t;
#include "target-arch-os.h"
diff --git a/src/runtime/bsd-os.h b/src/runtime/bsd-os.h
index 0c5526c2c..d3d7083d3 100644
--- a/src/runtime/bsd-os.h
+++ b/src/runtime/bsd-os.h
@@ -27,7 +27,6 @@ typedef size_t os_vm_size_t;
#else
typedef vm_size_t os_vm_size_t;
#endif
-typedef off_t os_vm_offset_t;
typedef int os_vm_prot_t;
#if defined(LISP_FEATURE_FREEBSD)
diff --git a/src/runtime/core.h b/src/runtime/core.h
index 6e0652418..11f36fe1d 100644
--- a/src/runtime/core.h
+++ b/src/runtime/core.h
@@ -42,9 +42,9 @@ struct memsize_options {
int present_in_core;
};
-extern lispobj load_core_file(char *file, os_vm_offset_t file_offset,
+extern lispobj load_core_file(char *file, int64_t file_offset,
int merge_core_pages);
-extern os_vm_offset_t search_for_embedded_core(char *filename,
+extern int64_t search_for_embedded_core(char *filename,
struct memsize_options *memsize_options);
/* arbitrary string identifying this build, embedded in .core files to
diff --git a/src/runtime/coreparse.c b/src/runtime/coreparse.c
index 8371ae416..3bfec4ee3 100644
--- a/src/runtime/coreparse.c
+++ b/src/runtime/coreparse.c
@@ -99,19 +99,18 @@ int lisp_code_in_elf() { return &lisp_code_start != 0; }
/* Search 'filename' for an embedded core. An SBCL core has, at the
* end of the file, a trailer containing optional saved runtime
- * options, the start of the core (an os_vm_offset_t), and a final
- * signature word (the lispobj CORE_MAGIC). If this trailer is found
- * at the end of the file, the start of the core can be determined
- * from the core size.
+ * options, the start of the core, and a final signature word (the
+ * lispobj CORE_MAGIC). If this trailer is found at the end of the
+ * file, the start of the core can be determined from the core size.
*
* If an embedded core is present, this returns the offset into the
* file to load the core from, or -1 if no core is present. */
-os_vm_offset_t
+int64_t
search_for_embedded_core(char *filename, struct memsize_options *memsize_options)
{
- extern os_vm_offset_t search_for_elf_core(int);
+ extern int64_t search_for_elf_core(int);
lispobj header = 0;
- os_vm_offset_t lispobj_size = sizeof(lispobj);
+ int64_t lispobj_size = sizeof(lispobj);
int fd;
if ((fd = open_binary(filename, O_RDONLY)) < 0)
@@ -125,15 +124,15 @@ search_for_embedded_core(char *filename, struct memsize_options *memsize_options
return 0;
}
- os_vm_offset_t core_start = -1; // invalid value
+ int64_t core_start = -1; // invalid value
if (lseek(fd, -lispobj_size, SEEK_END) < 0 ||
read(fd, &header, (size_t)lispobj_size) != lispobj_size)
goto lose;
if (header == CORE_MAGIC) {
// the last word in the file could be CORE_MAGIC by pure coincidence
- if (lseek(fd, -(lispobj_size + sizeof(os_vm_offset_t)), SEEK_END) < 0 ||
- read(fd, &core_start, sizeof(os_vm_offset_t)) != sizeof(os_vm_offset_t))
+ if (lseek(fd, -(lispobj_size + sizeof(int64_t)), SEEK_END) < 0 ||
+ read(fd, &core_start, sizeof(int64_t)) != sizeof(int64_t))
goto lose;
if (lseek(fd, core_start, SEEK_SET) != core_start ||
read(fd, &header, lispobj_size) != lispobj_size || header != CORE_MAGIC)
@@ -173,7 +172,7 @@ lose:
lose("This runtime was not built with zlib-compressed core support... aborting")
#else
# define ZLIB_BUFFER_SIZE (1u<<16)
-static void inflate_core_bytes(int fd, os_vm_offset_t offset,
+static void inflate_core_bytes(int fd, int64_t offset,
os_vm_address_t addr, int len)
{
z_stream stream;
@@ -697,7 +696,7 @@ void calc_immobile_space_bounds()
static void
process_directory(int count, struct ndir_entry *entry,
- int fd, os_vm_offset_t file_offset,
+ int fd, int64_t file_offset,
int __attribute__((unused)) merge_core_pages,
struct heap_adjust __attribute__((unused)) *adj)
{
@@ -969,7 +968,7 @@ process_directory(int count, struct ndir_entry *entry,
#ifdef LISP_FEATURE_GENCGC
extern void gc_load_corefile_ptes(core_entry_elt_t, core_entry_elt_t,
- os_vm_offset_t offset, int fd);
+ int64_t offset, int fd);
#else
#define gc_load_corefile_ptes(dummy1,dummy2,dummy3,dummy4)
#endif
@@ -983,7 +982,7 @@ static void sanity_check_loaded_core(lispobj);
* -1: default, yes for compressed cores, no otherwise.
*/
lispobj
-load_core_file(char *file, os_vm_offset_t file_offset, int merge_core_pages)
+load_core_file(char *file, int64_t file_offset, int merge_core_pages)
{
void *header;
core_entry_elt_t val, *ptr;
diff --git a/src/runtime/gc-common.c b/src/runtime/gc-common.c
index 0d8833755..7a513c9ba 100644
--- a/src/runtime/gc-common.c
+++ b/src/runtime/gc-common.c
@@ -1268,7 +1268,7 @@ static inline boolean stable_eql_hash_p(lispobj obj)
static void scan_nonweak_kv_vector(struct vector *kv_vector, void (*scav_entry)(lispobj*))
{
- lispobj* data = kv_vector->data;
+ lispobj* data = (lispobj*) kv_vector->data;
if (!is_vector_subtype(kv_vector->header, VectorAddrHashing)) {
// All keys were hashed address-insensitively
diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c
index 650dfc623..6b8660d74 100644
--- a/src/runtime/gencgc.c
+++ b/src/runtime/gencgc.c
@@ -4554,7 +4554,7 @@ gc_and_save(char *filename, boolean prepend_runtime,
/* Read corefile ptes from 'fd' which has already been positioned
* and store into the page table */
void gc_load_corefile_ptes(core_entry_elt_t n_ptes, core_entry_elt_t total_bytes,
- os_vm_offset_t offset, int fd)
+ int64_t offset, int fd)
{
compute_layout_of_layout();
gc_assert(ALIGN_UP(n_ptes * sizeof (struct corefile_pte), N_WORD_BYTES)
diff --git a/src/runtime/haiku-os.h b/src/runtime/haiku-os.h
index 5bf1dd12b..485bd95ca 100644
--- a/src/runtime/haiku-os.h
+++ b/src/runtime/haiku-os.h
@@ -21,7 +21,6 @@
// Needs to be defined before including target-arch.h
typedef caddr_t os_vm_address_t;
typedef size_t os_vm_size_t;
-typedef off_t os_vm_offset_t;
typedef int os_vm_prot_t;
#include "target-arch-os.h"
diff --git a/src/runtime/hpux-os.h b/src/runtime/hpux-os.h
index bc4d404d1..4f83166cc 100644
--- a/src/runtime/hpux-os.h
+++ b/src/runtime/hpux-os.h
@@ -7,7 +7,6 @@
typedef caddr_t os_vm_address_t;
typedef size_t os_vm_size_t;
-typedef off_t os_vm_offset_t;
typedef int os_vm_prot_t;
#define OS_VM_PROT_READ PROT_READ
diff --git a/src/runtime/linux-os.h b/src/runtime/linux-os.h
index c495f7bb6..ef19f0489 100644
--- a/src/runtime/linux-os.h
+++ b/src/runtime/linux-os.h
@@ -26,7 +26,6 @@
// Needs to be defined before including target-arch.h
typedef caddr_t os_vm_address_t;
typedef size_t os_vm_size_t;
-typedef off_t os_vm_offset_t;
typedef int os_vm_prot_t;
#include "target-arch-os.h"
diff --git a/src/runtime/os-common.c b/src/runtime/os-common.c
index 4926e3e2d..6a08cd9b8 100644
--- a/src/runtime/os-common.c
+++ b/src/runtime/os-common.c
@@ -232,7 +232,7 @@ gc_managed_heap_space_p(lispobj addr)
/* Remap a part of an already existing memory mapping from a file,
* and/or create a new mapping as need be */
-void* load_core_bytes(int fd, os_vm_offset_t offset, os_vm_address_t addr, os_vm_size_t len)
+void* load_core_bytes(int fd, int64_t offset, os_vm_address_t addr, os_vm_size_t len)
{
int fail = 0;
#ifdef LISP_FEATURE_HPUX
@@ -262,7 +262,7 @@ void* load_core_bytes(int fd, os_vm_offset_t offset, os_vm_address_t addr, os_vm
}
#endif
if (fail)
- lose("load_core_bytes(%d,%zx,%p,%zx) failed", fd, offset, addr, len);
+ lose("load_core_bytes(%d,%" PRId64 ",%p,%zx) failed", fd, offset, addr, len);
return (void*)actual;
}
diff --git a/src/runtime/os.h b/src/runtime/os.h
index 998ed7087..2b46e052f 100644
--- a/src/runtime/os.h
+++ b/src/runtime/os.h
@@ -121,7 +121,7 @@ extern void os_invalidate(os_vm_address_t addr, os_vm_size_t len);
/* This maps a file into memory, or calls lose(..) for various
* failures. */
extern void* load_core_bytes(int fd,
- os_vm_offset_t offset,
+ int64_t offset,
os_vm_address_t addr,
os_vm_size_t len);
diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c
index 8f21874ce..eb38dc10d 100644
--- a/src/runtime/runtime.c
+++ b/src/runtime/runtime.c
@@ -428,7 +428,7 @@ sbcl_main(int argc, char *argv[], char *envp[])
* a malloc'ed string which should be freed eventually. */
char *core = 0;
char **sbcl_argv = 0;
- os_vm_offset_t embedded_core_offset = 0;
+ int64_t embedded_core_offset = 0;
/* other command line options */
boolean end_runtime_options = 0;
@@ -465,7 +465,7 @@ sbcl_main(int argc, char *argv[], char *envp[])
sbcl_runtime_home = libpath;
if (sbcl_runtime) {
- os_vm_offset_t offset = search_for_embedded_core(sbcl_runtime, &memsize_options);
+ int64_t offset = search_for_embedded_core(sbcl_runtime, &memsize_options);
if (offset != -1) {
embedded_core_offset = offset;
core = sbcl_runtime;
@@ -667,7 +667,7 @@ sbcl_main(int argc, char *argv[], char *envp[])
* before we reach this block, so that there is no observable
* difference between "embedded" and "bare" images given to
* --core. */
- os_vm_offset_t offset = search_for_embedded_core(core, 0);
+ int64_t offset = search_for_embedded_core(core, 0);
if (offset != -1)
embedded_core_offset = offset;
}
diff --git a/src/runtime/save.c b/src/runtime/save.c
index 9e0439064..ad0d1aaf1 100644
--- a/src/runtime/save.c
+++ b/src/runtime/save.c
@@ -156,7 +156,7 @@ typedef long ftell_type;
#endif
static long write_bytes(FILE *file, char *addr, size_t bytes,
- os_vm_offset_t file_offset, int compression)
+ int64_t file_offset, int compression)
{
ftell_type here, data;
@@ -180,7 +180,7 @@ static long write_bytes(FILE *file, char *addr, size_t bytes,
static void
output_space(FILE *file, int id, lispobj *addr, lispobj *end,
- os_vm_offset_t file_offset,
+ int64_t file_offset,
int core_compression_level)
{
size_t words, bytes, data, compressed_flag;
@@ -274,7 +274,7 @@ save_to_filehandle(FILE *file, char *filename, lispobj init_function,
fflush(stdout);
}
- os_vm_offset_t core_start_pos = FTELL(file);
+ int64_t core_start_pos = FTELL(file);
write_lispobj(CORE_MAGIC, file);
/* If 'save_runtime_options' is specified then the saved thread stack size
@@ -371,7 +371,7 @@ save_to_filehandle(FILE *file, char *filename, lispobj init_function,
* prepended to it. */
fseek(file, 0, SEEK_END);
- if (1 != fwrite(&core_start_pos, sizeof(os_vm_offset_t), 1, file)) {
+ if (1 != fwrite(&core_start_pos, sizeof(int64_t), 1, file)) {
perror("Error writing core starting position to file");
fclose(file);
} else {
@@ -417,7 +417,7 @@ load_runtime(char *runtime_path, size_t *size_out)
void *buf = NULL;
FILE *input = NULL;
size_t size, count;
- os_vm_offset_t core_offset;
+ int64_t core_offset;
core_offset = search_for_embedded_core (runtime_path, 0);
if ((input = fopen(runtime_path, "rb")) == NULL) {
diff --git a/src/runtime/sunos-os.h b/src/runtime/sunos-os.h
index 0d1ea517e..8cce6ced5 100644
--- a/src/runtime/sunos-os.h
+++ b/src/runtime/sunos-os.h
@@ -21,7 +21,6 @@
/* FIXME: Stolen from CMUCL. Investigate. */
typedef char* os_vm_address_t;
typedef size_t os_vm_size_t;
-typedef off_t os_vm_offset_t;
typedef int os_vm_prot_t;
/* typedef struct ucontext os_context_t;*/
diff --git a/src/runtime/win32-os.c b/src/runtime/win32-os.c
index 964386baa..5b0c8a708 100644
--- a/src/runtime/win32-os.c
+++ b/src/runtime/win32-os.c
@@ -906,7 +906,7 @@ os_validate_recommit(os_vm_address_t addr, os_vm_size_t len)
* thing to maintain).
*/
-void* load_core_bytes(int fd, os_vm_offset_t offset, os_vm_address_t addr, os_vm_size_t len)
+void* load_core_bytes(int fd, int64_t offset, os_vm_address_t addr, os_vm_size_t len)
{
AVER(VirtualAlloc(addr, len, MEM_COMMIT, PAGE_EXECUTE_READWRITE)||
diff --git a/src/runtime/win32-os.h b/src/runtime/win32-os.h
index 9662bcc36..42b84ab6a 100644
--- a/src/runtime/win32-os.h
+++ b/src/runtime/win32-os.h
@@ -40,7 +40,6 @@ typedef int sigset_t;
typedef LPVOID os_vm_address_t;
typedef uword_t os_vm_size_t;
-typedef intptr_t os_vm_offset_t;
typedef int os_vm_prot_t;
/* These are used as bitfields, but Win32 doesn't work that way, so we do a translation. */
--
2.27.0
--
Manuel Giraud
_______________________________________________
Sbcl-devel mailing list
Sbcl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic