From: caro Date: Wed, 7 Mar 2012 08:58:55 +0000 (+0000) Subject: Eina: cosmetic (move eina_file_mmap_faulty to the 'global' part) X-Git-Tag: 2.0_alpha~28^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b5e9f301254aec9b7f8f4cae35a0f470de50c7cd;p=framework%2Fuifw%2Feina.git Eina: cosmetic (move eina_file_mmap_faulty to the 'global' part) git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@68908 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/eina_file.c b/src/lib/eina_file.c index bdb4cbe..9d58950 100644 --- a/src/lib/eina_file.c +++ b/src/lib/eina_file.c @@ -623,6 +623,61 @@ eina_file_shutdown(void) return EINA_TRUE; } +void +eina_file_mmap_faulty(void *addr, long page_size) +{ + Eina_File_Map *m; + Eina_File *f; + Eina_Iterator *itf; + Eina_Iterator *itm; + + /* NOTE: I actually don't know if other thread are running, I will try to take the lock. + It may be possible that if other thread are not running and they were in the middle of + accessing an Eina_File this lock are still taken and we will result as a deadlock. */ + eina_lock_take(&_eina_file_lock_cache); + + itf = eina_hash_iterator_data_new(_eina_file_cache); + EINA_ITERATOR_FOREACH(itf, f) + { + Eina_Bool faulty = EINA_FALSE; + + eina_lock_take(&f->lock); + + if (f->global_map) + { + if ((unsigned char *) addr < (((unsigned char *)f->global_map) + f->length) && + (((unsigned char *) addr) + page_size) >= (unsigned char *) f->global_map) + { + f->global_faulty = EINA_TRUE; + faulty = EINA_TRUE; + } + } + + if (!faulty) + { + itm = eina_hash_iterator_data_new(f->map); + EINA_ITERATOR_FOREACH(itm, m) + { + if ((unsigned char *) addr < (((unsigned char *)m->map) + m->length) && + (((unsigned char *) addr) + page_size) >= (unsigned char *) m->map) + { + m->faulty = EINA_TRUE; + faulty = EINA_TRUE; + break; + } + } + eina_iterator_free(itm); + } + + eina_lock_release(&f->lock); + + if (faulty) break; + } + eina_iterator_free(itf); + + eina_lock_release(&_eina_file_lock_cache); +} + /*============================================================================* * API * *============================================================================*/ @@ -1220,61 +1275,6 @@ eina_file_xattr_value_get(Eina_File *file) return eina_xattr_value_fd_ls(file->fd); } -void -eina_file_mmap_faulty(void *addr, long page_size) -{ - Eina_File_Map *m; - Eina_File *f; - Eina_Iterator *itf; - Eina_Iterator *itm; - - /* NOTE: I actually don't know if other thread are running, I will try to take the lock. - It may be possible that if other thread are not running and they were in the middle of - accessing an Eina_File this lock are still taken and we will result as a deadlock. */ - eina_lock_take(&_eina_file_lock_cache); - - itf = eina_hash_iterator_data_new(_eina_file_cache); - EINA_ITERATOR_FOREACH(itf, f) - { - Eina_Bool faulty = EINA_FALSE; - - eina_lock_take(&f->lock); - - if (f->global_map) - { - if ((unsigned char *) addr < (((unsigned char *)f->global_map) + f->length) && - (((unsigned char *) addr) + page_size) >= (unsigned char *) f->global_map) - { - f->global_faulty = EINA_TRUE; - faulty = EINA_TRUE; - } - } - - if (!faulty) - { - itm = eina_hash_iterator_data_new(f->map); - EINA_ITERATOR_FOREACH(itm, m) - { - if ((unsigned char *) addr < (((unsigned char *)m->map) + m->length) && - (((unsigned char *) addr) + page_size) >= (unsigned char *) m->map) - { - m->faulty = EINA_TRUE; - faulty = EINA_TRUE; - break; - } - } - eina_iterator_free(itm); - } - - eina_lock_release(&f->lock); - - if (faulty) break; - } - eina_iterator_free(itf); - - eina_lock_release(&_eina_file_lock_cache); -} - EAPI int eina_file_statat(void *container, Eina_File_Direct_Info *info, Eina_Stat *st) {