@@ -354,20 +354,18 @@ mergeInto(LibraryManager.library, {
354
354
MEMFS . expandFileStorage ( stream . node , offset + length ) ;
355
355
stream . node . usedBytes = Math . max ( stream . node . usedBytes , offset + length ) ;
356
356
} ,
357
- mmap : function ( stream , buffer , offset , length , position , prot , flags ) {
358
- #if ASSERTIONS
359
- // The data buffer should be a typed array view
360
- assert ( ! ( buffer instanceof ArrayBuffer ) ) ;
361
- #endif
357
+ mmap : function ( stream , address , length , position , prot , flags ) {
358
+ // We don't currently support location hints for the address of the mapping
359
+ assert ( address === 0 ) ;
360
+
362
361
if ( ! FS . isFile ( stream . node . mode ) ) {
363
362
throw new FS . ErrnoError ( { { { cDefine ( 'ENODEV' ) } } } ) ;
364
363
}
365
364
var ptr ;
366
365
var allocated ;
367
366
var contents = stream . node . contents ;
368
367
// Only make a new copy when MAP_PRIVATE is specified.
369
- if ( ! ( flags & { { { cDefine ( 'MAP_PRIVATE' ) } } } ) &&
370
- contents . buffer === buffer . buffer ) {
368
+ if ( ! ( flags & { { { cDefine ( 'MAP_PRIVATE' ) } } } ) && contents . buffer === buffer ) {
371
369
// We can't emulate MAP_SHARED when the file is not backed by the buffer
372
370
// we're mapping to (e.g. the HEAP buffer).
373
371
allocated = false ;
@@ -382,17 +380,14 @@ mergeInto(LibraryManager.library, {
382
380
}
383
381
}
384
382
allocated = true ;
385
- // malloc() can lead to growing the heap. If targeting the heap, we need to
386
- // re-acquire the heap buffer object in case growth had occurred.
387
- var fromHeap = ( buffer . buffer == HEAP8 . buffer ) ;
388
383
ptr = _malloc ( length ) ;
389
384
if ( ! ptr ) {
390
385
throw new FS . ErrnoError ( { { { cDefine ( 'ENOMEM' ) } } } ) ;
391
386
}
392
387
#if CAN_ADDRESS_2GB
393
388
ptr >>>= 0 ;
394
389
#endif
395
- ( fromHeap ? HEAP8 : buffer ) . set ( contents , ptr ) ;
390
+ HEAP8 . set ( contents , ptr ) ;
396
391
}
397
392
return { ptr : ptr , allocated : allocated } ;
398
393
} ,
0 commit comments