some bugfixes

This commit is contained in:
Andreas Rumpf
2009-05-14 01:46:41 +02:00
parent 233687adf7
commit 0e9d65e4ab
5 changed files with 34 additions and 19 deletions

View File

@@ -400,11 +400,6 @@ when hasSpawnH:
header: "<spawn.h>".} = cint
type
Tif_nameindex* {.importc: "struct if_nameindex", final,
pure, header: "<net/if.h>".} = object ## struct if_nameindex
if_index*: cint ## Numeric index of the interface.
if_name*: cstring ## Null-terminated name of the interface.
TSocklen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cint
TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cint
@@ -418,6 +413,12 @@ type
pure, final.} = object ## struct sockaddr_storage
ss_family*: Tsa_family ## Address family.
Tif_nameindex* {.importc: "struct if_nameindex", final,
pure, header: "<net/if.h>".} = object ## struct if_nameindex
if_index*: cint ## Numeric index of the interface.
if_name*: cstring ## Null-terminated name of the interface.
TIOVec* {.importc: "struct iovec", pure, final,
header: "<sys/uio.h>".} = object ## struct iovec
iov_base*: pointer ## Base address of a memory region for input or output.
@@ -1442,8 +1443,6 @@ var
SEEK_CUR* {.importc, header: "<unistd.h>".}: cint
SEEK_END* {.importc, header: "<unistd.h>".}: cint
IF_NAMESIZE* {.importc, header: "<net/if.h>".}: cint
SCM_RIGHTS* {.importc, header: "<sys/socket.h>".}: cint
## Indicates that the data array contains the access rights
## to be sent or received.
@@ -1525,6 +1524,8 @@ var
## Disables further send and receive operations.
SHUT_WR* {.importc, header: "<sys/socket.h>".}: cint
## Disables further send operations.
IF_NAMESIZE* {.importc, header: "<net/if.h>".}: cint
IPPROTO_IP* {.importc, header: "<netinet/in.h>".}: cint
## Internet protocol.
@@ -2288,11 +2289,6 @@ proc makecontext*(a1: var Tucontext, a4: proc (){.noconv.}, a3: cint) {.
varargs, importc, header: "<ucontext.h>".}
proc setcontext*(a1: var Tucontext): cint {.importc, header: "<ucontext.h>".}
proc swapcontext*(a1, a2: var Tucontext): cint {.importc, header: "<ucontext.h>".}
proc if_nametoindex*(a1: cstring): cint {.importc, header: "<net/if.h>".}
proc if_indextoname*(a1: cint, a2: cstring): cstring {.
importc, header: "<net/if.h>".}
proc if_nameindex*(): ptr Tif_nameindex {.importc, header: "<net/if.h>".}
proc if_freenameindex*(a1: ptr Tif_nameindex) {.importc, header: "<net/if.h>".}
proc readv*(a1: cint, a2: ptr TIOVec, a3: cint): int {.
importc, header: "<sys/uio.h>".}
@@ -2351,6 +2347,12 @@ proc sockatmark*(a1: cint): cint {.
proc socketpair*(a1, a2, a3: cint, a4: var array[0..1, cint]): cint {.
importc, header: "<sys/socket.h>".}
proc if_nametoindex*(a1: cstring): cint {.importc, header: "<net/if.h>".}
proc if_indextoname*(a1: cint, a2: cstring): cstring {.
importc, header: "<net/if.h>".}
proc if_nameindex*(): ptr Tif_nameindex {.importc, header: "<net/if.h>".}
proc if_freenameindex*(a1: ptr Tif_nameindex) {.importc, header: "<net/if.h>".}
proc IN6_IS_ADDR_UNSPECIFIED* (a1: ptr TIn6Addr): cint {.
importc, header: "<netinet/in.h>".}
## Unspecified address.

View File

@@ -148,6 +148,12 @@ begin
end
end;
function mapReturnType(typ: PType): TCTypeKind;
begin
if skipGeneric(typ).kind = tyArray then result := ctPtr
else result := mapType(typ)
end;
function getTypeDescAux(m: BModule; typ: PType;
var check: TIntSet): PRope; forward;
@@ -232,7 +238,8 @@ procedure fillResult(param: PSym);
begin
fillLoc(param.loc, locParam, param.typ, ropeff('Result', '%Result', []),
OnStack);
if (mapType(param.typ) <> ctArray) and IsInvalidReturnType(param.typ) then
if (mapReturnType(param.typ) <> ctArray)
and IsInvalidReturnType(param.typ) then
begin
include(param.loc.flags, lfIndirect);
param.loc.s := OnUnknown
@@ -277,8 +284,10 @@ begin
end;
if (t.sons[0] <> nil) and isInvalidReturnType(t.sons[0]) then begin
if params <> nil then app(params, ', ');
app(params, getTypeDescAux(m, t.sons[0], check));
if (mapType(t.sons[0]) <> ctArray) or (gCmd = cmdCompileToLLVM) then
arr := t.sons[0];
//if skipGeneric(arr).kind = tyArray then arr := arr.sons[1];
app(params, getTypeDescAux(m, arr, check));
if (mapReturnType(t.sons[0]) <> ctArray) or (gCmd = cmdCompileToLLVM) then
app(params, '*'+'');
appff(params, ' Result', ' @Result', []);
end;

View File

@@ -249,12 +249,12 @@ procedure UseMagic(m: BModule; const name: string); forward;
{$include 'ccgtypes.pas'}
// ------------------------------ Manager of temporaries ------------------
(*
function beEqualTypes(a, b: PType): bool;
begin
// returns whether two type are equal for the backend
result := sameType(skipGenericRange(a), skipGenericRange(b))
end;
end; *)
procedure getTemp(p: BProc; t: PType; var result: TLoc);
begin
@@ -642,6 +642,10 @@ begin
else begin
fillResult(res);
assignParam(p, res);
if skipGeneric(res.typ).kind = tyArray then begin
include(res.loc.flags, lfIndirect);
res.loc.s := OnUnknown;
end;
end;
initVariable(p, res);
genObjectInit(p, res.typ, res.loc, true);

View File

@@ -15,8 +15,8 @@ if SDL_Init(SDL_INIT_VIDEO) == 0:
greeting = SDL_LoadBmp("backgrnd.bmp")
if greeting == nil:
write(stdout, "greeting is nil!")
r.x = 0
r.y = 0
r.x = 0'i16
r.y = 0'i16
discard SDL_blitSurface(greeting, nil, screen, addr(r))
discard SDL_flip(screen)
SDL_Delay(3000)

Binary file not shown.