@@ -637,7 +637,8 @@ static inline void assert_is_page_aligned(uintptr_t ptr, size_t page_size) {
637
637
static int os_mmap_aligned (void * hint_addr , size_t length , size_t alignment ,
638
638
size_t page_size , int prot , int flag , int fd ,
639
639
size_t max_fd_size , os_mutex_t * lock_fd ,
640
- void * * out_addr , size_t * fd_size ) {
640
+ void * * out_addr , size_t * fd_size ,
641
+ size_t * fd_offset ) {
641
642
assert (out_addr );
642
643
643
644
size_t extended_length = length ;
@@ -650,7 +651,7 @@ static int os_mmap_aligned(void *hint_addr, size_t length, size_t alignment,
650
651
extended_length += alignment ;
651
652
}
652
653
653
- size_t fd_offset = 0 ;
654
+ * fd_offset = 0 ;
654
655
655
656
if (fd > 0 ) {
656
657
if (util_mutex_lock (lock_fd )) {
@@ -664,12 +665,12 @@ static int os_mmap_aligned(void *hint_addr, size_t length, size_t alignment,
664
665
return -1 ;
665
666
}
666
667
667
- fd_offset = * fd_size ;
668
+ * fd_offset = * fd_size ;
668
669
* fd_size += extended_length ;
669
670
util_mutex_unlock (lock_fd );
670
671
}
671
672
672
- void * ptr = os_mmap (hint_addr , extended_length , prot , flag , fd , fd_offset );
673
+ void * ptr = os_mmap (hint_addr , extended_length , prot , flag , fd , * fd_offset );
673
674
if (ptr == NULL ) {
674
675
LOG_PDEBUG ("memory mapping failed" );
675
676
return -1 ;
@@ -912,14 +913,14 @@ static umf_result_t os_alloc(void *provider, size_t size, size_t alignment,
912
913
return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
913
914
}
914
915
915
- size_t fd_offset = os_provider -> size_fd ; // needed for critnib_insert()
916
+ size_t fd_offset ; // needed for critnib_insert()
916
917
917
918
void * addr = NULL ;
918
919
errno = 0 ;
919
- ret = os_mmap_aligned (NULL , size , alignment , page_size ,
920
- os_provider -> protection , os_provider -> visibility ,
921
- os_provider -> fd , os_provider -> max_size_fd ,
922
- & os_provider -> lock_fd , & addr , & os_provider -> size_fd );
920
+ ret = os_mmap_aligned (
921
+ NULL , size , alignment , page_size , os_provider -> protection ,
922
+ os_provider -> visibility , os_provider -> fd , os_provider -> max_size_fd ,
923
+ & os_provider -> lock_fd , & addr , & os_provider -> size_fd , & fd_offset );
923
924
if (ret ) {
924
925
os_store_last_native_error (UMF_OS_RESULT_ERROR_ALLOC_FAILED , 0 );
925
926
LOG_ERR ("memory allocation failed" );
0 commit comments