Commit 66e0d090 by kollo

made a memory manager for 64 bit ....

memory functions ausgelagert in memory.h
update RELEASE_NOTES
parent 38203e11
......@@ -35,12 +35,13 @@ X11-Basic. Does anybody have an idea what could be the problem?
More things left to do:
=======================
- test the thing and find more bugs,
- Optimize a bit more, improve performance
- The WINDOWS-Version needs more work
- work on the sound system
- work on the SDL-Graphics implementation (fill styles etc...)
- documentation needs more work
- port it to apple ipad/iphone
- Optimize a bit more, improve performance,
- The WINDOWS-Version needs more work,
- work on the sound system,
- work on the SDL-Graphics implementation (fill styles etc...),
- documentation needs more work,
- port it to apple ipad/iphone,
- improve the 64 Version (pointer handling),
(etc. etc.)
So you are welcome to help.
......@@ -9,3 +9,5 @@ Release notes for Version 1.25 (Sept 2016 -- 2017)
- added bluetooth support (linux)
- improved USB functions (linux)
- make use of fftw library when available
- improved memory handling in 64bit versions
......@@ -67,7 +67,7 @@ CFLAGS= $(INC) $(DEF) $(OPT)
# these are the objects which go into libx11basic
LIBOBJS=xbasic.o tools.o loadprg.o file.o io.o io_basic.o parser.o variablen.o svariablen.o \
array.o parameter.o fft.o mathematics.o \
array.o parameter.o fft.o mathematics.o memory.o \
runtime.o wort_sep.o ltext.o functions.o sfunctions.o afunctions.o \
kommandos.o gkommandos.o bitmap.o do_gets.o errortxt.o window.o\
sysVstuff.o aes.o graphics.o sound.o number.o decode.o \
......@@ -104,7 +104,8 @@ HSRC= aes.h afunctions.h android.h array.h bitmap.h bytecode.h \
mathematics.h number.h options.h parameter.h parser.h raw_mouse.h raw_keyboard.h \
sfunctions.h sound.h svariablen.h sysVstuff.h \
terminal.h type.h variablen.h virtual-machine.h \
window.h wort_sep.h x11basic.h xb2csol.h xbasic.h lodepng.h md5.h sha1.h
window.h wort_sep.h x11basic.h xb2csol.h xbasic.h memory.h lodepng.h \
md5.h sha1.h
EXAMPLES_TESTS= \
../examples/tests/*.bas \
......@@ -878,13 +879,6 @@ check : xbasic
LD_LIBRARY_PATH=. ./xbasic -e version
sourcecheck : main.c bytecode.c xbasic.c do_gets.c variablen.c
splint -warnposix -nullassign -boolops -predboolint \
-I /usr/include/i386-linux-gnu/ $<
# Auto dependency stuff (from info make)
%.d: %.c
......
......@@ -23,6 +23,7 @@
#endif
#include "x11basic.h"
#include "xbasic.h"
#include "memory.h"
#include "graphics.h"
#include "aes.h"
#include "file.h"
......
......@@ -26,6 +26,7 @@
#include "x11basic.h"
#include "variablen.h"
#include "xbasic.h"
#include "memory.h"
#include "type.h"
#include "parser.h"
#include "parameter.h"
......
......@@ -22,6 +22,7 @@
#include "x11basic.h"
#include "variablen.h"
#include "xbasic.h"
#include "memory.h"
#include "type.h"
#include "parser.h"
#include "parameter.h"
......
......@@ -80,6 +80,7 @@
#include "x11basic.h"
#include "xbasic.h"
#include "memory.h"
#include "type.h"
#include "parser.h"
#include "svariablen.h"
......
......@@ -34,6 +34,7 @@
#include "x11basic.h"
#include "variablen.h"
#include "xbasic.h"
#include "memory.h"
#include "type.h"
#include "kommandos.h"
......
/* memory.c Hilfsfunktionen fuer Memory-Management (c) Markus Hoffmann */
/* This file is part of X11BASIC, the basic interpreter for Unix/X
* =====================================================================
* X11BASIC is free software and comes with NO WARRANTY - read the file
* COPYING for details
*/
#include <stdio.h>
#include <stdlib.h>
#include "defs.h"
#include "memory.h"
/* Pointerbase: Hier können bis zu 8 verschiedene Speicherbereiche addressiert werden.
*/
#if SIZEOF_VOID_P == 8
void *pointerbase[MAXANZPOINTERBASE]={NULL};
int pointerbasecnt=1;
#endif
/* memory.h (c) Markus Hoffmann*/
/* This file is part of X11BASIC, the basic interpreter for Unix/X
* ============================================================
* X11BASIC is free software and comes with NO WARRANTY - read the file
* COPYING for details
*/
#define MAXANZPOINTERBASE 8
/*Funktionen für die Umwandlung */
#if SIZEOF_VOID_P == 4
#define POINTER2INT(a) ((unsigned int)(a))
#define INT2POINTER(a) ((char *)(a))
#elif SIZEOF_VOID_P == 8
extern void *pointerbase[];
extern int pointerbasecnt;
static inline unsigned int catchpointerbase(void *a) {
unsigned long long pb2=((unsigned long long)a&0xffffffffe0000000ULL);
unsigned int ret=(unsigned int)((unsigned long long)a&0x1fffffffULL);
unsigned int i;
for(i=0;i<pointerbasecnt;i++) {
if(pointerbase[i]==(void *)pb2) break;
}
#if DEBUG
printf("Pointer: %p\n",a);
printf("Base: %p\n",(void *)pb2);
printf("x: %x\n",ret);
printf("idx: %d\n",i);
#endif
if(i==pointerbasecnt) { /* pointerbase is new. */
if(pointerbasecnt<MAXANZPOINTERBASE) {
pointerbase[pointerbasecnt++]=(void *)pb2;
} else printf("WARNING: pointerbasetable is full.\n");
#if DEBUG
if (pb2>=0xffff800000000000ULL) printf("Memory is system level memory.\n");
else if(pb2>=0x00007fff00000000ULL) printf("Memory is stack, vdso or vsyscall.\n");
else if(pb2< 0x0000000000400000ULL) printf("Memory is illegal.\n");
if (pb2< 0x0000800000000000ULL) printf("Memory is user space memory.\n");
if (pb2>=0x00007f0000000000ULL) printf("Memory is probably shared mem/so/mmap.\n");
#endif
}
ret|=(i<<29);
#if DEBUG
printf("--> x: %08x\n",ret);
#endif
return(ret);
}
static inline void *i2p(unsigned int a) {
unsigned int i=(a&0xe0000000)>>29;
a&=0x1fffffff;
return((void *)((unsigned long long)pointerbase[i]+(unsigned long long)a));
}
#define POINTER2INT(a) catchpointerbase(a)
#define INT2POINTER(a) i2p(a)
#else
#error Sizeof pointer unknown.
#endif
static inline void WSWAP(char *adr) {
char a=*adr;
*adr=adr[1];
adr[1]=a;
}
static inline void LSWAP(short *adr) {
short a=*adr;
*adr=adr[1];
adr[1]=a;
}
static inline void LWSWAP(char *p) {
char a=*p;
*p=p[3];
p[3]=a;
a=p[1];
p[1]=p[2];
p[2]=a;
}
......@@ -18,6 +18,7 @@
#include "defs.h"
#include "x11basic.h"
#include "xbasic.h"
#include "memory.h"
#include "type.h"
#include "parser.h"
#include "kommandos.h"
......
......@@ -16,6 +16,7 @@
#include "defs.h"
#include "x11basic.h"
#include "xbasic.h"
#include "memory.h"
#if defined WINDOWS || defined ANDROID
#define EX_OK 0
#else
......
......@@ -18,6 +18,7 @@
#include "defs.h"
#include "x11basic.h"
#include "xbasic.h"
#include "memory.h"
#include "type.h"
#include "parser.h"
#include "variablen.h"
......
......@@ -22,6 +22,7 @@
#include "defs.h"
#include "x11basic.h"
#include "xbasic.h"
#include "memory.h"
#include "graphics.h"
#include "variablen.h"
#include "file.h"
......
......@@ -92,11 +92,6 @@ int everytime=0,alarmpc=-1,alarmpctype=0;
int stack[STACKSIZE];
#if SIZEOF_VOID_P == 8
void *pointerbase=NULL;
#endif
/* fuer die Dateiverwaltung */
FILEINFO filenr[ANZFILENR];
static int *linetable=NULL; /* for correctly count splitted lines*/
......
......@@ -282,59 +282,6 @@ void free_pcode(int l);
#define structure_warning(lin,comment) {printf("WARNING: corrupt program structure at line %d ==> %s.\n",lin,comment); invalidate_screen();}
#endif
/*Funktionen für die Umwandlung */
#if SIZEOF_VOID_P == 4
#define POINTER2INT(a) ((unsigned int)(a))
#define INT2POINTER(a) ((char *)(a))
#elif SIZEOF_VOID_P == 8
extern void *pointerbase;
static inline unsigned int catchpointerbase(void *a) {
unsigned long long pb2;
// printf("Pointer: %p\nPointerbase: %p\n",a,pointerbase);
pb2=((unsigned long long)a&0xffffffff00000000ULL);
if(pb2!=(unsigned long long)pointerbase) {
printf("WARNING: 64bit pointer base has changed! %p --> %p\n",pointerbase, (void *)pb2);
}
pointerbase=(void *)pb2;
return((unsigned int)((unsigned long long)a&0xffffffffULL));
}
static inline void *i2p(unsigned int a) {
// printf("Pointer: %x ",a);
void *p=(void *)((unsigned long long)pointerbase+(unsigned long long)a);
// printf("--> %p\n",p);
return(p);
}
#define POINTER2INT(a) catchpointerbase(a)
#define INT2POINTER(a) i2p(a)
#else
#error Sizeof pointer unknown.
#endif
static inline void WSWAP(char *adr) {
char a=*adr;
*adr=adr[1];
adr[1]=a;
}
static inline void LSWAP(short *adr) {
short a=*adr;
*adr=adr[1];
adr[1]=a;
}
static inline void LWSWAP(char *p) {
char a=*p;
*p=p[3];
p[3]=a;
a=p[1];
p[1]=p[2];
p[2]=a;
}
/*Schnelle inline Funktionen */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment