The following definitions allow big mmf:
Linux
cocurrent'jmf'
   c_open=:   'libc.so.6 open   i *c i i'&(15!:0)
   c_close=:  'libc.so.6 close  i i'&(15!:0)
   c_lseek=:  'libc.so.6 lseek  x i x i'&(15!:0)
   c_write=:  'libc.so.6 write  x i * x'&(15!:0)
   c_mmap=:   'libc.so.6 mmap   * * x i i i x'&(15!:0)
   c_munmap=: 'libc.so.6 munmap i * x'&(15!:0)
Windows
cocurrent'jmf'
K32=: 2^32
K31=: 2^31
MAXLONG32=: <._1+K31

long64to32=: 3 : 0
       y=. (2$K32)#:y
       ({.;(}.))|.<.((y>K31)*-K32)+y
)
long32to64=: <.@(K32&#.)@|:@(K32&|)@;@|.

SetFilePointerDLLCALL=: >@{.@('kernel32 SetFilePointer i i i *i i'&(15!:0))
GetFileSizeDLLCALL=: >@{.@('kernel32 GetFileSize i i *i'&(15!:0))

SetFilePointerR=: verb define
       'hFile lDistanceToMove lpDistanceToMoveHigh dwMoveMethod'=. y
       if. (lpDistanceToMoveHigh-:NULLPTR) *. (lDistanceToMove>MAXLONG32) do.
               'lDistanceToMove lpDistanceToMoveHigh'=. long64to32
lDistanceToMove
       end.
       SetFilePointerDLLCALL
hFile;lDistanceToMove;lpDistanceToMoveHigh;dwMoveMethod
)

GetFileSizeR=: verb define
       hFile=. >{.y
       lpFileSizeHigh=. ,2
       lpFileSize=. GetFileSizeDLLCALL hFile;lpFileSizeHigh
       long32to64 lpFileSize,lpFileSizeHigh
)



To illustrate my solved test case (OpenSUSE 10.2 x64), here is the
transcript of a session with re-defined verbs.
IMPORTANT: ulimit -v unlimited was called before starting the J session.

   loadd '/home/vstar/ngl-beta/usr/mmftest.ijs'
   9!:7'+++++++++|-'

   FN=: jpath'~temp/test.jmf'
   GB=: 1 : '(*&(1024(<[EMAIL PROTECTED])3)) u'

   cd=:       15!:0
   cder=:     15!:10
   cderx=:    15!:11
   c_open=:   'libc.so.6 open   i *c i i'&cd
   c_close=:  'libc.so.6 close  i i'&cd
   c_lseek=:  'libc.so.6 lseek  x i x i'&cd
   c_write=:  'libc.so.6 write  x i * x'&cd
   c_mmap=:   'libc.so.6 mmap   * * x i i i x'&cd
   c_munmap=: 'libc.so.6 munmap i * x'&cd

   'O_RDONLY O_RDWR O_CREAT O_TRUNC'=: 0 2 64 512
   HS=:         568
   AFNJA=:      2
   JINT=:       4
   SZI=:        8
   SEEK_SET=:   0
   PROT_READ=:  1
   MAP_SHARED=: 1
   ENOMEM=:     12

   ]fn=: FN
/home/vstar/nglj64/temp/test.jmf
   ]ms=: 30 GB
32212254720
   ]ts=: HS+ms
32212255288

   NB. Create File
   ]fh=: 0 pick c_open fn; ((23 b.)/O_RDWR,O_CREAT,O_TRUNC); 8b666
4
   c_lseek fh;(<:ts);SEEK_SET
+-----------+-+-----------+-+
|32212255287|4|32212255287|0|
+-----------+-+-----------+-+
   c_write fh; (,0{a.); 0+1
+-+-+-+-+
|1|4| |1|
+-+-+-+-+
   c_lseek fh;0 ;SEEK_SET
+-+-+-+-+
|0|4|0|0|
+-+-+-+-+
   ]d=: HS,AFNJA,ms,JINT,0,0,1,0
568 2 32212254720 4 0 0 1 0
   c_write fh;d;(SZI*#d)
+--+-+---------------------------+--+
|64|4|568 2 32212254720 4 0 0 1 0|64|
+--+-+---------------------------+--+
   c_close fh
+-+-+
|0|4|
+-+-+

   NB. Map File
   ]mh=: ts=: 1!:4 <fn
32212255288
   ]fh=:  >{.c_open fn;O_RDONLY;0
4
   ]fad=: >{.c_mmap (<0);ts;PROT_READ;MAP_SHARED;fh;0
46983863193600
   ENOMEM -: >{.cderx''
0
   c_munmap (<fad);mh
+-+----------------+-----------+
|0|+--------------+|32212255288|
| ||46983863193600||           |
| |+--------------+|           |
+-+----------------+-----------+
   c_close fh
+-+-+
|0|4|
+-+-+

   (1!:55) <FN
1
   exit 0


On Fri, Apr 11, 2008 at 10:12 AM, bill lam <[EMAIL PROTECTED]> wrote:
> Thank you for confirmation that it works.
>
>  For Win64, there are GetFileSizeEx and SetFilePointerEx that work directly
> with 64-bit integer, however I cannot verify their signature because I do
> not have visual studio. I commit the changes to svn, in project
> ~Source/api/mapped/mapped
>  please test if it work or not.
>
>
>  regards,
>
>
>  ----------------------------------------------------------------------
>  For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to