Commit 28f5a365 authored by kollo's avatar kollo

fixed MEMDUMP, MALLOC, REALLOC, free() and SHM_detach(), draw_object ,

fix_bitblk, fix_iconblk, virtual_machine, shm_attach,
stdbmtobmp, c_curve, gosubproc, gotolabel, c_absolute, timer_handler, msynch,
receive, call, bload, bsave, bget, bput, bmove, ioctl, form_center, form_do,
objc_draw, objc_find, objc_offset, rsrc_gaddr
parent 95bbb7ae
......@@ -18,6 +18,7 @@
#include <gem.h>
#endif
#include "x11basic.h"
#include "xbasic.h"
#include "graphics.h"
#include "aes.h"
#include "file.h"
......@@ -244,24 +245,6 @@ void load_GEMFONT(int n) {
}
#endif
}
static inline void WSWAP(char *adr) {
char a=*adr;
*adr=adr[1];
adr[1]=a;
}
static void LSWAP(short *adr) {
short a=*adr;
*adr=adr[1];
adr[1]=a;
}
static void LWSWAP(short *adr) {
short a;
WSWAP((char *)&adr[0]);
WSWAP((char *)&adr[1]);
a=*adr;
*adr=adr[1];
adr[1]=a;
}
/* -------------------------------- AES-Implementationen ------------------*/
......@@ -786,19 +769,19 @@ if (drawbg) {
SetForeground(gem_colors[(bit->bi_color) & 0xf]);
SetBackground(gem_colors[WHITE]);
put_bitmap((char *)adr,obx,oby,bit->bi_wb*8,bit->bi_hl);
put_bitmap((char *)INT2POINTER(adr),obx,oby,bit->bi_wb*8,bit->bi_hl);
}
break;
case G_ICON:
{ICONBLK *bit=tree[idx].ob_spec.iconblk;
char *helper=(char *)&bit->ib_pmask;
unsigned int adr=*((LONG *)helper);
char *maskdata=(char *)adr;
char *maskdata=(char *)INT2POINTER(adr);
helper=(char *)&bit->ib_pdata;
adr=*((LONG *)helper);
char *bitdata=(char *)adr;
char *bitdata=(char *)INT2POINTER(adr);
helper=(char *)&bit->ib_ptext;
char *text=(char *)adr;
char *text=(char *)INT2POINTER(adr);
SetForeground(gem_colors[WHITE]);
put_bitmap(maskdata,obx,oby,bit->ib_wicon,bit->ib_hicon);
FillRectangle(obx+bit->ib_xtext,oby+bit->ib_ytext,bit->ib_wtext,bit->ib_htext);
......@@ -954,7 +937,7 @@ static void fix_bitblk() {
int anzahl=rsrc->rsh_nbb;
if(anzahl) {
// printf("FIX_BITBLK: Anzahl=$%04x\n",anzahl);
for(i =0; i < anzahl; i++) {
for(i=0; i<anzahl; i++) {
// if(rsrc->rsh_vrsn==0) {
for(j=0;j<sizeof(BITBLK)/2;j++) {
WSWAP((char *)((long)&base[i]+2*j));
......@@ -970,17 +953,17 @@ static void fix_bitblk() {
printf("w=%d h=%d x=%d y=%d c=%d\n",base[i].bi_wb,base[i].bi_hl,base[i].bi_x,base[i].bi_y,base[i].bi_color);
#endif
for(j=0;j<base[i].bi_wb*base[i].bi_hl/2;j++) {
WSWAP((char *)(k+2*j));
WSWAP((char *)INT2POINTER(k+2*j));
}
for(j=0;j<base[i].bi_wb*base[i].bi_hl/2;j++) {
n=0;
l=((WORD *)(k+2*j))[0];
l=((WORD *)INT2POINTER(k+2*j))[0];
for(m=0;m<16;m++) {
n=n<<1;
n|=(l & 1);
l=l>>1;
}
*((WORD *)(k+2*j))=n;
*((WORD *)INT2POINTER(k+2*j))=n;
}
// }
}
......@@ -995,7 +978,7 @@ static void fix_iconblk() {
for(i =0; i < anzahl; i++) {
// if(rsrc->rsh_vrsn==0) {
for(j=0;j<sizeof(ICONBLK)/2;j++) {
WSWAP((char *)((long)&base[i]+2*j));
WSWAP((char *)INT2POINTER((long)&base[i]+2*j));
}
LSWAP((short *)&(base[i].ib_pmask));
LSWAP((short *)&(base[i].ib_pdata));
......@@ -1016,32 +999,32 @@ static void fix_iconblk() {
k=*helper; /*(LONG *)&base[i].ib_pmask*/
for(j=0;j<base[i].ib_wicon*base[i].ib_hicon/16;j++) {
WSWAP((char *)(k+2*j));
WSWAP((char *)INT2POINTER(k+2*j));
}
for(j=0;j<base[i].ib_wicon*base[i].ib_hicon/16;j++) {
n=0;
l=((WORD *)(k+2*j))[0];
l=((WORD *)INT2POINTER(k+2*j))[0];
for(m=0;m<16;m++) {
n=n<<1;
n|=(l & 1);
l=l>>1;
}
*((WORD *)(k+2*j))=n;
*((WORD *)INT2POINTER(k+2*j))=n;
}
k=*helper2; /*(LONG *)&base[i].ib_pdata;*/
for(j=0;j<base[i].ib_wicon*base[i].ib_hicon/16;j++) {
WSWAP((char *)(k+2*j));
WSWAP((char *)INT2POINTER(k+2*j));
}
for(j=0;j<base[i].ib_wicon*base[i].ib_hicon/16;j++) {
n=0;
l=((WORD *)(k+2*j))[0];
l=((WORD *)INT2POINTER(k+2*j))[0];
for(m=0;m<16;m++) {
n=n<<1;
n|=(l & 1);
l=l>>1;
}
*((WORD *)(k+2*j))=n;
*((WORD *)INT2POINTER(k+2*j))=n;
}
//}
}
......
......@@ -90,7 +90,7 @@ static ARRAY f_einsmat(PARAMETER *plist, int e) {
/*Determinante berechnen*/
PARAMETER f_det(PARAMETER *plist, int e) {
PARAMETER ret;
PARAMETER ret; bzero(&ret,sizeof(ret));
ret.typ=PL_FLOAT; /* TODO !!!*/
ret.real=array_det((ARRAY *)&(plist->integer));
return(ret);
......
......@@ -122,7 +122,7 @@ unsigned char *stdbmtobmp(STANDARDBITMAP bmp, int *len) {
*buf2++=scanline[3]; /* A */
scanline+=4;
}
buf2=(unsigned char *)(((((int)buf2-(int)buf3)+3)&0xfffffffc)+(int)buf3); /* align to 4 */
buf2=buf3+(((buf2-buf3)+3)&0xfffffffc); /* align to 4 */
}
l=(buf2-buf3)+BITMAPFILEHEADERLEN+BITMAPINFOHEADERLEN;
writeint(&data[2],l);
......
......@@ -742,7 +742,7 @@ static int f_inode(STRING n) {return(stat_inode(n.pointer)); }
static int f_len(STRING n) {return(n.len); }
static int f_lpeek(int adr) {return((int)(*(long *)INT2POINTER(adr)));}
static double f_ltextlen(STRING n) {return((double)ltextlen(ltextxfaktor,ltextpflg,n.pointer)); }
static int f_malloc(int size) {return((int)malloc((size_t)size));}
static int f_malloc(int size) {return(POINTER2INT(malloc((size_t)size)));}
static int f_mshrink(int adr,int size) {return(0);} /*always return zero*/
static int f_mode(STRING n) {return(stat_mode(n.pointer)); }
static int f_nlink(STRING n) {return(stat_nlink(n.pointer)); }
......@@ -776,7 +776,7 @@ static int f_peek(int adr) {return((int)(*(char *)INT2POINTER(adr)));}
static int f_point(double v1, double v2) {return(get_point((int)v1,(int)v2));}
#endif
static double f_rad(double d) {return(d*PI/180);}
static int f_realloc(int adr,int size) {return((int)realloc((char *)adr,(size_t)size));}
static int f_realloc(int adr,int size) {return(POINTER2INT(realloc((char *)INT2POINTER(adr),(size_t)size)));}
static double f_rnd(double d) {return((double)rand()/RAND_MAX);}
static int f_size(STRING n) {return(stat_size(n.pointer)); }
......@@ -1193,7 +1193,7 @@ static int f_form_center(PARAMETER *plist,int e) {
short x,y,w,h,ret;
graphics();
gem_init();
ret=form_center((OBJECT *)plist->integer,&x,&y,&w,&h);
ret=form_center((OBJECT *)INT2POINTER(plist->integer),&x,&y,&w,&h);
if(e>4) {
if(plist[1].typ!=PL_LEER) varcastint(plist[1].integer,plist[1].pointer,x);
if(plist[2].typ!=PL_LEER) varcastint(plist[2].integer,plist[2].pointer,y);
......@@ -1214,18 +1214,18 @@ static int f_form_do(PARAMETER *plist,int e) {
if(e>1) startob=plist[1].integer;
graphics();
gem_init();
return(form_do((OBJECT *)plist->integer,startob));
return(form_do((OBJECT *)INT2POINTER(plist->integer),startob));
}
static int f_objc_draw(PARAMETER *plist,int e) {
graphics();
gem_init();
/*TODO: Clipping */
return(objc_draw((OBJECT *)plist->integer,plist[1].integer,plist[2].integer,
return(objc_draw((OBJECT *)INT2POINTER(plist->integer),plist[1].integer,plist[2].integer,
0,0,plist[5].integer,plist[6].integer));
}
static int f_objc_find(PARAMETER *plist,int e) {
return(objc_find((OBJECT *)plist[0].integer,0,7,plist[1].integer,plist[2].integer));
return(objc_find((OBJECT *)INT2POINTER(plist->integer),0,7,plist[1].integer,plist[2].integer));
}
static int f_objc_offset(PARAMETER *plist,int e) {
short x,y,ret;
......@@ -1244,7 +1244,7 @@ static int f_objc_offset(PARAMETER *plist,int e) {
if(typ==INTTYP) y=*((int *)plist[3].pointer);
else if(typ==FLOATTYP) y=(int)*((double *)plist[3].pointer);
}
ret=objc_offset((OBJECT *)plist->integer,plist[1].integer,&x,&y);
ret=objc_offset((OBJECT *)INT2POINTER(plist->integer),plist[1].integer,&x,&y);
if(e>2 && plist[2].typ!=PL_LEER) varcastint(plist[2].integer,plist[2].pointer,x);
if(e>3 && plist[3].typ!=PL_LEER) varcastint(plist[3].integer,plist[3].pointer,y);
......@@ -1265,7 +1265,7 @@ static int f_color_rgb(PARAMETER *plist,int e) {
static int f_rsrc_gaddr(PARAMETER *plist,int e) {
char *ptr;
int i=rsrc_gaddr(plist->integer,plist[1].integer,&ptr);
if(i>0) return((int)ptr);
if(i>0) return((int)POINTER2INT(ptr));
else return(-1);
}
......
......@@ -512,7 +512,7 @@ void c_line(PARAMETER *plist,int e) {
}
/* Kubische Bezier curve*/
void c_curve(PARAMETER *plist,int e) {
int granul=3,t=0,x=0,y=0,ox,oy;
int granul=3,t=0,x=0,y=0,ox=0,oy=0;
#define px0 plist[0].integer
#define py0 plist[1].integer
#define px1 plist[2].integer
......@@ -2148,7 +2148,7 @@ void c_menu(char *n) {
} else {
// TODO:
void (*func)();
func=(void *)menuaction;
func=(void *)INT2POINTER(menuaction);
func();
}
}
......@@ -2208,10 +2208,10 @@ void c_rsrc_free(char *n) {
if(rsrc_free()) xberror(73,""); /* Fehler bei RSRC_FREE*/
}
void c_objc_add(PARAMETER *plist,int e) {
objc_add((OBJECT *)plist[0].integer,plist[1].integer,plist[2].integer);
objc_add((OBJECT *)INT2POINTER(plist->integer),plist[1].integer,plist[2].integer);
}
void c_objc_delete(PARAMETER *plist,int e) {
objc_delete((OBJECT *)plist[0].integer,plist[1].integer);
objc_delete((OBJECT *)INT2POINTER(plist->integer),plist[1].integer);
}
void c_xload(char *n) {
char *name=fileselector("Load X11-Basic program:","./*.bas","");
......
......@@ -85,23 +85,22 @@ void mybox(int x1,int y1,int x2, int y2) {
#endif
}
int get_point(int x, int y) {
int r;
#if defined WINDOWS_NATIVE
r=0;
return(0); /* TODO */
#elif defined USE_SDL
r=sdl_getpixel(window[usewindow].display,x,y);
return(sdl_getpixel(window[usewindow].display,x,y));
#elif defined FRAMEBUFFER
r=FB_point(x,y);
return(FB_point(x,y));
#elif defined USE_X11
XImage *Image;
graphics();
int d=XDefaultDepthOfScreen(XDefaultScreenOfDisplay(window[usewindow].display));
Image=XGetImage(window[usewindow].display,window[usewindow].win,
x, y, 1, 1, AllPlanes,(d==1) ? XYPixmap : ZPixmap);
r=XGetPixel(Image, 0, 0);
XDestroyImage(Image);
#endif
int r=XGetPixel(Image, 0, 0);
XDestroyImage(Image);
return(r);
#endif
}
......@@ -299,8 +298,8 @@ int mousex() {
}
int mousey() {
#if defined ANDROID || defined FRAMEBUFFER
graphics();
return(screen.mouse_y);
graphics();
return(screen.mouse_y);
#elif defined WINDOWS_NATIVE
return(global_mousey);
#endif
......
......@@ -305,7 +305,7 @@ void c_msync(PARAMETER *plist,int e) {
if(e>=2) {
#ifndef WINDOWS
#ifndef ATARI
if(msync((void *)plist[0].integer, plist[1].integer,MS_SYNC|MS_INVALIDATE))
if(msync((void *)INT2POINTER(plist->integer), plist[1].integer,MS_SYNC|MS_INVALIDATE))
io_error(errno,"msync");
#endif
#endif
......@@ -315,7 +315,7 @@ void c_unmap(PARAMETER *plist,int e) {
if(e>=2) {
#ifndef WINDOWS
#ifndef ATARI
if(munmap((void *)plist[0].integer, plist[1].integer))
if(munmap((void *)INT2POINTER(plist->integer), plist[1].integer))
io_error(errno,"munmap");
#endif
#endif
......@@ -1141,11 +1141,10 @@ void c_receive(PARAMETER *plist, int e) {
if(fff.typ==0) xberror(24,""); /* File nicht geoeffnet */
else if(fff.typ==FT_USB) {
STRING str;
int ret;
if(fff.blk_len<=0) fff.blk_len=64;
str.pointer=malloc(fff.blk_len+1);
#ifdef HAVE_USB
ret=usb_bulk_read(fff.dptr,fff.ep_in,str.pointer,fff.blk_len,TIMEOUT);
int ret=usb_bulk_read(fff.dptr,fff.ep_in,str.pointer,fff.blk_len,TIMEOUT);
if(e>2) varcastint(plist[2].integer,plist[2].pointer,ret);
if(ret<0) {
printf("usb_bulk_read failed with code %i: %s\n", ret, usb_strerror());
......@@ -1342,7 +1341,7 @@ int f_exec(PARAMETER *plist,int e) {
void c_call(PARAMETER *plist,int e) { f_call(plist,e);}
int f_call(PARAMETER *plist,int e) {
typedef struct {int feld[20];} GTT;
int (*adr)(GTT)=(int (*)())plist->integer;
int (*adr)(GTT)=(int (*)())INT2POINTER(plist->integer);
// printf("call 0x%x mit %d args.\n",plist->integer,e);
if(e>20) xberror(45,"CALL"); /* Zu viele Parameter */
else if(adr==NULL) xberror(29,"CALL"); /* illegal address */
......@@ -1377,26 +1376,26 @@ int f_call(PARAMETER *plist,int e) {
void c_bload(PARAMETER *plist,int e) {
int len=-1;
if(e>2) len=plist[2].integer;
if(bload(plist->pointer,(char *)plist[1].integer,len)==-1) io_error(errno,"BLOAD");
if(bload(plist->pointer,(char *)INT2POINTER(plist[1].integer),len)==-1) io_error(errno,"BLOAD");
}
void c_bsave(PARAMETER *plist,int e) {
if(bsave(plist->pointer,(char *)plist[1].integer,plist[2].integer)==-1) io_error(errno,"BSAVE");
if(bsave(plist->pointer,(char *)INT2POINTER(plist[1].integer),plist[2].integer)==-1) io_error(errno,"BSAVE");
}
void c_bget(PARAMETER *plist,int e) {
int i=plist->integer;
if(filenr[i].typ) {
e=fread((char *)plist[1].integer,1,plist[2].integer,filenr[i].dptr);
e=fread((char *)INT2POINTER(plist[1].integer),1,plist[2].integer,filenr[i].dptr);
if(e<plist[2].integer) xberror(26,""); /* Fileende erreicht EOF */
} else xberror(24,""); /* File nicht geoeffnet */
}
void c_bput(PARAMETER *plist,int e) {
int i=plist->integer;
if(filenr[i].typ) fwrite((char *)plist[1].integer,1,plist[2].integer,filenr[i].dptr);
if(filenr[i].typ) fwrite((char *)INT2POINTER(plist[1].integer),1,plist[2].integer,filenr[i].dptr);
else xberror(24,""); /* File nicht geoeffnet */
}
void c_bmove(PARAMETER *plist,int e) { /* Memory copy BMOVE quelladr%,zieladr%,anzahl% */
memmove((char *)plist[1].integer,(char *)plist[0].integer,(size_t)plist[2].integer);
memmove((char *)INT2POINTER(plist[1].integer),(char *)INT2POINTER(plist[0].integer),(size_t)plist[2].integer);
}
void c_pipe(PARAMETER *plist,int e) {
int i=plist[0].integer;
......@@ -2122,7 +2121,7 @@ int f_ioctl(PARAMETER *plist,int e) {
#else
if(e==2) ret=ioctl(sock,plist[1].integer);
#endif
else ret=ioctl(sock,plist[1].integer,(void *)plist[2].integer);
else ret=ioctl(sock,plist[1].integer,(void *)INT2POINTER(plist[2].integer));
if(ret==-1)
#endif
io_error(errno,"ioctl");
......
......@@ -271,7 +271,7 @@ static int saveprg(char *fname) {
}
static void c_memdump(PARAMETER *plist,int e) {
memdump((unsigned char *)plist[0].integer,plist[1].integer);
memdump((unsigned char *)INT2POINTER(plist->integer),plist[1].integer);
}
static void stringdump(const char *s,int l,char *d) {
......@@ -651,7 +651,7 @@ static void c_list(PARAMETER *plist, int e) {
" Size of Data-Segment: %d\n",(int)h->textseglen,(int)h->rodataseglen,(int)h->sdataseglen);
printf(" Size of bss-Segment: %d\n"
" Size of String-Segment: %d\n",(int)h->bssseglen,(int)h->stringseglen);
printf(" Size of Symbol-Segment: %d (%d symbols)\n",(int)h->symbolseglen,(int)h->symbolseglen/sizeof(BYTECODE_SYMBOL));
printf(" Size of Symbol-Segment: %d (%d symbols)\n",(int)h->symbolseglen,(int)(h->symbolseglen/sizeof(BYTECODE_SYMBOL)));
} else {
if(o<=prglen) for(i=a;i<o;i++) puts(program[i]);
}
......@@ -1645,7 +1645,7 @@ static void gosubproc(int pc2,int type) {
sp--;
} else {
void (*func)();
func=(void *)pc2;
func=(void *)INT2POINTER(pc2);
func();
}
}
......@@ -1660,7 +1660,7 @@ static void gotolabel(int pc2,int type) {
// TODO:
} else {
#ifndef __APPLE__
void *func=(void *)pc2;
void *func=(void *)INT2POINTER(pc2);
goto *func;
#else
printf("ERROR/Macintosh MacOS X\nSee Bug 18658 Bugzilla.\nGOTO not possible.\n");
......@@ -1737,7 +1737,7 @@ static void c_absolute(PARAMETER *plist,int e) {
int vnr=plist->integer;
erase_variable(&variablen[vnr]);
variablen[vnr].flags=V_STATIC;
variablen[vnr].pointer.i=(int *)plist[1].integer;
variablen[vnr].pointer.i=(int *)INT2POINTER(plist[1].integer);
}
......@@ -2096,9 +2096,9 @@ void do_help(const char *w) {
}
}
static void c_error(PARAMETER *plist,int e) {xberror(plist->integer,"");}
static void c_free(PARAMETER *plist,int e) {free((char *)plist->integer);}
static void c_free(PARAMETER *plist,int e) {free((char *)INT2POINTER(plist->integer));}
static void c_detatch(PARAMETER *plist,int e) {
int r=shm_detatch(plist->integer);
int r=shm_detatch(INT2POINTER(plist->integer));
if(r!=0) io_error(r,"DETATCH");
}
static void c_shm_free(PARAMETER *plist,int e) {shm_free(plist->integer);}
......
......@@ -205,7 +205,7 @@ static void timer_handler( int signum) {
} else {
// TODO:
void (*func)();
func=(void *)alarmpc;
func=(void *)INT2POINTER(alarmpc);
func();
}
}
......
......@@ -11,6 +11,10 @@
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "defs.h"
#include "x11basic.h"
#include "xbasic.h"
#if defined WINDOWS || defined ANDROID
#define EX_OK 0
#else
......@@ -311,13 +315,13 @@ int shm_malloc(size_t segsize, key_t key) {
}
int shm_attach(int shmid) {
int r=(int)shmat(shmid,0,0);
int r=POINTER2INT(shmat(shmid,0,0));
if(r==-1) io_error(errno,"SHM_ATTACH"); /* shm_attach error.*/
return(r);
}
int shm_detatch(int shmaddr) {
if(shmdt((void *)shmaddr)==-1) return(errno);
int shm_detatch(const void *shmaddr) {
if(shmdt(shmaddr)==-1) return(errno);
return(0);
}
......
......@@ -11,6 +11,6 @@
#endif
void shm_free(int shmid);
int shm_detatch(int shmaddr);
int shm_detatch(const void *);
int shm_attach(int shmid);
int shm_malloc(size_t segsize, key_t key);
......@@ -704,8 +704,11 @@ STATIC int vm_func(PARAMETER *sp,int i, int anzarg) { /* */
if(sp->typ==PL_STRING) {
a.len=sp->integer;
a.pointer=sp->pointer;
} else
xberror(47,(char *)pfuncs[i].name); /* Parameter %s falsch, kein String */
} else {
a.len=0;
a.pointer=NULL;
xberror(47,(char *)pfuncs[i].name); /* Parameter %s falsch, kein String */
}
// printf("Got a string: <%s>\n",a.pointer);
if((pfuncs[i].opcode&FM_RET)==F_IRET) {
sp->integer=((int (*)())pfuncs[i].routine)(a);
......@@ -1037,21 +1040,21 @@ PARAMETER *virtual_machine(const STRING bcpc, int offset, int *npar, const PARAM
break;
case BC_LOADi:
CP4(&a,&bcpc.pointer[i],i);
opstack->integer=*((int *)a);
opstack->integer=*((int *)INT2POINTER(a));
opstack->typ=PL_INT;
opstack++;
VERBOSE("[$%x].i ",a);
break;
case BC_LOADf:
CP4(&a,&bcpc.pointer[i],i);
opstack->real=*((double *)a);
opstack->real=*((double *)INT2POINTER(a));
opstack->typ=PL_FLOAT;
opstack++;
VERBOSE("[$%x].d ",a);
break;
case BC_LOADc:
CP4(&a,&bcpc.pointer[i],i);
opstack->real=*((double *)a);
opstack->real=*((double *)INT2POINTER(a));
opstack->imag=0;
opstack->typ=PL_COMPLEX;
opstack++;
......@@ -1319,7 +1322,7 @@ PARAMETER *virtual_machine(const STRING bcpc, int offset, int *npar, const PARAM
opstack+=vm_exch(opstack);
break;
case BC_CLEAR:
a=((int)opstack-(int)osp)/sizeof(PARAMETER);
a=(opstack-osp); /* a=((int)opstack-(int)osp)/sizeof(PARAMETER); */
if(a) {
opstack=osp;
for(j=0;j<a;j++) free_parameter(&opstack[j]);
......@@ -1327,7 +1330,7 @@ PARAMETER *virtual_machine(const STRING bcpc, int offset, int *npar, const PARAM
VERBOSE("vm_clear ");
break;
case BC_COUNT:
a=((int)opstack-(int)osp)/sizeof(PARAMETER);
a=(opstack-osp); /* a=((int)opstack-(int)osp)/sizeof(PARAMETER); */
opstack->integer=a;
opstack->typ=PL_INT;
opstack++;
......@@ -1433,7 +1436,7 @@ PARAMETER *virtual_machine(const STRING bcpc, int offset, int *npar, const PARAM
opstack++;
break;
default:
VMERROR("BC_ILLEGAL instruction %2x at %p",(int)cmd,(void *)i);
VMERROR("BC_ILLEGAL instruction %2x at %p",(int)cmd,(void *)INT2POINTER(i));
memdump((unsigned char *)&(bcpc.pointer[i]),16);
xberror(104,""); /* Illegal Instruction */
}
......@@ -1443,7 +1446,7 @@ PARAMETER *virtual_machine(const STRING bcpc, int offset, int *npar, const PARAM
#ifdef ANDROID
backlog("Virtual machine exited.");
#endif
*npar=((int)opstack-(int)osp)/sizeof(PARAMETER);
*npar=(opstack-osp); /* *npar=((int)opstack-(int)osp)/sizeof(PARAMETER); */
return(osp);
}
......@@ -1473,8 +1476,8 @@ static void do_pusharg(va_list *arg, unsigned char typ, PARAMETER **sp) {
// va_list arguments=*arg;
//#endif
switch(typ) {
case 'a': a=va_arg ( arguments, ARRAY ); *((ARRAY *)(opstack->integer))=double_array(&a); opstack->typ=PL_ARRAY; opstack++; break;
case 's': s=va_arg ( arguments, STRING ); *((STRING *)(opstack->integer))=double_string(&s); opstack->typ=PL_STRING; opstack++; break;
case 'a': a=va_arg ( arguments, ARRAY ); *((ARRAY *)INT2POINTER(opstack->integer))=double_array(&a); opstack->typ=PL_ARRAY; opstack++; break;
case 's': s=va_arg ( arguments, STRING ); *((STRING *)INT2POINTER(opstack->integer))=double_string(&s); opstack->typ=PL_STRING; opstack++; break;
case 'f': f=va_arg ( arguments, double ); opstack->real=f; opstack->typ=PL_FLOAT; opstack++; break;
case 'i': i=va_arg ( arguments, int ); opstack->integer=i; opstack->typ=PL_INT; opstack++; break;
case '.': va_arg ( arguments, int ); /*parameter abraeumen*/
......
......@@ -312,7 +312,7 @@ static void translate() {
fflush(optr);
redo=0;
fprintf(optr,"/* %02x / %02x */",i,i+sizeof(BYTECODE_HEADER));
fprintf(optr,"/* %02x / %02x */",i,i+(unsigned int)sizeof(BYTECODE_HEADER));
if((b=havesymbol(i,STT_LABEL))>=0)
fprintf(optr,"%s: ",&strings[symtab[b].name]);
else if((b=havesymbol(i,0))>=0) {
......@@ -755,30 +755,30 @@ WSWAP((char *)&bytecode->version);
bytecode=(BYTECODE_HEADER *)p;
}
fprintf(optr,"txt: $%08x %d\n",sizeof(BYTECODE_HEADER),(int)bytecode->textseglen);
fprintf(optr,"rodata: $%08x %d\n",sizeof(BYTECODE_HEADER)+
fprintf(optr,"txt: $%08x %d\n",(unsigned int)sizeof(BYTECODE_HEADER),(int)bytecode->textseglen);
fprintf(optr,"rodata: $%08x %d\n",(unsigned int)sizeof(BYTECODE_HEADER)+
(unsigned int)bytecode->textseglen,(int)bytecode->rodataseglen);
rodata=p+sizeof(BYTECODE_HEADER)+(unsigned int)bytecode->textseglen;
fprintf(optr,"sdata: $%08x %d\n",sizeof(BYTECODE_HEADER)+
fprintf(optr,"sdata: $%08x %d\n",(unsigned int)sizeof(BYTECODE_HEADER)+
(unsigned int)bytecode->textseglen+
(unsigned int)bytecode->rodataseglen,(int)bytecode->sdataseglen);
fprintf(optr,"data: $%08x %d\n",sizeof(BYTECODE_HEADER)+
fprintf(optr,"data: $%08x %d\n",(unsigned int)sizeof(BYTECODE_HEADER)+
(unsigned int)bytecode->textseglen+
(unsigned int)bytecode->rodataseglen+
(unsigned int)bytecode->sdataseglen,(int)bytecode->dataseglen);
datasec=(unsigned char *)&p[sizeof(BYTECODE_HEADER)+(unsigned int)bytecode->textseglen+
bytecode->rodataseglen];
fprintf(optr,"bss: $%08x %d\n",sizeof(BYTECODE_HEADER)+
fprintf(optr,"bss: $%08x %d\n",(unsigned int)sizeof(BYTECODE_HEADER)+
(unsigned int)bytecode->textseglen+
(unsigned int)bytecode->rodataseglen+
(unsigned int)bytecode->sdataseglen+
(unsigned int)bytecode->dataseglen,(int)bytecode->bssseglen);
fprintf(optr,"str: $%08x %d\n",sizeof(BYTECODE_HEADER)+
fprintf(optr,"str: $%08x %d\n",(unsigned int)sizeof(BYTECODE_HEADER)+
(unsigned int)bytecode->textseglen+
(unsigned int)bytecode->rodataseglen+
(unsigned int) bytecode->sdataseglen+
(unsigned int)bytecode->dataseglen,(int)bytecode->stringseglen);
fprintf(optr,"sym: $%08x %d\n",sizeof(BYTECODE_HEADER)+
fprintf(optr,"sym: $%08x %d\n",(unsigned int)sizeof(BYTECODE_HEADER)+
(unsigned int)bytecode->textseglen+
(unsigned int)bytecode->rodataseglen+
(unsigned int)bytecode->sdataseglen+
......
......@@ -90,7 +90,7 @@ int everytime=0,alarmpc=-1,alarmpctype=0;
int stack[STACKSIZE];
#if defined ENVIRONMENT64
#if SIZEOF_VOID_P == 8
void *pointerbase=NULL;
#endif
......
......@@ -293,7 +293,7 @@ static inline unsigned int catchpointerbase(void *a) {
// 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!\n");
pointerbase=pb2;
pointerbase=(void *)pb2;
return((unsigned int)((unsigned long long)a&0xffffffffULL));
}
static inline void *i2p(unsigned int a) {
......
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