[fpc-pascal] fpMMap and FreeBSD

Xromov Kirill volgaboatman at mail.ru
Thu Apr 21 17:00:10 CEST 2005


Hello fpc-pascal,

  I try to use fpMMap function to access file data under FreeBSD 5.3-RELEASE
  with fpc-1.9.8. But code from examle
  (http://www.freepascal.org/docs-html/rtl/baseunix/fpmmap.html) not working.


  P:=Pchar(fpmmap(nil,len+1 ,PROT_READ or PROT_WRITE,MAP_PRIVATE,fd,0));
  If longint(P)=-1 then Halt(4);
  // At this P is normal pointer like (0x291ad000).
  
  Writeln('Read in memory  :',P);

  and at this point: Program received signal SIGBUS, Bus error.


  And strange moment. Another example in C work OK.
---
  if ((src = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED, fdin, 0)) == (caddr_t) -1)
    perror ("mmap error for input");

  /* mmap the output file */
  if ((dst = mmap (0, statbuf.st_size, PROT_READ | PROT_WRITE,
                   MAP_SHARED, fdout, 0)) == (caddr_t) -1)
    perror ("mmap error for output");

  /* this copies the input file to the output file */
  memcpy (dst, src, statbuf.st_size);
---


  
-- 
Best regards,
 Xromov                          mailto:volgaboatman at mail.ru





More information about the fpc-pascal mailing list