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 <alloca.h>
#include <string.h> //#include <string.h>
extern void *memcpy(void *dest, const void *src, long n); extern void *memcpy(void *dest, const void *src, unsigned long n);
extern void *malloc(long size); //extern char *memcpy();
extern void *malloc(unsigned long size);
extern void exit(int status); extern void exit(int status);
#define export #define export

View file

@ -166,6 +166,10 @@ TYPE
END; END;
JmpBuf* = RECORD 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;*) (*bx*, si*, di*, bp*, sp*, pc*: LONGINT;*)
(* bits/setjmp.h sets up longer array in GNU libc *) (* bits/setjmp.h sets up longer array in GNU libc *)
(* (*
@ -175,7 +179,10 @@ TYPE
typedef int __jmp_buf[6]; typedef int __jmp_buf[6];
# endif # 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 (* setjmp.h
/* Calling environment, plus possibly a saved signal mask. */ /* Calling environment, plus possibly a saved signal mask. */
struct __jmp_buf_tag struct __jmp_buf_tag
@ -191,7 +198,7 @@ struct __jmp_buf_tag
*) *)
(*maskWasSaved*, savedMask*: LONGINT;*) (*maskWasSaved*, savedMask*: LONGINT;*)
maskWasSaved*: INTEGER; (*maskWasSaved*: INTEGER; *)
(* (*
# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int))) # define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
typedef struct typedef struct
@ -200,27 +207,27 @@ typedef struct
} __sigset_t; } __sigset_t;
*) *)
savedMask*: sigsett; (*savedMask*: sigsett;*)
END ; END ;
Status* = RECORD (* struct stat *) Status* = RECORD (* struct stat *)
dev* : LONGINT; (* dev_t 8 *) dev* : INTEGER; (* dev_t 4 *)
ino* : LONGINT; (* ino 8 *) mode*: SHORTINT; mode1*: SHORTINT; (* mode_t 2 *)
nlink* : LONGINT; nlink* : SHORTINT; nlink1*: SHORTINT; (* nlink_t 2 *)
mode* : INTEGER; ino* : LONGINT (* __darwin_ino64_t 8 *)
uid*, gid*: INTEGER; uid*, gid*: INTEGER; (* uid_t, gid_t 4 *)
pad0* : INTEGER; rdev*: INTEGER; (* dev_t 4 *)
rdev* : LONGINT; atime* : LONGINT; atimences* : LONGINT; (* struct timespec 16 *)
size* : LONGINT; mtime* : LONGINT; mtimences* : LONGINT; (* struct timespec 16 *)
blksize* : LONGINT; ctime* : LONGINT; ctimences* : LONGINT; (* struct timespec 16 *)
birthtime* : LONGINT; birthtimences* : LONGINT; (* struct timespec 16 *)
size*: LONGINT; (* off_t 8 *)
blocks* : LONGINT; blocks* : LONGINT;
atime* : LONGINT; blksize* : INTEGER;
atimences* : LONGINT; flags* : INTEGER;
mtime* : LONGINT; gen* : INTEGER;
mtimensec* : LONGINT; lspare* : INTEGER;
ctime* : LONGINT; qspare*, qspare1*: LONGINT;
ctimensec* : LONGINT;
unused0*, unused1*, unused2*: LONGINT;
END ; END ;
(* from /usr/include/bits/time.h (* from /usr/include/bits/time.h

View file

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

BIN
vocparam

Binary file not shown.