Darwin port ... yet not ready

This commit is contained in:
Norayr Chilingarian 2014-03-19 06:23:47 +08:00
parent 02f7cad356
commit 279e037b5f
4 changed files with 44 additions and 36 deletions

View file

@ -12,10 +12,11 @@ uses double # as concatenation operator
*/
#include <alloca.h>
#include <string.h>
//#include <string.h>
extern void *memcpy(void *dest, const void *src, long n);
extern void *malloc(long size);
extern void *memcpy(void *dest, const void *src, unsigned long n);
//extern char *memcpy();
extern void *malloc(unsigned long size);
extern void exit(int status);
#define export

View file

@ -166,6 +166,10 @@ TYPE
END;
JmpBuf* = RECORD
(* macosx darwin 64bit, cpp /usr/include/setjmp.h
typedef int jmp_buf[((9 * 2) + 3 + 16)];
*)
(*bx*, si*, di*, bp*, sp*, pc*: LONGINT;*)
(* bits/setjmp.h sets up longer array in GNU libc *)
(*
@ -175,7 +179,10 @@ TYPE
typedef int __jmp_buf[6];
# endif
*)
bx*, si*, di*, bp*, sp*, pc*, ki*, ku*: LONGINT;
(*bx*, si*, di*, bp*, sp*, pc*, ki*, ku*: LONGINT;*)
f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15,
f16, f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29,
f30, f31, f32, f33, f34, f35, f36: INTEGER;
(* setjmp.h
/* Calling environment, plus possibly a saved signal mask. */
struct __jmp_buf_tag
@ -191,7 +198,7 @@ struct __jmp_buf_tag
*)
(*maskWasSaved*, savedMask*: LONGINT;*)
maskWasSaved*: INTEGER;
(*maskWasSaved*: INTEGER; *)
(*
# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
typedef struct
@ -200,27 +207,27 @@ typedef struct
} __sigset_t;
*)
savedMask*: sigsett;
(*savedMask*: sigsett;*)
END ;
Status* = RECORD (* struct stat *)
dev* : LONGINT; (* dev_t 8 *)
ino* : LONGINT; (* ino 8 *)
nlink* : LONGINT;
mode* : INTEGER;
uid*, gid*: INTEGER;
pad0* : INTEGER;
rdev* : LONGINT;
size* : LONGINT;
blksize* : LONGINT;
dev* : INTEGER; (* dev_t 4 *)
mode*: SHORTINT; mode1*: SHORTINT; (* mode_t 2 *)
nlink* : SHORTINT; nlink1*: SHORTINT; (* nlink_t 2 *)
ino* : LONGINT (* __darwin_ino64_t 8 *)
uid*, gid*: INTEGER; (* uid_t, gid_t 4 *)
rdev*: INTEGER; (* dev_t 4 *)
atime* : LONGINT; atimences* : LONGINT; (* struct timespec 16 *)
mtime* : LONGINT; mtimences* : LONGINT; (* struct timespec 16 *)
ctime* : LONGINT; ctimences* : LONGINT; (* struct timespec 16 *)
birthtime* : LONGINT; birthtimences* : LONGINT; (* struct timespec 16 *)
size*: LONGINT; (* off_t 8 *)
blocks* : LONGINT;
atime* : LONGINT;
atimences* : LONGINT;
mtime* : LONGINT;
mtimensec* : LONGINT;
ctime* : LONGINT;
ctimensec* : LONGINT;
unused0*, unused1*, unused2*: LONGINT;
blksize* : INTEGER;
flags* : INTEGER;
gen* : INTEGER;
lspare* : INTEGER;
qspare*, qspare1*: LONGINT;
END ;
(* from /usr/include/bits/time.h

View file

@ -23,23 +23,23 @@ struct {CHAR ch;} rec0;
struct {CHAR ch; LONGREAL x;} rec1;
struct {char x[65];} rec2;
void main()
int main()
{
long x, y;
/* get size and alignment of standard types */
printf("CHAR %d %d\n", sizeof(CHAR), (char*)&c.x - (char*)&c);
printf("BOOLEAN %d %d\n", sizeof(BOOLEAN), (char*)&b.x - (char*)&b);
printf("SHORTINT %d %d\n", sizeof(SHORTINT), (char*)&si.x - (char*)&si);
printf("INTEGER %d %d\n", sizeof(INTEGER), (char*)&i.x - (char*)&i);
printf("LONGINT %d %d\n", sizeof(LONGINT), (char*)&li.x - (char*)&li);
printf("SET %d %d\n", sizeof(SET), (char*)&s.x - (char*)&s);
printf("REAL %d %d\n", sizeof(REAL), (char*)&r.x - (char*)&r);
printf("LONGREAL %d %d\n", sizeof(LONGREAL), (char*)&lr.x - (char*)&lr);
printf("PTR %d %d\n", sizeof p.x, (char*)&p.x - (char*)&p);
printf("PROC %d %d\n", sizeof f.x, (char*)&f.x - (char*)&f);
printf("RECORD %d %d\n", (sizeof rec2 == 65) == (sizeof rec0 == 1), sizeof rec2 - 64);
printf("CHAR %lu %lu\n", sizeof(CHAR), (char*)&c.x - (char*)&c);
printf("BOOLEAN %lu %lu\n", sizeof(BOOLEAN), (char*)&b.x - (char*)&b);
printf("SHORTINT %lu %lu\n", sizeof(SHORTINT), (char*)&si.x - (char*)&si);
printf("INTEGER %lu %lu\n", sizeof(INTEGER), (char*)&i.x - (char*)&i);
printf("LONGINT %lu %lu\n", sizeof(LONGINT), (char*)&li.x - (char*)&li);
printf("SET %lu %lu\n", sizeof(SET), (char*)&s.x - (char*)&s);
printf("REAL %lu %lu\n", sizeof(REAL), (char*)&r.x - (char*)&r);
printf("LONGREAL %lu %lu\n", sizeof(LONGREAL), (char*)&lr.x - (char*)&lr);
printf("PTR %lu %lu\n", sizeof p.x, (char*)&p.x - (char*)&p);
printf("PROC %lu %lu\n", sizeof f.x, (char*)&f.x - (char*)&f);
printf("RECORD %d %lu\n", (sizeof rec2 == 65) == (sizeof rec0 == 1), sizeof rec2 - 64);
x = 1;
printf("ENDIAN %d %d\n", *(char*)&x, 0);
printf("ENDIAN %hhd %d\n", *(char*)&x, 0);
if (sizeof(CHAR)!=1) printf("error: CHAR should have size 1\n");
if (sizeof(BOOLEAN)!=1) printf("error: BOOLEAN should have size 1\n");
@ -47,7 +47,7 @@ void main()
if (sizeof(long)!=sizeof p.x) printf("error: LONGINT should have the same size as pointers\n");
if (sizeof(long)!=sizeof f.x) printf("error: LONGINT should have the same size as function pointers\n");
if (((sizeof rec2 == 65) == (sizeof rec0 == 1)) && ((sizeof rec2 - 64) != sizeof rec0))
printf("error: unsupported record layout sizeof rec0 = %d sizeof rec2 = %d\n", sizeof rec0, sizeof rec2);
printf("error: unsupported record layout sizeof rec0 = %lu sizeof rec2 = %lu\n", sizeof rec0, sizeof rec2);
/* test the __ASHR macro */
if (__ASHR(-1, 1) != -1) printf("error: ASH(-1, -1) # -1\n");

BIN
vocparam

Binary file not shown.