some bugfixes

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

View file

@ -400,11 +400,6 @@ when hasSpawnH:
header: "<spawn.h>".} = cint header: "<spawn.h>".} = cint
type 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 TSocklen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cint
TSa_Family* {.importc: "sa_family_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 pure, final.} = object ## struct sockaddr_storage
ss_family*: Tsa_family ## Address family. 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, TIOVec* {.importc: "struct iovec", pure, final,
header: "<sys/uio.h>".} = object ## struct iovec header: "<sys/uio.h>".} = object ## struct iovec
iov_base*: pointer ## Base address of a memory region for input or output. 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_CUR* {.importc, header: "<unistd.h>".}: cint
SEEK_END* {.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 SCM_RIGHTS* {.importc, header: "<sys/socket.h>".}: cint
## Indicates that the data array contains the access rights ## Indicates that the data array contains the access rights
## to be sent or received. ## to be sent or received.
@ -1526,6 +1525,8 @@ var
SHUT_WR* {.importc, header: "<sys/socket.h>".}: cint SHUT_WR* {.importc, header: "<sys/socket.h>".}: cint
## Disables further send operations. ## Disables further send operations.
IF_NAMESIZE* {.importc, header: "<net/if.h>".}: cint
IPPROTO_IP* {.importc, header: "<netinet/in.h>".}: cint IPPROTO_IP* {.importc, header: "<netinet/in.h>".}: cint
## Internet protocol. ## Internet protocol.
IPPROTO_IPV6* {.importc, header: "<netinet/in.h>".}: cint IPPROTO_IPV6* {.importc, header: "<netinet/in.h>".}: cint
@ -2288,11 +2289,6 @@ proc makecontext*(a1: var Tucontext, a4: proc (){.noconv.}, a3: cint) {.
varargs, importc, header: "<ucontext.h>".} varargs, importc, header: "<ucontext.h>".}
proc setcontext*(a1: var Tucontext): cint {.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 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 {. proc readv*(a1: cint, a2: ptr TIOVec, a3: cint): int {.
importc, header: "<sys/uio.h>".} 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 {. proc socketpair*(a1, a2, a3: cint, a4: var array[0..1, cint]): cint {.
importc, header: "<sys/socket.h>".} 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 {. proc IN6_IS_ADDR_UNSPECIFIED* (a1: ptr TIn6Addr): cint {.
importc, header: "<netinet/in.h>".} importc, header: "<netinet/in.h>".}
## Unspecified address. ## Unspecified address.

View file

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

View file

@ -249,12 +249,12 @@ procedure UseMagic(m: BModule; const name: string); forward;
{$include 'ccgtypes.pas'} {$include 'ccgtypes.pas'}
// ------------------------------ Manager of temporaries ------------------ // ------------------------------ Manager of temporaries ------------------
(*
function beEqualTypes(a, b: PType): bool; function beEqualTypes(a, b: PType): bool;
begin begin
// returns whether two type are equal for the backend // returns whether two type are equal for the backend
result := sameType(skipGenericRange(a), skipGenericRange(b)) result := sameType(skipGenericRange(a), skipGenericRange(b))
end; end; *)
procedure getTemp(p: BProc; t: PType; var result: TLoc); procedure getTemp(p: BProc; t: PType; var result: TLoc);
begin begin
@ -642,6 +642,10 @@ begin
else begin else begin
fillResult(res); fillResult(res);
assignParam(p, res); assignParam(p, res);
if skipGeneric(res.typ).kind = tyArray then begin
include(res.loc.flags, lfIndirect);
res.loc.s := OnUnknown;
end;
end; end;
initVariable(p, res); initVariable(p, res);
genObjectInit(p, res.typ, res.loc, true); 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") greeting = SDL_LoadBmp("backgrnd.bmp")
if greeting == nil: if greeting == nil:
write(stdout, "greeting is nil!") write(stdout, "greeting is nil!")
r.x = 0 r.x = 0'i16
r.y = 0 r.y = 0'i16
discard SDL_blitSurface(greeting, nil, screen, addr(r)) discard SDL_blitSurface(greeting, nil, screen, addr(r))
discard SDL_flip(screen) discard SDL_flip(screen)
SDL_Delay(3000) SDL_Delay(3000)

Binary file not shown.