eina: add eina_file_map_populate()

This commit is contained in:
Carsten Haitzler 2013-07-06 22:01:23 +09:00
parent 28c2bd1918
commit d15d86e26f
4 changed files with 43 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2013-07-06 Carsten Haitzler (The Rasterman)
* Add direct eina file map populate controls
2013-07-04 Cedric Bail
* Eina: add eina_tiler_area_size_set and eina_tiler_strict_set to make Eina_Tiler in par with Evas_Tilebuf.

1
NEWS
View File

@ -32,6 +32,7 @@ Additions:
- Add eina_str_convert_len() to work around broken eina_str_convert()
- Add eina_file_dup()
- Add eina_tiler_area_size_set(), eina_tiler_strict_set()
- Add eina_file_map_populate()
* Eet:
- Add eet_mmap()
- Add eet_data_descriptor_name_get()

View File

@ -376,6 +376,9 @@ _eina_file_map_rule_apply(Eina_File_Populate rule, void *addr, unsigned long int
case EINA_FILE_SEQUENTIAL: flag = MADV_SEQUENTIAL; break;
case EINA_FILE_POPULATE: flag = MADV_WILLNEED; break;
case EINA_FILE_WILLNEED: flag = MADV_WILLNEED; break;
case EINA_FILE_DONTNEED: flag = MADV_DONTNEED; break;
case EINA_FILE_REMOVE: flag = MADV_REMOVE; break;
default: return tmp; break;
}
madvise(addr, size, flag);
@ -1079,6 +1082,20 @@ eina_file_map_free(Eina_File *file, void *map)
eina_lock_release(&file->lock);
}
EAPI void
eina_file_map_populate(Eina_File *file, Eina_File_Populate rule, void *map,
unsigned long int offset, unsigned long int length)
{
Eina_File_Map *em;
EINA_SAFETY_ON_NULL_RETURN(file);
eina_lock_take(&file->lock);
em = eina_hash_find(file->rmap, &map);
if (em) _eina_file_map_rule_apply(rule, ((char *)em->map) + offset,
length, em->hugetlb);
eina_lock_release(&file->lock);
}
EAPI Eina_Bool
eina_file_map_faulted(Eina_File *file, void *map)
{

View File

@ -139,7 +139,9 @@ typedef enum {
EINA_FILE_RANDOM, /**< Advise random memory access to the mapped memory. */
EINA_FILE_SEQUENTIAL, /**< Advise sequential memory access to the mapped memory. */
EINA_FILE_WILLNEED, /**< Advise need for all the mapped memory. */
EINA_FILE_POPULATE /**< Request all the mapped memory. */
EINA_FILE_POPULATE, /**< Request all the mapped memory. */
EINA_FILE_DONTNEED, /**< Indicate that the memory is no longer needed. This may result in the memory being removed from any caches if applicable. @since 1.8 */
EINA_FILE_REMOVE /**< This memory is to be released and any content will be lost. Subsequent accesses will succeed but return fresh memory as if accessed for the first time. This may not suceed if the filesystem does not support it. @since 1.8 */
} Eina_File_Populate;
/* Why do this? Well PATH_MAX may vary from when eina itself is compiled
@ -576,6 +578,24 @@ EAPI void *eina_file_map_new(Eina_File *file, Eina_File_Populate rule,
*/
EAPI void eina_file_map_free(Eina_File *file, void *map);
/**
* @brief Ask the OS to populate or otherwise pages of memory in file mapping
*
* @param file The file handle from whih the map comes
* @param map Memory that was mapped inside of which the memory range is
* @param offset The offset in bytes from the start of the map address
* @param length The length in bytes of the memory region to populate
*
* This advises the operating system as to what to do with the memory mapped
* to the given @p file. This affects a specific range of memory and may not
* be honored if the system chooses to ignore the request.
*
* @sine 1.8
*/
EAPI void
eina_file_map_populate(Eina_File *file, Eina_File_Populate rule, void *map,
unsigned long int offset, unsigned long int length);
/**
* @brief Map line by line in memory efficiently with an Eina_Iterator
* @param file The file to run over