Explorar el Código

* EPoll_Event is packed only on x86-64, not other 64 Bit CPUs, resolves #34416
* epoll_pwait expects the SigSet size as sixth parameter (kernel syscall only)
+ simple epoll* test

git-svn-id: trunk@44093 -

florian hace 5 años
padre
commit
2b7447c78d
Se han modificado 3 ficheros con 28 adiciones y 2 borrados
  1. 1 0
      .gitattributes
  2. 3 2
      rtl/linux/linux.pp
  3. 24 0
      tests/test/units/linux/tepoll1.pp

+ 1 - 0
.gitattributes

@@ -15638,6 +15638,7 @@ tests/test/units/fpwidestring/twide2fpwidestring.pp svneol=native#text/pascal
 tests/test/units/fpwidestring/twide6fpwidestring.pp svneol=native#text/pascal
 tests/test/units/fpwidestring/twide6fpwidestring.pp svneol=native#text/pascal
 tests/test/units/fpwidestring/twide7fpwidestring.pp svneol=native#text/pascal
 tests/test/units/fpwidestring/twide7fpwidestring.pp svneol=native#text/pascal
 tests/test/units/lineinfo/tlininfo.pp svneol=native#text/plain
 tests/test/units/lineinfo/tlininfo.pp svneol=native#text/plain
+tests/test/units/linux/tepoll1.pp svneol=native#text/pascal
 tests/test/units/linux/tstatx.pp svneol=native#text/pascal
 tests/test/units/linux/tstatx.pp svneol=native#text/pascal
 tests/test/units/math/tcmpnan.pp svneol=native#text/plain
 tests/test/units/math/tcmpnan.pp svneol=native#text/plain
 tests/test/units/math/tdivmod.pp svneol=native#text/plain
 tests/test/units/math/tdivmod.pp svneol=native#text/plain

+ 3 - 2
rtl/linux/linux.pp

@@ -279,7 +279,8 @@ type
   TEPoll_Data =  Epoll_Data;
   TEPoll_Data =  Epoll_Data;
   PEPoll_Data = ^Epoll_Data;
   PEPoll_Data = ^Epoll_Data;
 
 
-  EPoll_Event = {$ifdef cpu64} packed {$endif} record
+  { x86_64 uses a packed record so it is compatible with i386 }
+  EPoll_Event = {$ifdef cpux86_64} packed {$endif} record
     Events: cuint32;
     Events: cuint32;
     Data  : TEpoll_Data;
     Data  : TEpoll_Data;
   end;
   end;
@@ -622,7 +623,7 @@ function epoll_wait(epfd: cint; events: pepoll_event; maxevents, timeout: cint):
 begin
 begin
 {$if defined(generic_linux_syscalls)}
 {$if defined(generic_linux_syscalls)}
   epoll_wait := do_syscall(syscall_nr_epoll_pwait, tsysparam(epfd),
   epoll_wait := do_syscall(syscall_nr_epoll_pwait, tsysparam(epfd),
-    tsysparam(events), tsysparam(maxevents), tsysparam(timeout),0);
+    tsysparam(events), tsysparam(maxevents), tsysparam(timeout),0,sizeof(TSigSet));
 {$else}
 {$else}
   epoll_wait := do_syscall(syscall_nr_epoll_wait, tsysparam(epfd),
   epoll_wait := do_syscall(syscall_nr_epoll_wait, tsysparam(epfd),
     tsysparam(events), tsysparam(maxevents), tsysparam(timeout));
     tsysparam(events), tsysparam(maxevents), tsysparam(timeout));

+ 24 - 0
tests/test/units/linux/tepoll1.pp

@@ -0,0 +1,24 @@
+{ %target=linux }
+uses
+  baseunix,linux,ctypes;
+  
+var
+  e : tepoll_event;
+  es : array[0..10] of tepoll_event;
+  fd : cint;
+  i : Longint;
+begin
+  fillchar(es,sizeof(es),$de);
+  fd:=epoll_create(1);
+  
+  e.Events:=EPOLLIN;
+  e.Data.u32:=$1234568;
+  if (epoll_ctl(fd,EPOLL_CTL_ADD,0,@e)<>0) then
+    begin
+      writeln('Error in epoll_ctl');
+      fpclose(fd);
+      halt(1);
+    end;
+  i:=epoll_wait(fd,@es,length(es),100);
+  fpclose(fd);
+end.