Commit Graph

60 Commits

Author SHA1 Message Date
Stefan Schmidt f3d9b8ee70 esacpe: remove library from tree
This has not been used for a while and is not even buildable after our
switch to meson. It was a niche to start with given that it needed the
PS3 OS to run on. I asked for any remaining users at EDD and on the list
but heard nothing. Time to remove.

Signed-off-by: Stefan Schmidt <s.schmidt@samsung.com>
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10778
2019-12-04 12:21:24 -08:00
Carsten Haitzler 1127409564 eina - add portable close all fd's we don't need function
close all fd's starting at a given fd and then leving out an exception
list specially passed, if any. useful for fork+exec. this uses it in
efl's fork+exec paths.

@feat
2019-11-27 16:52:49 +00:00
Carsten Haitzler 807c8e7357 eina file - don't double unlock a lock
thanks to coverity - found this double unlock path in case of error.

fix CID 1403899
2019-08-11 12:47:38 +01:00
Carsten Haitzler 9b294d6284 eina file - stat generation inexactness support
this is a performance optimization. it brings in a "stat generation".
for now it's disabled by default so we retain previous behavior. this
stops eina file from opening and stating a file every time you open
... it only does it if stat generation is off, or, if the generation
changed since the last time it opened that file. this makes cache hits
not have a 3 syscall cost (open+fstat+close). this optimizes that
lower end of things path. but .. it comes at a cost. if the file
changes before generation ticks over (which this forces to tick over
every time the loop exits idle by default).

now here is something to ask.

1. should we have this on by default and accept the "inexactness"
since you can eina_file_statgen_next() before any call that would do
i/o to force it to look at the real file stat info...
2. should we tick over every idle enter OR every N idle enters  or
every frame we render instead? ... i want to avoid getting a timestamp
or having a timer interrupt often... so what should we do?

at least this introduces the idea, some api's and an env var to turn
this on. it definitely cuts down syscalls during things like creation
of widdgets or objects in large batches etc.
2019-07-28 11:51:15 +01:00
Carsten Haitzler d19e435ff9 reduce syscalls on opening files - roll CLOEXEC into open
on linux open supports() O_CLOEXEC. add test case for this in meson
build and ifdef. this rolls 3 syscalls into 1 as we were doing open,
then fnctl to get and fcntl to set flags.

less syscalls is a good thing as syscalls are not cheap on some
architectures or systems. I've seen a syscall on 1 system take 2-3x
as long as another and another syscall in the same 2 system
comparison take 10x as long. depending on the syscall you may only
have a budget of something like 5000 syscalls "per frame" (60fps)
before you spend all of your frame time just in syscalls not
doing any processing, so we should keep these down if possible
and that is what this does.
2019-07-26 11:43:17 +01:00
Mike Blumenkrantz 655c816539 eina/file: use INFO log level when eina_file_open fails
Summary:
this function is commonly used to detect the existence of files using
its return value. for this purpose, printing warnings any time the file
cannot be opened is spammy and not very helpful in the context of detecting
actual errors.
Depends on D8950

Reviewers: devilhorns

Reviewed By: devilhorns

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8951
2019-05-29 12:29:03 -04:00
Carsten Haitzler 79c783d16f eina file - fix unused param warning by marking as unused
unsued in some ifdef paths, so mark as such to avouid warning noise
2018-11-09 11:43:58 +00:00
Al Poole a538f47854 eina_file: make sure we use a stringshare when virtualized.
As the filename is now a stringshare, also make sure virtual
files use stringshares for the filename! Also when unmapping
we still need to test whether it is copied or not as unmap
will break on less tolerant architectures.

@fix T6449
2017-11-30 13:57:25 +00:00
Cedric Bail 6e64a104a6 eina: use a stringshare to store the filename internally.
T6164
2017-10-17 16:15:19 -07:00
Subodh Kumar f418d62af3 eina: comparing less than zero with unsigned long int
Summary:
Unsigned integer should not be compared to less than zero
@fix

Test Plan: NA

Reviewers: cedric

Reviewed By: cedric

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D5269

Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2017-10-09 16:37:50 -07:00
Jean-Philippe Andre 05c051405e eina file: Ensure populate is safe to call
This makes sure that the call to madvise is safe. On Linux it's not too
much of an issue as checks are made inside madvise, and the worst that
can happen is an error is returned (EINVAL). Not great.

But if MAP_POPULATE is not present, as is the case on *BSD, then the
internal function _eina_file_map_populate() is used for the populate
rule. In that case actual data is read and we should make sure not to
trigger a segfault or bus error.

Also, this makes sure that in case of HugeTLB we actually populate all
pages, rather than one page out of 8 (we were jumping by 16Mb instead of
2Mb).

Note: Can we get the size of a HugeTLB at runtime? We're assuming 2Mb
which might very well not be the case!
See: https://wiki.debian.org/Hugepages

Tested by disabling MAP_POPULATE and observing crashes :)

@fix
2017-09-18 11:58:53 +09:00
Jean-Philippe Andre b2ea60691e eina file: Fix map_populate on the global map
If eina_file_map_all() is called, the map isn't added to the internal
hash "rmap" and so _eina_file_map_rule_apply() would never be called.

@fix

asa
2017-09-18 11:58:53 +09:00
Carsten Haitzler a5c8e883d8 eina mmap safety - only map zeropages if it's an eina file that sigbuses
restrict mapping /dev/zero to only eina files having a sigbus
reported. the mmap was before all our file access used eina_file i
think thus the raw mmap of it. now walk all eina files and find the
candidate and only then if it exists flag is as having a faulty i/o
backing and map the zerto pages then return, otherwise call abort.
more restricted mapping and perhaps a fix for not trapping non-efl
issues.

@fix
2017-08-30 12:03:41 +09:00
Guilherme Iscaro 48443fda8f Eina_File: Avoid using munmap() on file->global_map.
When a virtualized file is created the file->global_map will not
point to a mmapped region, thus it's not safe to use munmap() during
the file cleanup. Only use munmap() if the file is backed by a FD.

Fixes: T5234.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-08-02 16:03:20 -07:00
Al Poole 9aeaef55c4 eina_file: fix unmap of unmapped region when Eina_File has copied data and not a map;
Summary:
This was causing problems on non-Linux architectures as eina_file_real_close unmapped not mapped data. Added a "copied" flag to Eina_File which is set on eina_file_virtualize (on copied data), and tested for when eina_file_real_close does the unmap. I'm surprised Linux allowed this. Certainly all of the BSDs crashed with the previous behaviour.

@fix T5479

Test Plan: Example inlcude Rage and Enlightenment Thumb on BSD systems which use eina_file_virtualize with emotion to obtain album artwork.

Reviewers: raster, cedric, jpeg

Reviewed By: jpeg

Maniphest Tasks: T5479

Differential Revision: https://phab.enlightenment.org/D5006
2017-07-07 13:22:53 +09:00
Cedric BAIL b2893dfc77 eina: use new API eina_file_close_on_exec. 2017-04-18 16:54:03 -07:00
Ivan Furs 808fcf4dae eina_file: add eina_file_unlink
Test Plan: split  D4423 - unlink

Reviewers: raster, vtorri, an.kroitor, jpeg, reutskiy.v.v, NikaWhite, cedric

Reviewed By: cedric

Subscribers: artem.popov, cedric, vtorri, jpeg

Tags: #windows, #efl

Differential Revision: https://phab.enlightenment.org/D4485

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-02-07 15:14:54 -08:00
Carsten Haitzler 58d3328d80 eina - eina file map populate fallback to use log int not int... for size
this makes the size match other sizes in eina_file. doesn't affect
linux but i think bsd's get hit.
2016-09-20 21:57:47 +09:00
Cedric BAIL 25aef34aa0 eina: populate memory in the right limit. 2016-09-19 14:02:43 -07:00
Cedric BAIL 0ef07d6095 eina: readdir_r has been deprecated.
So glibc has decided that readdir_r is hard to use safely and deprecated it
this summer. They recommand to use readdir, which was in the past unsafe to
use in a multi thread scenario, but is now on most system (and all system
we care, including our own implementation in evil). It is basically safe
as long the same DIRP is not accessed from another thread. This is true in
our code base, so we are fine to go with this.

For further reading: https://lwn.net/Articles/696474/
2016-08-25 15:23:14 -07:00
Cedric BAIL 72aca66f8d eina: win32 and linux version code are the same. Sharing code is better. 2014-07-14 15:46:54 +02:00
Vincent Torri ea8b4c82ed eina: call the function, then return 2014-07-13 15:17:34 +02:00
Guillaume Friloux 619987bc2e Remove warning by adding eina_cpu.h which expose eina_cpu_page_size() 2014-05-30 10:25:05 +02:00
Cedric Bail f5f9e44219 eina: reduce log to warning when not found. 2014-02-22 16:37:15 +09:00
Cedric BAIL 58f424a199 eina: add more debug information when failing to open a file. 2014-02-21 17:13:09 +09:00
Cedric Bail 62b469749a eina: fix the crash seen by some during rebuild.
Before this patch, we were unconditionnaly destroying the Eina_File if that one
did change on disk. We also make sure that we remove the right entry from the cache
if the file did change there.
2013-11-21 14:49:08 +09:00
Cedric Bail 0cfb40b7fb eina: cleanup file destruction and reintroduce EINA_MAGIC use. 2013-11-20 20:08:44 +09:00
Jérémy Zurcher 8a3e021298 Revert "eina: fix a possible race condition during eina_file_close."
it breaks everything

This reverts commit 7e8fb93206.
2013-11-20 10:22:00 +01:00
Cedric Bail 7e8fb93206 eina: fix a possible race condition during eina_file_close.
The lock on the main hash was taken to late (after we took the decision
to remove the targeted Eina_File from the cache), this means it was possible
to get an Eina_File from the cache that was going to be removed. This patch
attempt to fix that potential race condition.

Hopefully should fix T461.
2013-11-20 13:02:37 +09:00
Cedric BAIL da559ee5d0 eina: use portable infrastructure to detect page size. 2013-11-10 09:26:12 +01:00
Cedric Bail 570ce667f3 eina: fix API as we don't and never will touch memory for write in that function. 2013-10-28 18:32:40 +09:00
Cedric Bail caf934e005 eina: don't try close dummy handle. 2013-09-02 12:33:21 +09:00
Jean-Philippe Andre deacfdce24 eina: Fix invalid check on Eina_File::global_map
global_map is set to MAP_FAILED in case of error after mmap.
So, it is initialized to MAP_FAILED and considered valid
otherwise.

So, we don't want to set the map to NULL or even check again NULL.
2013-08-27 17:31:12 +09:00
Carsten Haitzler bdb19cd974 eina-file - adapt to bsd version of MADV_REMOVE 2013-08-06 16:13:03 +09:00
Cedric Bail 4dd259f3b1 eina: add eina_file_refresh(). 2013-07-31 17:16:40 +09:00
Cedric Bail f2de8970a1 eina: add support for in memory only Eina_File. 2013-07-31 11:51:51 +09:00
Carsten Haitzler d15d86e26f eina: add eina_file_map_populate() 2013-07-06 22:01:23 +09:00
Cedric Bail 674f612c3b eina: more meaningful message. 2013-05-08 18:17:00 +09:00
Cedric BAIL 6b4ba5cead eina: a little bit sleepy, put that in the right file. 2013-03-15 16:47:05 +09:00
Cedric BAIL 352ed3cfa4 eina: add evil in. 2013-03-15 16:41:46 +09:00
Cedric BAIL 0dde9a6574 eina: share eina_file_copy code accross platform. 2013-03-15 16:05:39 +09:00
Cedric BAIL e70502f1a1 eina: improve portability of Eina_File. 2013-03-15 11:05:25 +09:00
Daniel Willmann f90726cf35 Revert "eina: improve portability of Eina_File."
This reverts commit c002d113f1.

This commit reliably breaks builds with clang. Please test with
export CC=clang before you commit again.

export CC=clang
./autogen.sh --enable-multisense && make -j 10

The error Jenkins gets (I confirmed locally):

/bin/bash: line 1: 13549 Segmentation fault      (core dumped) EFL_RUN_IN_TREE=1 ./bin/edje/edje_cc -id . -fd . -id ./tests/emotion/data tests/emotion/data/theme.edc tests/emotion/data/theme.edj
2013-03-14 17:21:48 +00:00
Cedric BAIL c002d113f1 eina: improve portability of Eina_File. 2013-03-14 20:52:37 +09:00
Cedric Bail 709b975ca3 check fchmod existence for portabilityy 2013-03-13 17:04:32 +09:00
Cedric Bail 8d5e33077e efl: use HAVE_FCNTL around call to fcntl. 2013-03-10 23:10:27 +09:00
Cedric BAIL 1cb8c3c006 efl/eina: fix map leak in Eina_File.
SVN revision: 83668
2013-02-06 09:28:00 +00:00
Gustavo Sverzut Barbieri e21bfbbbb2 eina: add missing ifdef around splice code.
SVN revision: 82735
2013-01-14 00:00:37 +00:00
Gustavo Sverzut Barbieri 0a2d116119 efl: eina_alloca.h to simplify alloca() usage.
having to replicate 18 lines per file just to access alloca() is
insane. Let's do that in Eina.h and avoid that crap :-/



SVN revision: 82082
2013-01-03 15:10:34 +00:00
Gustavo Sverzut Barbieri 43eb232d38 oops: remove printf
SVN revision: 81943
2012-12-31 23:42:25 +00:00