ran ecrustify on ecore. some manual fixing too.

SVN revision: 64238
This commit is contained in:
Carsten Haitzler 2011-10-21 05:40:39 +00:00
parent 8893a9ff35
commit 58cbf16625
24 changed files with 5756 additions and 4978 deletions

File diff suppressed because it is too large Load Diff

View File

@ -48,153 +48,155 @@
* use multiple values with the same parser.
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
ECORE_GETOPT_ACTION_STORE,
ECORE_GETOPT_ACTION_STORE_CONST,
ECORE_GETOPT_ACTION_STORE_TRUE,
ECORE_GETOPT_ACTION_STORE_FALSE,
ECORE_GETOPT_ACTION_CHOICE,
ECORE_GETOPT_ACTION_APPEND,
ECORE_GETOPT_ACTION_COUNT,
ECORE_GETOPT_ACTION_CALLBACK,
ECORE_GETOPT_ACTION_HELP,
ECORE_GETOPT_ACTION_VERSION,
ECORE_GETOPT_ACTION_COPYRIGHT,
ECORE_GETOPT_ACTION_LICENSE
} Ecore_Getopt_Action;
typedef enum {
ECORE_GETOPT_ACTION_STORE,
ECORE_GETOPT_ACTION_STORE_CONST,
ECORE_GETOPT_ACTION_STORE_TRUE,
ECORE_GETOPT_ACTION_STORE_FALSE,
ECORE_GETOPT_ACTION_CHOICE,
ECORE_GETOPT_ACTION_APPEND,
ECORE_GETOPT_ACTION_COUNT,
ECORE_GETOPT_ACTION_CALLBACK,
ECORE_GETOPT_ACTION_HELP,
ECORE_GETOPT_ACTION_VERSION,
ECORE_GETOPT_ACTION_COPYRIGHT,
ECORE_GETOPT_ACTION_LICENSE
} Ecore_Getopt_Action;
typedef enum {
ECORE_GETOPT_TYPE_STR,
ECORE_GETOPT_TYPE_BOOL,
ECORE_GETOPT_TYPE_SHORT,
ECORE_GETOPT_TYPE_INT,
ECORE_GETOPT_TYPE_LONG,
ECORE_GETOPT_TYPE_USHORT,
ECORE_GETOPT_TYPE_UINT,
ECORE_GETOPT_TYPE_ULONG,
ECORE_GETOPT_TYPE_DOUBLE
} Ecore_Getopt_Type;
typedef enum {
ECORE_GETOPT_TYPE_STR,
ECORE_GETOPT_TYPE_BOOL,
ECORE_GETOPT_TYPE_SHORT,
ECORE_GETOPT_TYPE_INT,
ECORE_GETOPT_TYPE_LONG,
ECORE_GETOPT_TYPE_USHORT,
ECORE_GETOPT_TYPE_UINT,
ECORE_GETOPT_TYPE_ULONG,
ECORE_GETOPT_TYPE_DOUBLE
} Ecore_Getopt_Type;
typedef enum {
ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO = 0,
ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES = 1,
ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL = 3
} Ecore_Getopt_Desc_Arg_Requirement;
typedef enum {
ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO = 0,
ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES = 1,
ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL = 3
} Ecore_Getopt_Desc_Arg_Requirement;
typedef union _Ecore_Getopt_Value Ecore_Getopt_Value;
typedef union _Ecore_Getopt_Value Ecore_Getopt_Value;
typedef struct _Ecore_Getopt_Desc_Store Ecore_Getopt_Desc_Store;
typedef struct _Ecore_Getopt_Desc_Callback Ecore_Getopt_Desc_Callback;
typedef struct _Ecore_Getopt_Desc Ecore_Getopt_Desc;
typedef struct _Ecore_Getopt Ecore_Getopt;
typedef struct _Ecore_Getopt_Desc_Store Ecore_Getopt_Desc_Store;
typedef struct _Ecore_Getopt_Desc_Callback Ecore_Getopt_Desc_Callback;
typedef struct _Ecore_Getopt_Desc Ecore_Getopt_Desc;
typedef struct _Ecore_Getopt Ecore_Getopt;
union _Ecore_Getopt_Value
{
char **strp;
unsigned char *boolp;
short *shortp;
int *intp;
long *longp;
unsigned short *ushortp;
unsigned int *uintp;
unsigned long *ulongp;
double *doublep;
Eina_List **listp;
void **ptrp;
};
union _Ecore_Getopt_Value
{
char **strp;
unsigned char *boolp;
short *shortp;
int *intp;
long *longp;
unsigned short *ushortp;
unsigned int *uintp;
unsigned long *ulongp;
double *doublep;
Eina_List **listp;
void **ptrp;
};
struct _Ecore_Getopt_Desc_Store
{
Ecore_Getopt_Type type; /**< type of data being handled */
Ecore_Getopt_Desc_Arg_Requirement arg_req;
union
{
const char *strv;
Eina_Bool boolv;
short shortv;
int intv;
long longv;
unsigned short ushortv;
unsigned int uintv;
unsigned long ulongv;
double doublev;
} def;
};
struct _Ecore_Getopt_Desc_Store
{
Ecore_Getopt_Type type; /**< type of data being handled */
Ecore_Getopt_Desc_Arg_Requirement arg_req;
union
{
const char *strv;
Eina_Bool boolv;
short shortv;
int intv;
long longv;
unsigned short ushortv;
unsigned int uintv;
unsigned long ulongv;
double doublev;
} def;
};
struct _Ecore_Getopt_Desc_Callback
{
Eina_Bool (*func)(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, const char *str, void *data, Ecore_Getopt_Value *storage);
const void *data;
Ecore_Getopt_Desc_Arg_Requirement arg_req;
const char *def;
};
struct _Ecore_Getopt_Desc_Callback
{
Eina_Bool (*func)(const Ecore_Getopt *parser,
const Ecore_Getopt_Desc *desc,
const char *str,
void *data,
Ecore_Getopt_Value *storage);
const void *data;
Ecore_Getopt_Desc_Arg_Requirement arg_req;
const char *def;
};
struct _Ecore_Getopt_Desc
{
char shortname; /**< used with a single dash */
const char *longname; /**< used with double dashes */
const char *help; /**< used by --help/ecore_getopt_help() */
const char *metavar; /**< used by ecore_getopt_help() with nargs > 0 */
struct _Ecore_Getopt_Desc
{
char shortname; /**< used with a single dash */
const char *longname; /**< used with double dashes */
const char *help; /**< used by --help/ecore_getopt_help() */
const char *metavar; /**< used by ecore_getopt_help() with nargs > 0 */
Ecore_Getopt_Action action; /**< define how to handle it */
union
{
const Ecore_Getopt_Desc_Store store;
const void *store_const;
const char *const *choices; /* NULL terminated. */
const Ecore_Getopt_Type append_type;
const Ecore_Getopt_Desc_Callback callback;
const void *dummy;
} action_param;
};
Ecore_Getopt_Action action; /**< define how to handle it */
union
{
const Ecore_Getopt_Desc_Store store;
const void *store_const;
const char *const *choices; /* NULL terminated. */
const Ecore_Getopt_Type append_type;
const Ecore_Getopt_Desc_Callback callback;
const void *dummy;
} action_param;
};
struct _Ecore_Getopt
{
const char *prog; /**< to be used when ecore_app_args_get() fails */
const char *usage; /**< usage example, %prog is replaced */
const char *version; /**< if exists, --version will work */
const char *copyright; /**< if exists, --copyright will work */
const char *license; /**< if exists, --license will work */
const char *description; /**< long description, possible multiline */
Eina_Bool strict : 1; /**< fail on errors */
const Ecore_Getopt_Desc descs[]; /* NULL terminated. */
};
struct _Ecore_Getopt
{
const char *prog; /**< to be used when ecore_app_args_get() fails */
const char *usage; /**< usage example, %prog is replaced */
const char *version; /**< if exists, --version will work */
const char *copyright; /**< if exists, --copyright will work */
const char *license; /**< if exists, --license will work */
const char *description; /**< long description, possible multiline */
Eina_Bool strict : 1; /**< fail on errors */
const Ecore_Getopt_Desc descs[]; /* NULL terminated. */
};
#define ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, arg_requirement, default_value) \
{shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \
{.store = {type, arg_requirement, default_value}}}
{shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \
{.store = {type, arg_requirement, default_value}}}
#define ECORE_GETOPT_STORE(shortname, longname, help, type) \
ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \
#define ECORE_GETOPT_STORE(shortname, longname, help, type) \
ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \
ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {})
#define ECORE_GETOPT_STORE_STR(shortname, longname, help) \
#define ECORE_GETOPT_STORE_STR(shortname, longname, help) \
ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_STR)
#define ECORE_GETOPT_STORE_BOOL(shortname, longname, help) \
#define ECORE_GETOPT_STORE_BOOL(shortname, longname, help) \
ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_BOOL)
#define ECORE_GETOPT_STORE_SHORT(shortname, longname, help) \
#define ECORE_GETOPT_STORE_SHORT(shortname, longname, help) \
ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_SHORT)
#define ECORE_GETOPT_STORE_INT(shortname, longname, help) \
#define ECORE_GETOPT_STORE_INT(shortname, longname, help) \
ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_INT)
#define ECORE_GETOPT_STORE_LONG(shortname, longname, help) \
#define ECORE_GETOPT_STORE_LONG(shortname, longname, help) \
ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_LONG)
#define ECORE_GETOPT_STORE_USHORT(shortname, longname, help) \
#define ECORE_GETOPT_STORE_USHORT(shortname, longname, help) \
ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_USHORT)
#define ECORE_GETOPT_STORE_UINT(shortname, longname, help) \
#define ECORE_GETOPT_STORE_UINT(shortname, longname, help) \
ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_UINT)
#define ECORE_GETOPT_STORE_ULONG(shortname, longname, help) \
#define ECORE_GETOPT_STORE_ULONG(shortname, longname, help) \
ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_ULONG)
#define ECORE_GETOPT_STORE_DOUBLE(shortname, longname, help) \
#define ECORE_GETOPT_STORE_DOUBLE(shortname, longname, help) \
ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_DOUBLE)
#define ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, type) \
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, \
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, \
ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {})
#define ECORE_GETOPT_STORE_METAVAR_STR(shortname, longname, help, metavar) \
@ -216,7 +218,6 @@ extern "C" {
#define ECORE_GETOPT_STORE_METAVAR_DOUBLE(shortname, longname, help, metavar) \
ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_DOUBLE)
#define ECORE_GETOPT_STORE_DEF(shortname, longname, help, type, default_value) \
ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \
ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL, \
@ -262,7 +263,7 @@ extern "C" {
#define ECORE_GETOPT_STORE_FULL_STR(shortname, longname, help, metavar, arg_requirement, default_value) \
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
ECORE_GETOPT_TYPE_STR, \
arg_requirement, \
arg_requirement, \
{.strv = default_value})
#define ECORE_GETOPT_STORE_FULL_BOOL(shortname, longname, help, metavar, arg_requirement, default_value) \
ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
@ -307,37 +308,36 @@ extern "C" {
#define ECORE_GETOPT_STORE_CONST(shortname, longname, help, value) \
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_CONST, \
{.store_const = value}}
{.store_const = value}}
#define ECORE_GETOPT_STORE_TRUE(shortname, longname, help) \
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_TRUE, \
{.dummy = NULL}}
{.dummy = NULL}}
#define ECORE_GETOPT_STORE_FALSE(shortname, longname, help) \
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_FALSE, \
{.dummy = NULL}}
{.dummy = NULL}}
#define ECORE_GETOPT_CHOICE(shortname, longname, help, choices_array) \
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_CHOICE, \
{.choices = choices_array}}
{.choices = choices_array}}
#define ECORE_GETOPT_CHOICE_METAVAR(shortname, longname, help, metavar, choices_array) \
{shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CHOICE, \
{.choices = choices_array}}
{.choices = choices_array}}
#define ECORE_GETOPT_APPEND(shortname, longname, help, sub_type) \
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_APPEND, \
{.append_type = sub_type}}
{.append_type = sub_type}}
#define ECORE_GETOPT_APPEND_METAVAR(shortname, longname, help, metavar, type) \
{shortname, longname, help, metavar, ECORE_GETOPT_ACTION_APPEND, \
{.append_type = type}}
{.append_type = type}}
#define ECORE_GETOPT_COUNT(shortname, longname, help) \
{shortname, longname, help, NULL, ECORE_GETOPT_ACTION_COUNT, \
{.dummy = NULL}}
{.dummy = NULL}}
#define ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, callback_func, callback_data, argument_requirement, default_value) \
{shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CALLBACK, \
{.callback = {callback_func, callback_data, \
argument_requirement, default_value}}}
{.callback = {callback_func, callback_data, \
argument_requirement, default_value}}}
#define ECORE_GETOPT_CALLBACK_NOARGS(shortname, longname, help, callback_func, callback_data) \
ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, NULL, \
callback_func, callback_data, \
@ -351,23 +351,23 @@ extern "C" {
#define ECORE_GETOPT_HELP(shortname, longname) \
{shortname, longname, "show this message.", NULL, \
ECORE_GETOPT_ACTION_HELP, \
{.dummy = NULL}}
ECORE_GETOPT_ACTION_HELP, \
{.dummy = NULL}}
#define ECORE_GETOPT_VERSION(shortname, longname) \
{shortname, longname, "show program version.", NULL, \
ECORE_GETOPT_ACTION_VERSION, \
{.dummy = NULL}}
ECORE_GETOPT_ACTION_VERSION, \
{.dummy = NULL}}
#define ECORE_GETOPT_COPYRIGHT(shortname, longname) \
{shortname, longname, "show copyright.", NULL, \
ECORE_GETOPT_ACTION_COPYRIGHT, \
{.dummy = NULL}}
ECORE_GETOPT_ACTION_COPYRIGHT, \
{.dummy = NULL}}
#define ECORE_GETOPT_LICENSE(shortname, longname) \
{shortname, longname, "show license.", NULL, \
ECORE_GETOPT_ACTION_LICENSE, \
{.dummy = NULL}}
ECORE_GETOPT_ACTION_LICENSE, \
{.dummy = NULL}}
#define ECORE_GETOPT_SENTINEL {0, NULL, NULL, NULL, 0, {.dummy = NULL}}
@ -383,19 +383,35 @@ extern "C" {
#define ECORE_GETOPT_VALUE_PTR(val) {.ptrp = &(val)}
#define ECORE_GETOPT_VALUE_PTR_CAST(val) {.ptrp = (void **)&(val)}
#define ECORE_GETOPT_VALUE_LIST(val) {.listp = &(val)}
#define ECORE_GETOPT_VALUE_NONE {.ptrp = NULL}
#define ECORE_GETOPT_VALUE_NONE {.ptrp = NULL}
EAPI void ecore_getopt_help(FILE *fp, const Ecore_Getopt *info);
EAPI void
ecore_getopt_help(FILE *fp,
const Ecore_Getopt *info);
EAPI Eina_Bool ecore_getopt_parser_has_duplicates(const Ecore_Getopt *parser);
EAPI int ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int argc, char **argv);
EAPI Eina_Bool
ecore_getopt_parser_has_duplicates(const Ecore_Getopt *parser);
EAPI int
ecore_getopt_parse(const Ecore_Getopt *parser,
Ecore_Getopt_Value *values,
int argc,
char **argv);
EAPI Eina_List *ecore_getopt_list_free(Eina_List *list);
/* helper functions to be used with ECORE_GETOPT_CALLBACK_*() */
EAPI Eina_Bool ecore_getopt_callback_geometry_parse(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, const char *str, void *data, Ecore_Getopt_Value *storage);
EAPI Eina_Bool ecore_getopt_callback_size_parse(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, const char *str, void *data, Ecore_Getopt_Value *storage);
EAPI Eina_List *ecore_getopt_list_free(Eina_List *list);
/* helper functions to be used with ECORE_GETOPT_CALLBACK_*() */
EAPI Eina_Bool
ecore_getopt_callback_geometry_parse(const Ecore_Getopt *parser,
const Ecore_Getopt_Desc *desc,
const char *str,
void *data,
Ecore_Getopt_Value *storage);
EAPI Eina_Bool
ecore_getopt_callback_size_parse(const Ecore_Getopt *parser,
const Ecore_Getopt_Desc *desc,
const char *str,
void *data,
Ecore_Getopt_Value *storage);
#ifdef __cplusplus
}

View File

@ -38,9 +38,9 @@
static Ecore_Version _version = { VERS_MAJ, VERS_MIN, VERS_MIC, VERS_REV };
EAPI Ecore_Version *ecore_version = &_version;
#define KEEP_MAX(Global, Local) \
if (Global < (Local)) \
Global = Local;
#define KEEP_MAX(Global, Local) \
if (Global < (Local)) \
Global = Local;
static Eina_Bool _ecore_memory_statistic(void *data);
static int _ecore_memory_max_total = 0;
@ -57,23 +57,25 @@ typedef struct _Ecore_Safe_Call Ecore_Safe_Call;
struct _Ecore_Safe_Call
{
union {
Ecore_Cb async;
Ecore_Cb async;
Ecore_Data_Cb sync;
} cb;
void *data;
void *data;
Eina_Lock m;
Eina_Lock m;
Eina_Condition c;
int current_id;
int current_id;
Eina_Bool sync : 1;
Eina_Bool suspend : 1;
Eina_Bool sync : 1;
Eina_Bool suspend : 1;
};
static void _ecore_main_loop_thread_safe_call(Ecore_Safe_Call *order);
static void _thread_safe_cleanup(void *data);
static void _thread_callback(void *data, void *buffer, unsigned int nbyte);
static void _thread_callback(void *data,
void *buffer,
unsigned int nbyte);
static Eina_List *_thread_cb = NULL;
static Ecore_Pipe *_thread_call = NULL;
static Eina_Lock _thread_safety;
@ -138,11 +140,11 @@ ecore_init(void)
setlocale(LC_CTYPE, "");
#endif
/*
if (strcmp(nl_langinfo(CODESET), "UTF-8"))
{
if (strcmp(nl_langinfo(CODESET), "UTF-8"))
{
WRN("Not a utf8 locale!");
}
*/
}
*/
#ifdef HAVE_EVIL
if (!evil_init())
return --_ecore_init_count;
@ -189,9 +191,9 @@ ecore_init(void)
return _ecore_init_count;
shutdown_log_dom:
shutdown_log_dom:
eina_shutdown();
shutdown_evil:
shutdown_evil:
#ifdef HAVE_EVIL
evil_shutdown();
#endif
@ -214,56 +216,56 @@ ecore_shutdown(void)
/*
* take a lock here because _ecore_event_shutdown() does callbacks
*/
_ecore_lock();
if (--_ecore_init_count != 0)
goto unlock;
_ecore_lock();
if (--_ecore_init_count != 0)
goto unlock;
ecore_pipe_del(_thread_call);
eina_lock_free(&_thread_safety);
eina_condition_free(&_thread_cond);
eina_lock_free(&_thread_mutex);
eina_condition_free(&_thread_feedback_cond);
eina_lock_free(&_thread_feedback_mutex);
eina_lock_free(&_thread_id_lock);
ecore_pipe_del(_thread_call);
eina_lock_free(&_thread_safety);
eina_condition_free(&_thread_cond);
eina_lock_free(&_thread_mutex);
eina_condition_free(&_thread_feedback_cond);
eina_lock_free(&_thread_feedback_mutex);
eina_lock_free(&_thread_id_lock);
if (_ecore_fps_debug) _ecore_fps_debug_shutdown();
_ecore_poller_shutdown();
_ecore_animator_shutdown();
_ecore_glib_shutdown();
_ecore_job_shutdown();
_ecore_thread_shutdown();
_ecore_exe_shutdown();
_ecore_idle_enterer_shutdown();
_ecore_idle_exiter_shutdown();
_ecore_idler_shutdown();
_ecore_timer_shutdown();
_ecore_event_shutdown();
_ecore_main_shutdown();
_ecore_signal_shutdown();
_ecore_main_loop_shutdown();
if (_ecore_fps_debug) _ecore_fps_debug_shutdown();
_ecore_poller_shutdown();
_ecore_animator_shutdown();
_ecore_glib_shutdown();
_ecore_job_shutdown();
_ecore_thread_shutdown();
_ecore_exe_shutdown();
_ecore_idle_enterer_shutdown();
_ecore_idle_exiter_shutdown();
_ecore_idler_shutdown();
_ecore_timer_shutdown();
_ecore_event_shutdown();
_ecore_main_shutdown();
_ecore_signal_shutdown();
_ecore_main_loop_shutdown();
#if HAVE_MALLINFO
if (getenv("ECORE_MEM_STAT"))
{
_ecore_memory_statistic(NULL);
if (getenv("ECORE_MEM_STAT"))
{
_ecore_memory_statistic(NULL);
ERR("[%i] Memory MAX total: %i, free: %i",
_ecore_memory_pid,
_ecore_memory_max_total,
_ecore_memory_max_free);
}
ERR("[%i] Memory MAX total: %i, free: %i",
_ecore_memory_pid,
_ecore_memory_max_total,
_ecore_memory_max_free);
}
#endif
eina_log_domain_unregister(_ecore_log_dom);
_ecore_log_dom = -1;
eina_shutdown();
eina_log_domain_unregister(_ecore_log_dom);
_ecore_log_dom = -1;
eina_shutdown();
#ifdef HAVE_EVIL
evil_shutdown();
evil_shutdown();
#endif
unlock:
_ecore_unlock();
_ecore_unlock();
return _ecore_init_count;
return _ecore_init_count;
}
/**
@ -273,20 +275,21 @@ unlock:
static int wakeup = 42;
EAPI void
ecore_main_loop_thread_safe_call_async(Ecore_Cb callback, void *data)
ecore_main_loop_thread_safe_call_async(Ecore_Cb callback,
void *data)
{
Ecore_Safe_Call *order;
if (!callback) return ;
if (!callback) return;
if (eina_main_loop_is())
{
callback(data);
return ;
return;
}
order = malloc(sizeof (Ecore_Safe_Call));
if (!order) return ;
if (!order) return;
order->cb.async = callback;
order->data = data;
@ -297,7 +300,8 @@ ecore_main_loop_thread_safe_call_async(Ecore_Cb callback, void *data)
}
EAPI void *
ecore_main_loop_thread_safe_call_sync(Ecore_Data_Cb callback, void *data)
ecore_main_loop_thread_safe_call_sync(Ecore_Data_Cb callback,
void *data)
{
Ecore_Safe_Call *order;
void *ret;
@ -354,7 +358,7 @@ ecore_thread_main_loop_begin(void)
if (order->current_id < 0)
{
_thread_id_max = 0;
order->current_id = ++_thread_id_max;
order->current_id = ++_thread_id_max;
}
eina_lock_release(&_thread_id_lock);
@ -414,7 +418,8 @@ ecore_thread_main_loop_end(void)
}
EAPI void
ecore_print_warning(const char *function, const char *sparam)
ecore_print_warning(const char *function,
const char *sparam)
{
WRN("***** Developer Warning ***** :\n"
"\tThis program is calling:\n\n"
@ -426,7 +431,10 @@ ecore_print_warning(const char *function, const char *sparam)
}
EAPI void
_ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *fname)
_ecore_magic_fail(const void *d,
Ecore_Magic m,
Ecore_Magic req_m,
const char *fname)
{
ERR("\n"
"*** ECORE ERROR: Ecore Magic Check Failed!!!\n"
@ -441,9 +449,9 @@ _ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *f
" Supplied: %08x - %s",
(unsigned int)req_m, _ecore_magic_string_get(req_m),
(unsigned int)m, _ecore_magic_string_get(m));
ERR("*** NAUGHTY PROGRAMMER!!!\n"
"*** SPANK SPANK SPANK!!!\n"
"*** Now go fix your code. Tut tut tut!");
ERR("*** NAUGHTY PROGRAMMER!!!\n"
"*** SPANK SPANK SPANK!!!\n"
"*** Now go fix your code. Tut tut tut!");
if (getenv("ECORE_ERROR_ABORT")) abort();
}
@ -455,36 +463,46 @@ _ecore_magic_string_get(Ecore_Magic m)
case ECORE_MAGIC_NONE:
return "None (Freed Object)";
break;
case ECORE_MAGIC_EXE:
return "Ecore_Exe (Executable)";
break;
case ECORE_MAGIC_TIMER:
return "Ecore_Timer (Timer)";
break;
case ECORE_MAGIC_IDLER:
return "Ecore_Idler (Idler)";
break;
case ECORE_MAGIC_IDLE_ENTERER:
return "Ecore_Idle_Enterer (Idler Enterer)";
break;
case ECORE_MAGIC_IDLE_EXITER:
return "Ecore_Idle_Exiter (Idler Exiter)";
break;
case ECORE_MAGIC_FD_HANDLER:
return "Ecore_Fd_Handler (Fd Handler)";
break;
case ECORE_MAGIC_WIN32_HANDLER:
return "Ecore_Win32_Handler (Win32 Handler)";
break;
case ECORE_MAGIC_EVENT_HANDLER:
return "Ecore_Event_Handler (Event Handler)";
break;
case ECORE_MAGIC_EVENT:
return "Ecore_Event (Event)";
break;
default:
return "<UNKNOWN>";
};
}
}
/* fps debug calls - for debugging how much time your app actually spends */
@ -498,9 +516,9 @@ unsigned int *_ecore_fps_runtime_mmap = NULL;
void
_ecore_fps_debug_init(void)
{
char buf[PATH_MAX];
char buf[PATH_MAX];
const char *tmp;
int pid;
int pid;
_ecore_fps_debug_init_count++;
if (_ecore_fps_debug_init_count > 1) return;
@ -561,14 +579,14 @@ _ecore_fps_debug_shutdown(void)
{
char buf[4096];
const char *tmp;
int pid;
int pid;
#ifndef HAVE_EVIL
tmp = "/tmp";
tmp = "/tmp";
#else
tmp = (char *)evil_tmpdir_get ();
tmp = (char *)evil_tmpdir_get ();
#endif /* HAVE_EVIL */
pid = (int)getpid();
pid = (int)getpid();
snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid);
unlink(buf);
if (_ecore_fps_runtime_mmap)
@ -611,12 +629,12 @@ _ecore_memory_statistic(__UNUSED__ void *data)
mi = mallinfo();
#define HAS_CHANGED(Global, Local) \
if (Global != Local) \
{ \
Global = Local; \
changed = EINA_TRUE; \
}
#define HAS_CHANGED(Global, Local) \
if (Global != Local) \
{ \
Global = Local; \
changed = EINA_TRUE; \
}
HAS_CHANGED(uordblks, mi.uordblks);
HAS_CHANGED(fordblks, mi.fordblks);
@ -659,8 +677,8 @@ _thread_safe_cleanup(void *data)
}
static void
_thread_callback(void *data __UNUSED__,
void *buffer __UNUSED__,
_thread_callback(void *data __UNUSED__,
void *buffer __UNUSED__,
unsigned int nbyte __UNUSED__)
{
Ecore_Safe_Call *call;
@ -677,23 +695,23 @@ _thread_callback(void *data __UNUSED__,
{
eina_lock_take(&_thread_mutex);
eina_lock_take(&call->m);
_thread_id = call->current_id;
eina_lock_take(&call->m);
_thread_id = call->current_id;
eina_condition_broadcast(&call->c);
eina_lock_release(&call->m);
eina_lock_release(&call->m);
while (_thread_id_update != _thread_id)
eina_condition_wait(&_thread_cond);
while (_thread_id_update != _thread_id)
eina_condition_wait(&_thread_cond);
eina_lock_release(&_thread_mutex);
eina_main_loop_define();
eina_lock_take(&_thread_feedback_mutex);
eina_lock_take(&_thread_feedback_mutex);
_thread_id = -1;
_thread_id = -1;
eina_condition_broadcast(&_thread_feedback_cond);
eina_lock_release(&_thread_feedback_mutex);
eina_condition_broadcast(&_thread_feedback_cond);
eina_lock_release(&_thread_feedback_mutex);
_thread_safe_cleanup(call);
free(call);
@ -710,3 +728,4 @@ _thread_callback(void *data __UNUSED__,
}
}
}

View File

@ -8,38 +8,36 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Animator
{
EINA_INLIST;
ECORE_MAGIC;
ECORE_MAGIC;
Ecore_Task_Cb func;
void *data;
Ecore_Task_Cb func;
void *data;
double start, run;
Ecore_Timeline_Cb run_func;
void *run_data;
double start, run;
Ecore_Timeline_Cb run_func;
void *run_data;
Eina_Bool delete_me : 1;
Eina_Bool suspended : 1;
Eina_Bool delete_me : 1;
Eina_Bool suspended : 1;
};
static Eina_Bool _ecore_animator_run(void *data);
static Eina_Bool _ecore_animator(void *data);
static int animators_delete_me = 0;
static Ecore_Animator *animators = NULL;
static double animators_frametime = 1.0 / 30.0;
static int animators_delete_me = 0;
static Ecore_Animator *animators = NULL;
static double animators_frametime = 1.0 / 30.0;
static Ecore_Animator_Source src = ECORE_ANIMATOR_SOURCE_TIMER;
static Ecore_Timer *timer = NULL;
static int ticking = 0;
static Ecore_Cb begin_tick_cb = NULL;
static const void *begin_tick_data = NULL;
static Ecore_Cb end_tick_cb = NULL;
static const void *end_tick_data = NULL;
static Ecore_Animator_Source src = ECORE_ANIMATOR_SOURCE_TIMER;
static Ecore_Timer *timer = NULL;
static int ticking = 0;
static Ecore_Cb begin_tick_cb = NULL;
static const void *begin_tick_data = NULL;
static Ecore_Cb end_tick_cb = NULL;
static const void *end_tick_data = NULL;
static void
_begin_tick(void)
@ -56,13 +54,15 @@ _begin_tick(void)
double d = -fmod(t_loop - sync_0, animators_frametime);
timer = _ecore_timer_loop_add(animators_frametime,
_ecore_animator, NULL);
_ecore_animator, NULL);
_ecore_timer_delay(timer, d);
}
break;
case ECORE_ANIMATOR_SOURCE_CUSTOM:
if (begin_tick_cb) begin_tick_cb((void *)begin_tick_data);
break;
default:
break;
}
@ -82,9 +82,11 @@ _end_tick(void)
timer = NULL;
}
break;
case ECORE_ANIMATOR_SOURCE_CUSTOM:
if (end_tick_cb) end_tick_cb((void *)end_tick_data);
break;
default:
break;
}
@ -109,15 +111,15 @@ _do_tick(void)
if (animators_delete_me)
{
Ecore_Animator *l;
for (l = animators; l;)
for (l = animators; l; )
{
animator = l;
l = (Ecore_Animator *) EINA_INLIST_GET(l)->next;
l = (Ecore_Animator *)EINA_INLIST_GET(l)->next;
if (animator->delete_me)
{
animators = (Ecore_Animator *)
eina_inlist_remove(EINA_INLIST_GET(animators),
EINA_INLIST_GET(animator));
eina_inlist_remove(EINA_INLIST_GET(animators),
EINA_INLIST_GET(animator));
ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE);
free(animator);
animators_delete_me--;
@ -134,7 +136,8 @@ _do_tick(void)
}
static Ecore_Animator *
_ecore_animator_add(Ecore_Task_Cb func, const void *data)
_ecore_animator_add(Ecore_Task_Cb func,
const void *data)
{
Ecore_Animator *animator = NULL;
@ -150,7 +153,8 @@ _ecore_animator_add(Ecore_Task_Cb func, const void *data)
}
EAPI Ecore_Animator *
ecore_animator_add(Ecore_Task_Cb func, const void *data)
ecore_animator_add(Ecore_Task_Cb func,
const void *data)
{
Ecore_Animator *animator;
@ -162,7 +166,9 @@ ecore_animator_add(Ecore_Task_Cb func, const void *data)
}
EAPI Ecore_Animator *
ecore_animator_timeline_add(double runtime, Ecore_Timeline_Cb func, const void *data)
ecore_animator_timeline_add(double runtime,
Ecore_Timeline_Cb func,
const void *data)
{
Ecore_Animator *animator;
@ -191,7 +197,8 @@ _pos_map_cos(double in)
}
static double
_pos_map_accel_factor(double pos, double v1)
_pos_map_accel_factor(double pos,
double v1)
{
int i, fact = (int)v1;
double p, o1 = pos, o2 = pos, v;
@ -208,7 +215,9 @@ _pos_map_accel_factor(double pos, double v1)
}
static double
_pos_map_pow(double pos, double divis, int p)
_pos_map_pow(double pos,
double divis,
int p)
{
double v = 1.0;
int i;
@ -217,7 +226,9 @@ _pos_map_pow(double pos, double divis, int p)
}
static double
_pos_map_spring(double pos, int bounces, double decfac)
_pos_map_spring(double pos,
int bounces,
double decfac)
{
int segnum, segpos, b1, b2;
double len, decay, decpos, p2;
@ -235,49 +246,63 @@ _pos_map_spring(double pos, int bounces, double decfac)
}
EAPI double
ecore_animator_pos_map(double pos, Ecore_Pos_Map map, double v1, double v2)
ecore_animator_pos_map(double pos,
Ecore_Pos_Map map,
double v1,
double v2)
{
/* purely functional - locking not required */
if (pos > 1.0) pos = 1.0;
else if (pos < 0.0) pos = 0.0;
switch (map)
{
case ECORE_POS_MAP_LINEAR:
return pos;
case ECORE_POS_MAP_ACCELERATE:
pos = 1.0 - _pos_map_sin((M_PI / 2.0) + ((pos * M_PI) / 2.0));
return pos;
case ECORE_POS_MAP_DECELERATE:
pos = _pos_map_sin((pos * M_PI) / 2.0);
return pos;
case ECORE_POS_MAP_SINUSOIDAL:
pos = (1.0 - _pos_map_cos(pos * M_PI)) / 2.0;
return pos;
case ECORE_POS_MAP_ACCELERATE_FACTOR:
pos = _pos_map_accel_factor(pos, v1);
return pos;
case ECORE_POS_MAP_DECELERATE_FACTOR:
pos = 1.0 - _pos_map_accel_factor(1.0 - pos, v1);
return pos;
case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
if (pos < 0.5) pos = _pos_map_accel_factor(pos * 2.0, v1) / 2.0;
else pos = 1.0 - (_pos_map_accel_factor((1.0 - pos) * 2.0, v1) / 2.0);
return pos;
case ECORE_POS_MAP_DIVISOR_INTERP:
pos = _pos_map_pow(pos, v1, (int)v2);
return pos;
case ECORE_POS_MAP_BOUNCE:
pos = _pos_map_spring(pos, (int)v2, v1);
if (pos < 0.0) pos = -pos;
pos = 1.0 - pos;
return pos;
case ECORE_POS_MAP_SPRING:
pos = 1.0 - _pos_map_spring(pos, (int)v2, v1);
return pos;
default:
return pos;
}
return pos;
if (pos > 1.0) pos = 1.0;
else if (pos < 0.0)
pos = 0.0;
switch (map)
{
case ECORE_POS_MAP_LINEAR:
return pos;
case ECORE_POS_MAP_ACCELERATE:
pos = 1.0 - _pos_map_sin((M_PI / 2.0) + ((pos * M_PI) / 2.0));
return pos;
case ECORE_POS_MAP_DECELERATE:
pos = _pos_map_sin((pos * M_PI) / 2.0);
return pos;
case ECORE_POS_MAP_SINUSOIDAL:
pos = (1.0 - _pos_map_cos(pos * M_PI)) / 2.0;
return pos;
case ECORE_POS_MAP_ACCELERATE_FACTOR:
pos = _pos_map_accel_factor(pos, v1);
return pos;
case ECORE_POS_MAP_DECELERATE_FACTOR:
pos = 1.0 - _pos_map_accel_factor(1.0 - pos, v1);
return pos;
case ECORE_POS_MAP_SINUSOIDAL_FACTOR:
if (pos < 0.5) pos = _pos_map_accel_factor(pos * 2.0, v1) / 2.0;
else pos = 1.0 - (_pos_map_accel_factor((1.0 - pos) * 2.0, v1) / 2.0);
return pos;
case ECORE_POS_MAP_DIVISOR_INTERP:
pos = _pos_map_pow(pos, v1, (int)v2);
return pos;
case ECORE_POS_MAP_BOUNCE:
pos = _pos_map_spring(pos, (int)v2, v1);
if (pos < 0.0) pos = -pos;
pos = 1.0 - pos;
return pos;
case ECORE_POS_MAP_SPRING:
pos = 1.0 - _pos_map_spring(pos, (int)v2, v1);
return pos;
default:
return pos;
}
return pos;
}
EAPI void *
@ -376,7 +401,8 @@ ecore_animator_source_get(void)
}
EAPI void
ecore_animator_custom_source_tick_begin_callback_set(Ecore_Cb func, const void *data)
ecore_animator_custom_source_tick_begin_callback_set(Ecore_Cb func,
const void *data)
{
_ecore_lock();
begin_tick_cb = func;
@ -387,7 +413,8 @@ ecore_animator_custom_source_tick_begin_callback_set(Ecore_Cb func, const void *
}
EAPI void
ecore_animator_custom_source_tick_end_callback_set(Ecore_Cb func, const void *data)
ecore_animator_custom_source_tick_end_callback_set(Ecore_Cb func,
const void *data)
{
_ecore_lock();
end_tick_cb = func;
@ -414,7 +441,7 @@ _ecore_animator_shutdown(void)
Ecore_Animator *animator;
animator = animators;
animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators));
animators = (Ecore_Animator *)eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators));
ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE);
free(animator);
}
@ -432,7 +459,8 @@ _ecore_animator_run(void *data)
{
pos = (t - animator->start) / animator->run;
if (pos > 1.0) pos = 1.0;
else if (pos < 0.0) pos = 0.0;
else if (pos < 0.0)
pos = 0.0;
}
run_ret = animator->run_func(animator->run_data, pos);
if (t >= (animator->start + animator->run)) run_ret = EINA_FALSE;
@ -448,3 +476,4 @@ _ecore_animator(void *data __UNUSED__)
_ecore_unlock();
return r;
}

View File

@ -35,7 +35,8 @@ static char **app_argv = NULL;
* for later use by ecore_app_restart() or ecore_app_args_get().
*/
EAPI void
ecore_app_args_set(int argc, const char **argv)
ecore_app_args_set(int argc,
const char **argv)
{
EINA_MAIN_LOOP_CHECK_RETURN;
@ -57,7 +58,8 @@ ecore_app_args_set(int argc, const char **argv)
* same set by ecore_app_args_set().
*/
EAPI void
ecore_app_args_get(int *argc, char ***argv)
ecore_app_args_get(int *argc,
char ***argv)
{
EINA_MAIN_LOOP_CHECK_RETURN;

View File

@ -12,40 +12,39 @@ static int inpurge = 0;
struct _Ecore_Event_Handler
{
EINA_INLIST;
ECORE_MAGIC;
int type;
ECORE_MAGIC;
int type;
Ecore_Event_Handler_Cb func;
void *data;
int references;
Eina_Bool delete_me : 1;
void *data;
int references;
Eina_Bool delete_me : 1;
};
struct _Ecore_Event_Filter
{
EINA_INLIST;
ECORE_MAGIC;
Ecore_Data_Cb func_start;
ECORE_MAGIC;
Ecore_Data_Cb func_start;
Ecore_Filter_Cb func_filter;
Ecore_End_Cb func_end;
void *loop_data;
void *data;
int references;
Eina_Bool delete_me : 1;
Ecore_End_Cb func_end;
void *loop_data;
void *data;
int references;
Eina_Bool delete_me : 1;
};
struct _Ecore_Event
{
EINA_INLIST;
ECORE_MAGIC;
int type;
void *event;
ECORE_MAGIC;
int type;
void *event;
Ecore_End_Cb func_free;
void *data;
int references;
Eina_Bool delete_me : 1;
void *data;
int references;
Eina_Bool delete_me : 1;
};
static int events_num = 0;
static Ecore_Event *events = NULL;
static Ecore_Event *event_current = NULL;
@ -65,13 +64,11 @@ static Ecore_Event *event_filter_event_current = NULL;
static int event_filters_delete_me = 0;
static int event_id_max = ECORE_EVENT_COUNT;
static int ecore_raw_event_type = ECORE_EVENT_NONE;
static void *ecore_raw_event_event = NULL;
static void *ecore_raw_event_event = NULL;
static void _ecore_event_purge_deleted(void);
static void _ecore_event_purge_deleted(void);
static void *_ecore_event_del(Ecore_Event *event);
/**
* @addtogroup Ecore_Event_Group
*
@ -102,7 +99,9 @@ static void *_ecore_event_del(Ecore_Event *event);
* been called, will not be.
*/
EAPI Ecore_Event_Handler *
ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data)
ecore_event_handler_add(int type,
Ecore_Event_Handler_Cb func,
const void *data)
{
Ecore_Event_Handler *eh = NULL;
@ -213,7 +212,8 @@ unlock:
* which was previously associated with @p eh by ecore_event_handler_add().
*/
EAPI void *
ecore_event_handler_data_set(Ecore_Event_Handler *eh, const void *data)
ecore_event_handler_data_set(Ecore_Event_Handler *eh,
const void *data)
{
void *old = NULL;
@ -232,7 +232,8 @@ unlock:
}
static void
_ecore_event_generic_free (void *data __UNUSED__, void *event)
_ecore_event_generic_free(void *data __UNUSED__,
void *event)
{
free (event);
}
@ -256,7 +257,10 @@ _ecore_event_generic_free (void *data __UNUSED__, void *event)
* func_free is passed @p data as its data parameter.
*/
EAPI Ecore_Event *
ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data)
ecore_event_add(int type,
void *ev,
Ecore_End_Cb func_free,
void *data)
{
Ecore_Event *event = NULL;
@ -345,7 +349,10 @@ ecore_event_type_new(void)
* and @p data pointer to clean up.
*/
EAPI Ecore_Event_Filter *
ecore_event_filter_add(Ecore_Data_Cb func_start, Ecore_Filter_Cb func_filter, Ecore_End_Cb func_end, const void *data)
ecore_event_filter_add(Ecore_Data_Cb func_start,
Ecore_Filter_Cb func_filter,
Ecore_End_Cb func_end,
const void *data)
{
Ecore_Event_Filter *ef = NULL;
@ -358,7 +365,7 @@ ecore_event_filter_add(Ecore_Data_Cb func_start, Ecore_Filter_Cb func_filter, Ec
ef->func_filter = func_filter;
ef->func_end = func_end;
ef->data = (void *)data;
event_filters = (Ecore_Event_Filter *) eina_inlist_append(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef));
event_filters = (Ecore_Event_Filter *)eina_inlist_append(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef));
unlock:
_ecore_unlock();
return ef;
@ -460,7 +467,7 @@ _ecore_event_shutdown(void)
{
while ((eh = event_handlers[i]))
{
event_handlers[i] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[i]), EINA_INLIST_GET(event_handlers[i]));
event_handlers[i] = (Ecore_Event_Handler *)eina_inlist_remove(EINA_INLIST_GET(event_handlers[i]), EINA_INLIST_GET(event_handlers[i]));
ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
if (!eh->delete_me) free(eh);
}
@ -473,7 +480,7 @@ _ecore_event_shutdown(void)
event_handlers_alloc_num = 0;
while ((ef = event_filters))
{
event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(event_filters));
event_filters = (Ecore_Event_Filter *)eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(event_filters));
ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
free(ef);
}
@ -492,7 +499,10 @@ _ecore_event_exist(void)
}
Ecore_Event *
_ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data)
_ecore_event_add(int type,
void *ev,
Ecore_End_Cb func_free,
void *data)
{
Ecore_Event *e;
@ -523,7 +533,7 @@ _ecore_event_del(Ecore_Event *event)
data = event->data;
if (event->func_free) _ecore_call_end_cb(event->func_free, event->data, event->event);
events = (Ecore_Event *) eina_inlist_remove(EINA_INLIST_GET(events), EINA_INLIST_GET(event));
events = (Ecore_Event *)eina_inlist_remove(EINA_INLIST_GET(events), EINA_INLIST_GET(event));
ECORE_MAGIC_SET(event, ECORE_MAGIC_NONE);
free(event);
events_num--;
@ -555,16 +565,15 @@ _ecore_event_purge_deleted(void)
static inline void
_ecore_event_filters_apply()
{
if (!event_filter_current)
{
/* regular main loop, start from head */
event_filter_current = event_filters;
event_filter_current = event_filters;
}
else
{
/* recursive main loop, continue from where we were */
event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next;
event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next;
}
while (event_filter_current)
@ -580,13 +589,13 @@ _ecore_event_filters_apply()
if (!event_filter_event_current)
{
/* regular main loop, start from head */
event_filter_event_current = events;
/* regular main loop, start from head */
event_filter_event_current = events;
}
else
{
/* recursive main loop, continue from where we were */
event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next;
/* recursive main loop, continue from where we were */
event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next;
}
while (event_filter_event_current)
@ -594,7 +603,7 @@ _ecore_event_filters_apply()
Ecore_Event *e = event_filter_event_current;
if (!_ecore_call_filter_cb(ef->func_filter, ef->data,
ef->loop_data, e->type, e->event))
ef->loop_data, e->type, e->event))
{
ecore_event_del(e);
}
@ -615,10 +624,10 @@ _ecore_event_filters_apply()
{
int deleted_in_use = 0;
Ecore_Event_Filter *l;
for (l = event_filters; l;)
for (l = event_filters; l; )
{
Ecore_Event_Filter *ef = l;
l = (Ecore_Event_Filter *) EINA_INLIST_GET(l)->next;
l = (Ecore_Event_Filter *)EINA_INLIST_GET(l)->next;
if (ef->delete_me)
{
if (ef->references)
@ -627,7 +636,7 @@ _ecore_event_filters_apply()
continue;
}
event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef));
event_filters = (Ecore_Event_Filter *)eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef));
ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
free(ef);
}
@ -636,6 +645,7 @@ _ecore_event_filters_apply()
event_filters_delete_me = 0;
}
}
void
_ecore_event_call(void)
{
@ -647,8 +657,8 @@ _ecore_event_call(void)
if (!event_current)
{
/* regular main loop, start from head */
event_current = events;
event_handler_current = NULL;
event_current = events;
event_handler_current = NULL;
}
while (event_current)
@ -669,13 +679,13 @@ _ecore_event_call(void)
{
if (!event_handler_current)
{
/* regular main loop, start from head */
event_handler_current = event_handlers[e->type];
/* regular main loop, start from head */
event_handler_current = event_handlers[e->type];
}
else
{
/* recursive main loop, continue from where we were */
event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next;
/* recursive main loop, continue from where we were */
event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next;
}
while ((event_handler_current) && (!e->delete_me))
@ -730,7 +740,7 @@ _ecore_event_call(void)
event_handlers_delete_list = eina_list_remove_list(event_handlers_delete_list, l);
event_handlers[eh->type] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[eh->type]), EINA_INLIST_GET(eh));
event_handlers[eh->type] = (Ecore_Event_Handler *)eina_inlist_remove(EINA_INLIST_GET(event_handlers[eh->type]), EINA_INLIST_GET(eh));
ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
free(eh);
}
@ -777,3 +787,4 @@ _ecore_event_signal_realtime_new(void)
{
return calloc(1, sizeof(Ecore_Event_Signal_Realtime));
}

File diff suppressed because it is too large Load Diff

View File

@ -26,54 +26,54 @@
typedef enum
{
ECORE_EXE_WIN32_SIGINT,
ECORE_EXE_WIN32_SIGQUIT,
ECORE_EXE_WIN32_SIGTERM,
ECORE_EXE_WIN32_SIGKILL
ECORE_EXE_WIN32_SIGINT,
ECORE_EXE_WIN32_SIGQUIT,
ECORE_EXE_WIN32_SIGTERM,
ECORE_EXE_WIN32_SIGKILL
} Ecore_Exe_Win32_Signal;
struct _Ecore_Exe
{
EINA_INLIST;
ECORE_MAGIC;
ECORE_MAGIC;
HANDLE process2;
HANDLE process; /* CloseHandle */
HANDLE process_thread;
DWORD process_id;
DWORD thread_id;
void *data;
char *tag;
char *cmd;
Ecore_Exe_Flags flags;
HANDLE process2;
HANDLE process; /* CloseHandle */
HANDLE process_thread;
DWORD process_id;
DWORD thread_id;
void *data;
char *tag;
char *cmd;
Ecore_Exe_Flags flags;
Ecore_Exe_Win32_Signal sig;
Ecore_Win32_Handler *h_close;
Ecore_Win32_Handler *h_close;
struct
{
HANDLE child_pipe;
HANDLE child_pipe_x;
HANDLE child_pipe;
HANDLE child_pipe_x;
Ecore_Pipe *p;
HANDLE thread;
void *data_buf;
int data_size;
HANDLE thread;
void *data_buf;
int data_size;
} pipe_read;
struct
{
HANDLE child_pipe;
HANDLE child_pipe_x;
HANDLE thread;
HANDLE child_pipe;
HANDLE child_pipe_x;
HANDLE thread;
Ecore_Win32_Handler *h;
void *data_buf;
int data_size;
void *data_buf;
int data_size;
} pipe_write;
struct
{
HANDLE child_pipe;
HANDLE child_pipe_x;
HANDLE child_pipe;
HANDLE child_pipe_x;
Ecore_Pipe *p;
HANDLE thread;
void *data_buf;
int data_size;
HANDLE thread;
void *data_buf;
int data_size;
} pipe_error;
Eina_Bool close_stdin : 1;
Eina_Bool is_suspended : 1;
@ -86,18 +86,28 @@ static Ecore_Exe *exes = NULL;
static int _ecore_exe_win32_pipes_set(Ecore_Exe *exe);
static void _ecore_exe_win32_pipes_close(Ecore_Exe *exe);
static BOOL CALLBACK _ecore_exe_enum_windows_procedure(HWND window, LPARAM data);
static void _ecore_exe_event_add_free(void *data, void *ev);
static void _ecore_exe_event_del_free(void *data, void *ev);
static BOOL CALLBACK _ecore_exe_enum_windows_procedure(HWND window,
LPARAM data);
static void _ecore_exe_event_add_free(void *data,
void *ev);
static void _ecore_exe_event_del_free(void *data,
void *ev);
static void _ecore_exe_event_exe_data_free(void *data,
void *ev);
static int _ecore_exe_win32_pipe_thread_generic_cb(void *data, Ecore_Exe_Flags flags);
static int _ecore_exe_win32_pipe_thread_generic_cb(void *data,
Ecore_Exe_Flags flags);
static DWORD WINAPI _ecore_exe_win32_pipe_thread_read_cb(void *data);
static DWORD WINAPI _ecore_exe_win32_pipe_thread_error_cb(void *data);
static Eina_Bool _ecore_exe_close_cb(void *data, Ecore_Win32_Handler *wh);
static void _ecore_exe_pipe_read_cb(void *data, void *buf, unsigned int size);
static int _ecore_exe_pipe_write_cb(void *data, Ecore_Win32_Handler *wh);
static void _ecore_exe_pipe_error_cb(void *data, void *buf, unsigned int size);
static Eina_Bool _ecore_exe_close_cb(void *data,
Ecore_Win32_Handler *wh);
static void _ecore_exe_pipe_read_cb(void *data,
void *buf,
unsigned int size);
static int _ecore_exe_pipe_write_cb(void *data,
Ecore_Win32_Handler *wh);
static void _ecore_exe_pipe_error_cb(void *data,
void *buf,
unsigned int size);
EAPI int ECORE_EXE_EVENT_ADD = 0;
EAPI int ECORE_EXE_EVENT_DEL = 0;
@ -117,7 +127,7 @@ void
_ecore_exe_shutdown(void)
{
while (exes)
ecore_exe_free(exes);
ecore_exe_free(exes);
}
static int run_pri = NORMAL_PRIORITY_CLASS;
@ -127,26 +137,32 @@ ecore_exe_run_priority_set(int pri)
{
switch (pri)
{
case ECORE_EXE_WIN32_PRIORITY_IDLE:
run_pri = IDLE_PRIORITY_CLASS;
break;
case ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL:
run_pri = BELOW_NORMAL_PRIORITY_CLASS;
break;
case ECORE_EXE_WIN32_PRIORITY_NORMAL:
run_pri = NORMAL_PRIORITY_CLASS;
break;
case ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL:
run_pri = ABOVE_NORMAL_PRIORITY_CLASS;
break;
case ECORE_EXE_WIN32_PRIORITY_HIGH:
run_pri = HIGH_PRIORITY_CLASS;
break;
case ECORE_EXE_WIN32_PRIORITY_REALTIME:
run_pri = REALTIME_PRIORITY_CLASS;
break;
default:
break;
case ECORE_EXE_WIN32_PRIORITY_IDLE:
run_pri = IDLE_PRIORITY_CLASS;
break;
case ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL:
run_pri = BELOW_NORMAL_PRIORITY_CLASS;
break;
case ECORE_EXE_WIN32_PRIORITY_NORMAL:
run_pri = NORMAL_PRIORITY_CLASS;
break;
case ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL:
run_pri = ABOVE_NORMAL_PRIORITY_CLASS;
break;
case ECORE_EXE_WIN32_PRIORITY_HIGH:
run_pri = HIGH_PRIORITY_CLASS;
break;
case ECORE_EXE_WIN32_PRIORITY_REALTIME:
run_pri = REALTIME_PRIORITY_CLASS;
break;
default:
break;
}
}
@ -155,38 +171,47 @@ ecore_exe_run_priority_get(void)
{
switch (run_pri)
{
case IDLE_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_IDLE;
case BELOW_NORMAL_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL;
case NORMAL_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_NORMAL;
case ABOVE_NORMAL_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL;
case HIGH_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_HIGH;
case REALTIME_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_REALTIME;
/* default should not be reached */
default:
return ECORE_EXE_WIN32_PRIORITY_NORMAL;
case IDLE_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_IDLE;
case BELOW_NORMAL_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL;
case NORMAL_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_NORMAL;
case ABOVE_NORMAL_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL;
case HIGH_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_HIGH;
case REALTIME_PRIORITY_CLASS:
return ECORE_EXE_WIN32_PRIORITY_REALTIME;
/* default should not be reached */
default:
return ECORE_EXE_WIN32_PRIORITY_NORMAL;
}
}
EAPI Ecore_Exe *
ecore_exe_run(const char *exe_cmd, const void *data)
ecore_exe_run(const char *exe_cmd,
const void *data)
{
return ecore_exe_pipe_run(exe_cmd, 0, data);
}
EAPI Ecore_Exe *
ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data)
ecore_exe_pipe_run(const char *exe_cmd,
Ecore_Exe_Flags flags,
const void *data)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
STARTUPINFO si;
PROCESS_INFORMATION pi;
Ecore_Exe_Event_Add *e;
Ecore_Exe *exe;
char *ret = NULL;
Ecore_Exe *exe;
char *ret = NULL;
exe = calloc(1, sizeof(Ecore_Exe));
if (!exe)
@ -271,24 +296,25 @@ ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data)
return exe;
delete_h_close:
delete_h_close:
ecore_main_win32_handler_del(exe->h_close);
close_process2:
close_process2:
CloseHandle(exe->process2);
close_thread:
close_thread:
CloseHandle(exe->process_thread);
CloseHandle(exe->process);
free_exe_cmd:
free_exe_cmd:
free(exe->cmd);
close_pipes:
close_pipes:
_ecore_exe_win32_pipes_close(exe);
free_exe:
free_exe:
free(exe);
return NULL;
}
EAPI void
ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func)
ecore_exe_callback_pre_free_set(Ecore_Exe *exe,
Ecore_Exe_Cb func)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
@ -300,7 +326,9 @@ ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func)
}
EAPI Eina_Bool
ecore_exe_send(Ecore_Exe *exe, const void *data, int size)
ecore_exe_send(Ecore_Exe *exe,
const void *data,
int size)
{
void *buf;
@ -350,16 +378,21 @@ ecore_exe_close_stdin(Ecore_Exe *exe)
/* Not used on Windows */
EAPI void
ecore_exe_auto_limits_set(Ecore_Exe *exe __UNUSED__, int start_bytes __UNUSED__, int end_bytes __UNUSED__, int start_lines __UNUSED__, int end_lines __UNUSED__)
ecore_exe_auto_limits_set(Ecore_Exe *exe __UNUSED__,
int start_bytes __UNUSED__,
int end_bytes __UNUSED__,
int start_lines __UNUSED__,
int end_lines __UNUSED__)
{
}
EAPI Ecore_Exe_Event_Data *
ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags)
ecore_exe_event_data_get(Ecore_Exe *exe,
Ecore_Exe_Flags flags)
{
Ecore_Exe_Event_Data *e = NULL;
unsigned char *inbuf;
int inbuf_num;
unsigned char *inbuf;
int inbuf_num;
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
@ -445,7 +478,8 @@ ecore_exe_pid_get(const Ecore_Exe *exe)
}
EAPI void
ecore_exe_tag_set(Ecore_Exe *exe, const char *tag)
ecore_exe_tag_set(Ecore_Exe *exe,
const char *tag)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
@ -454,7 +488,7 @@ ecore_exe_tag_set(Ecore_Exe *exe, const char *tag)
}
IF_FREE(exe->tag);
if (tag)
exe->tag = strdup(tag);
exe->tag = strdup(tag);
}
EAPI const char *
@ -545,7 +579,7 @@ ecore_exe_interrupt(Ecore_Exe *exe)
CloseHandle(exe->process_thread);
CloseHandle(exe->process);
exe->sig = ECORE_EXE_WIN32_SIGINT;
while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe));
while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe)) ;
}
EAPI void
@ -560,7 +594,7 @@ ecore_exe_quit(Ecore_Exe *exe)
CloseHandle(exe->process_thread);
CloseHandle(exe->process);
exe->sig = ECORE_EXE_WIN32_SIGQUIT;
while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe));
while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe)) ;
}
EAPI void
@ -575,7 +609,7 @@ ecore_exe_terminate(Ecore_Exe *exe)
/* CloseHandle(exe->thread); */
CloseHandle(exe->process);
exe->sig = ECORE_EXE_WIN32_SIGTERM;
while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe));
while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe)) ;
}
EAPI void
@ -590,11 +624,12 @@ ecore_exe_kill(Ecore_Exe *exe)
CloseHandle(exe->process_thread);
CloseHandle(exe->process);
exe->sig = ECORE_EXE_WIN32_SIGKILL;
while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe));
while (EnumWindows(_ecore_exe_enum_windows_procedure, (LPARAM)exe)) ;
}
EAPI void
ecore_exe_signal(Ecore_Exe *exe, int num __UNUSED__)
ecore_exe_signal(Ecore_Exe *exe,
int num __UNUSED__)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
@ -619,17 +654,18 @@ ecore_exe_hup(Ecore_Exe *exe)
/* FIXME: manage error mode */
static int
_ecore_exe_win32_pipe_thread_generic_cb(void *data, Ecore_Exe_Flags flags)
_ecore_exe_win32_pipe_thread_generic_cb(void *data,
Ecore_Exe_Flags flags)
{
#define BUFSIZE 2048
char buf[BUFSIZE];
Ecore_Exe *exe;
char *current_buf = NULL;
HANDLE child_pipe;
char buf[BUFSIZE];
Ecore_Exe *exe;
char *current_buf = NULL;
HANDLE child_pipe;
Ecore_Pipe *ecore_pipe;
Ecore_Exe_Event_Data *event;
DWORD size;
DWORD current_size = 0;
DWORD size;
DWORD current_size = 0;
BOOL res;
exe = (Ecore_Exe *)data;
@ -653,7 +689,7 @@ _ecore_exe_win32_pipe_thread_generic_cb(void *data, Ecore_Exe_Flags flags)
while (1)
{
if (!PeekNamedPipe(child_pipe, buf, sizeof(buf), &size, &current_size, NULL))
if (!PeekNamedPipe(child_pipe, buf, sizeof(buf), &size, &current_size, NULL))
continue;
if (size == 0)
continue;
@ -700,13 +736,13 @@ _ecore_exe_win32_pipe_thread_generic_cb(void *data, Ecore_Exe_Flags flags)
static DWORD WINAPI
_ecore_exe_win32_pipe_thread_read_cb(void *data)
{
return _ecore_exe_win32_pipe_thread_generic_cb(data, ECORE_EXE_PIPE_READ);
return _ecore_exe_win32_pipe_thread_generic_cb(data, ECORE_EXE_PIPE_READ);
}
static DWORD WINAPI
_ecore_exe_win32_pipe_thread_error_cb(void *data)
{
return _ecore_exe_win32_pipe_thread_generic_cb(data, ECORE_EXE_PIPE_ERROR);
return _ecore_exe_win32_pipe_thread_generic_cb(data, ECORE_EXE_PIPE_ERROR);
}
static int
@ -756,13 +792,13 @@ _ecore_exe_win32_pipes_set(Ecore_Exe *exe)
exe->pipe_error.child_pipe_x = child_pipe_x;
exe->pipe_error.p = ecore_pipe_add(_ecore_exe_pipe_error_cb, exe);
exe->pipe_error.thread = CreateThread(NULL, 0,
_ecore_exe_win32_pipe_thread_error_cb,
exe, 0, NULL);
_ecore_exe_win32_pipe_thread_error_cb,
exe, 0, NULL);
}
return 1;
close_pipe:
close_pipe:
CloseHandle(child_pipe);
CloseHandle(child_pipe_x);
@ -774,44 +810,44 @@ _ecore_exe_win32_pipes_close(Ecore_Exe *exe)
{
if (exe->flags & ECORE_EXE_PIPE_READ)
{
if (exe->pipe_read.child_pipe)
{
CloseHandle(exe->pipe_read.child_pipe);
exe->pipe_read.child_pipe = NULL;
}
if (exe->pipe_read.child_pipe_x)
{
CloseHandle(exe->pipe_read.child_pipe_x);
exe->pipe_read.child_pipe_x = NULL;
}
if (exe->pipe_read.child_pipe)
{
CloseHandle(exe->pipe_read.child_pipe);
exe->pipe_read.child_pipe = NULL;
}
if (exe->pipe_read.child_pipe_x)
{
CloseHandle(exe->pipe_read.child_pipe_x);
exe->pipe_read.child_pipe_x = NULL;
}
}
if (exe->flags & ECORE_EXE_PIPE_WRITE)
{
if (exe->pipe_write.child_pipe)
{
CloseHandle(exe->pipe_write.child_pipe);
exe->pipe_write.child_pipe = NULL;
}
if (exe->pipe_write.child_pipe_x)
{
CloseHandle(exe->pipe_write.child_pipe_x);
exe->pipe_write.child_pipe_x = NULL;
}
if (exe->pipe_write.child_pipe)
{
CloseHandle(exe->pipe_write.child_pipe);
exe->pipe_write.child_pipe = NULL;
}
if (exe->pipe_write.child_pipe_x)
{
CloseHandle(exe->pipe_write.child_pipe_x);
exe->pipe_write.child_pipe_x = NULL;
}
}
if (exe->flags & ECORE_EXE_PIPE_ERROR)
{
if (exe->pipe_error.child_pipe)
{
CloseHandle(exe->pipe_error.child_pipe);
exe->pipe_error.child_pipe = NULL;
}
if (exe->pipe_error.child_pipe_x)
{
CloseHandle(exe->pipe_error.child_pipe_x);
exe->pipe_error.child_pipe_x = NULL;
}
if (exe->pipe_error.child_pipe)
{
CloseHandle(exe->pipe_error.child_pipe);
exe->pipe_error.child_pipe = NULL;
}
if (exe->pipe_error.child_pipe_x)
{
CloseHandle(exe->pipe_error.child_pipe_x);
exe->pipe_error.child_pipe_x = NULL;
}
}
}
@ -824,10 +860,11 @@ _ecore_exe_thread_procedure(LPVOID data __UNUSED__)
}
static BOOL CALLBACK
_ecore_exe_enum_windows_procedure(HWND window, LPARAM data)
_ecore_exe_enum_windows_procedure(HWND window,
LPARAM data)
{
Ecore_Exe *exe;
DWORD thread_id;
DWORD thread_id;
exe = (Ecore_Exe *)data;
thread_id = GetWindowThreadProcessId(window, NULL);
@ -835,62 +872,63 @@ _ecore_exe_enum_windows_procedure(HWND window, LPARAM data)
if (thread_id == exe->thread_id)
{
/* Ctrl-C or Ctrl-Break */
if (CreateRemoteThread(exe->process, NULL, 0,
(LPTHREAD_START_ROUTINE)_ecore_exe_thread_procedure, NULL,
0, NULL))
{
printf ("remote thread\n");
return EINA_FALSE;
}
if (CreateRemoteThread(exe->process, NULL, 0,
(LPTHREAD_START_ROUTINE)_ecore_exe_thread_procedure, NULL,
0, NULL))
{
printf ("remote thread\n");
return EINA_FALSE;
}
if ((exe->sig == ECORE_EXE_WIN32_SIGINT) ||
(exe->sig == ECORE_EXE_WIN32_SIGQUIT))
{
printf ("int or quit\n");
return EINA_FALSE;
}
if ((exe->sig == ECORE_EXE_WIN32_SIGINT) ||
(exe->sig == ECORE_EXE_WIN32_SIGQUIT))
{
printf ("int or quit\n");
return EINA_FALSE;
}
/* WM_CLOSE message */
PostMessage(window, WM_CLOSE, 0, 0);
if (WaitForSingleObject(exe->process, ECORE_EXE_WIN32_TIMEOUT) == WAIT_OBJECT_0)
{
printf ("CLOSE\n");
return EINA_FALSE;
}
/* WM_CLOSE message */
PostMessage(window, WM_CLOSE, 0, 0);
if (WaitForSingleObject(exe->process, ECORE_EXE_WIN32_TIMEOUT) == WAIT_OBJECT_0)
{
printf ("CLOSE\n");
return EINA_FALSE;
}
/* WM_QUIT message */
PostMessage(window, WM_QUIT, 0, 0);
if (WaitForSingleObject(exe->process, ECORE_EXE_WIN32_TIMEOUT) == WAIT_OBJECT_0)
{
printf ("QUIT\n");
return EINA_FALSE;
}
/* WM_QUIT message */
PostMessage(window, WM_QUIT, 0, 0);
if (WaitForSingleObject(exe->process, ECORE_EXE_WIN32_TIMEOUT) == WAIT_OBJECT_0)
{
printf ("QUIT\n");
return EINA_FALSE;
}
/* Exit process */
if (CreateRemoteThread(exe->process, NULL, 0,
(LPTHREAD_START_ROUTINE)ExitProcess, NULL,
0, NULL))
{
printf ("remote thread 2\n");
return EINA_FALSE;
}
/* Exit process */
if (CreateRemoteThread(exe->process, NULL, 0,
(LPTHREAD_START_ROUTINE)ExitProcess, NULL,
0, NULL))
{
printf ("remote thread 2\n");
return EINA_FALSE;
}
if (exe->sig == ECORE_EXE_WIN32_SIGTERM)
{
printf ("term\n");
return EINA_FALSE;
}
if (exe->sig == ECORE_EXE_WIN32_SIGTERM)
{
printf ("term\n");
return EINA_FALSE;
}
TerminateProcess(exe->process, 0);
TerminateProcess(exe->process, 0);
return EINA_FALSE;
return EINA_FALSE;
}
return EINA_TRUE;
}
static void
_ecore_exe_event_add_free(void *data __UNUSED__, void *ev)
_ecore_exe_event_add_free(void *data __UNUSED__,
void *ev)
{
Ecore_Exe_Event_Add *e;
@ -899,7 +937,8 @@ _ecore_exe_event_add_free(void *data __UNUSED__, void *ev)
}
static void
_ecore_exe_event_del_free(void *data __UNUSED__, void *ev)
_ecore_exe_event_del_free(void *data __UNUSED__,
void *ev)
{
Ecore_Exe_Event_Del *e;
@ -910,7 +949,8 @@ _ecore_exe_event_del_free(void *data __UNUSED__, void *ev)
}
static void
_ecore_exe_event_exe_data_free(void *data __UNUSED__, void *ev)
_ecore_exe_event_exe_data_free(void *data __UNUSED__,
void *ev)
{
Ecore_Exe_Event_Data *e;
@ -919,11 +959,12 @@ _ecore_exe_event_exe_data_free(void *data __UNUSED__, void *ev)
}
static Eina_Bool
_ecore_exe_close_cb(void *data, Ecore_Win32_Handler *wh __UNUSED__)
_ecore_exe_close_cb(void *data,
Ecore_Win32_Handler *wh __UNUSED__)
{
Ecore_Exe_Event_Del *e;
Ecore_Exe *exe;
DWORD exit_code = 0;
Ecore_Exe *exe;
DWORD exit_code = 0;
e = calloc(1, sizeof(Ecore_Exe_Event_Del));
if (!e) return 0;
@ -943,17 +984,19 @@ _ecore_exe_close_cb(void *data, Ecore_Win32_Handler *wh __UNUSED__)
printf("%s\n", msg);
free(msg);
}
e->pid = exe->process_id;
e->exe = exe;
e->pid = exe->process_id;
e->exe = exe;
ecore_event_add(ECORE_EXE_EVENT_DEL, e,
_ecore_exe_event_del_free, NULL);
ecore_event_add(ECORE_EXE_EVENT_DEL, e,
_ecore_exe_event_del_free, NULL);
return 0;
}
static void
_ecore_exe_pipe_read_cb(void *data, void *buf, unsigned int size)
_ecore_exe_pipe_read_cb(void *data,
void *buf,
unsigned int size)
{
Ecore_Exe_Event_Data *e;
@ -965,19 +1008,20 @@ _ecore_exe_pipe_read_cb(void *data, void *buf, unsigned int size)
}
static int
_ecore_exe_pipe_write_cb(void *data, Ecore_Win32_Handler *wh __UNUSED__)
_ecore_exe_pipe_write_cb(void *data,
Ecore_Win32_Handler *wh __UNUSED__)
{
char buf[READBUFSIZ];
char buf[READBUFSIZ];
Ecore_Exe *exe;
DWORD num_exe;
BOOL res;
DWORD num_exe;
BOOL res;
exe = (Ecore_Exe *)data;
res = WriteFile(exe->pipe_write.child_pipe_x, buf, READBUFSIZ, &num_exe, NULL);
if (!res || num_exe == 0)
{
/* FIXME: what to do here ?? */
/* FIXME: what to do here ?? */
}
if (exe->close_stdin == 1)
@ -996,7 +1040,9 @@ _ecore_exe_pipe_write_cb(void *data, Ecore_Win32_Handler *wh __UNUSED__)
}
static void
_ecore_exe_pipe_error_cb(void *data, void *buf, unsigned int size)
_ecore_exe_pipe_error_cb(void *data,
void *buf,
unsigned int size)
{
Ecore_Exe_Event_Data *e;
@ -1006,3 +1052,4 @@ _ecore_exe_pipe_error_cb(void *data, void *buf, unsigned int size)
_ecore_exe_event_exe_data_free,
NULL);
}

View File

@ -18,3 +18,4 @@ void
_ecore_exe_shutdown(void)
{
}

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,9 @@ _ecore_glib_fds_resize(size_t size)
}
static int
_ecore_glib_context_query(GMainContext *ctx, int priority, int *p_timer)
_ecore_glib_context_query(GMainContext *ctx,
int priority,
int *p_timer)
{
int reqfds;
@ -51,7 +53,7 @@ _ecore_glib_context_query(GMainContext *ctx, int priority, int *p_timer)
size_t size;
reqfds = g_main_context_query
(ctx, priority, p_timer, _ecore_glib_fds, _ecore_glib_fds_size);
(ctx, priority, p_timer, _ecore_glib_fds, _ecore_glib_fds_size);
if (reqfds <= (int)_ecore_glib_fds_size) break;
size = (1 + reqfds / ECORE_GLIB_FDS_STEP) * ECORE_GLIB_FDS_STEP;
@ -70,7 +72,11 @@ _ecore_glib_context_query(GMainContext *ctx, int priority, int *p_timer)
}
static int
_ecore_glib_context_poll_from(const GPollFD *pfds, int count, fd_set *rfds, fd_set *wfds, fd_set *efds)
_ecore_glib_context_poll_from(const GPollFD *pfds,
int count,
fd_set *rfds,
fd_set *wfds,
fd_set *efds)
{
const GPollFD *itr = pfds, *itr_end = pfds + count;
int glib_fds = -1;
@ -92,7 +98,12 @@ _ecore_glib_context_poll_from(const GPollFD *pfds, int count, fd_set *rfds, fd_s
}
static int
_ecore_glib_context_poll_to(GPollFD *pfds, int count, const fd_set *rfds, const fd_set *wfds, const fd_set *efds, int ready)
_ecore_glib_context_poll_to(GPollFD *pfds,
int count,
const fd_set *rfds,
const fd_set *wfds,
const fd_set *efds,
int ready)
{
GPollFD *itr = pfds, *itr_end = pfds + count;
@ -119,7 +130,12 @@ _ecore_glib_context_poll_to(GPollFD *pfds, int count, const fd_set *rfds, const
}
static int
_ecore_glib_select__locked(GMainContext *ctx, int ecore_fds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *ecore_timeout)
_ecore_glib_select__locked(GMainContext *ctx,
int ecore_fds,
fd_set *rfds,
fd_set *wfds,
fd_set *efds,
struct timeval *ecore_timeout)
{
int priority, maxfds, glib_fds, reqfds, reqtimeout, ret;
struct timeval *timeout, glib_timeout;
@ -129,7 +145,7 @@ _ecore_glib_select__locked(GMainContext *ctx, int ecore_fds, fd_set *rfds, fd_se
if (reqfds < 0) goto error;
glib_fds = _ecore_glib_context_poll_from
(_ecore_glib_fds, reqfds, rfds, wfds, efds);
(_ecore_glib_fds, reqfds, rfds, wfds, efds);
if (reqtimeout == -1)
timeout = ecore_timeout;
@ -148,20 +164,24 @@ _ecore_glib_select__locked(GMainContext *ctx, int ecore_fds, fd_set *rfds, fd_se
ret = _ecore_glib_select_original(maxfds, rfds, wfds, efds, timeout);
ret = _ecore_glib_context_poll_to
(_ecore_glib_fds, reqfds, rfds, wfds, efds, ret);
(_ecore_glib_fds, reqfds, rfds, wfds, efds, ret);
if (g_main_context_check(ctx, priority, _ecore_glib_fds, reqfds))
g_main_context_dispatch(ctx);
return ret;
error:
error:
return _ecore_glib_select_original
(ecore_fds, rfds, wfds, efds, ecore_timeout);
(ecore_fds, rfds, wfds, efds, ecore_timeout);
}
static int
_ecore_glib_select(int ecore_fds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *ecore_timeout)
_ecore_glib_select(int ecore_fds,
fd_set *rfds,
fd_set *wfds,
fd_set *efds,
struct timeval *ecore_timeout)
{
GStaticMutex lock = G_STATIC_MUTEX_INIT;
GMutex *mutex = g_static_mutex_get_mutex(&lock);
@ -180,13 +200,14 @@ _ecore_glib_select(int ecore_fds, fd_set *rfds, fd_set *wfds, fd_set *efds, stru
}
ret = _ecore_glib_select__locked
(ctx, ecore_fds, rfds, wfds, efds, ecore_timeout);
(ctx, ecore_fds, rfds, wfds, efds, ecore_timeout);
g_mutex_unlock(mutex);
g_main_context_release(ctx);
return ret;
}
#endif
void

View File

@ -7,21 +7,19 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Idle_Enterer
{
EINA_INLIST;
ECORE_MAGIC;
ECORE_MAGIC;
Ecore_Task_Cb func;
void *data;
int references;
Eina_Bool delete_me : 1;
void *data;
int references;
Eina_Bool delete_me : 1;
};
static Ecore_Idle_Enterer *idle_enterers = NULL;
static Ecore_Idle_Enterer *idle_enterer_current = NULL;
static int idle_enterers_delete_me = 0;
static int idle_enterers_delete_me = 0;
static void *
_ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer);
@ -43,7 +41,8 @@ _ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer);
* (or ECORE_CALLBACK_CANCEL) deletes the idle enterer.
*/
EAPI Ecore_Idle_Enterer *
ecore_idle_enterer_add(Ecore_Task_Cb func, const void *data)
ecore_idle_enterer_add(Ecore_Task_Cb func,
const void *data)
{
Ecore_Idle_Enterer *ie = NULL;
@ -55,7 +54,7 @@ ecore_idle_enterer_add(Ecore_Task_Cb func, const void *data)
ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_ENTERER);
ie->func = func;
ie->data = (void *)data;
idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_append(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
idle_enterers = (Ecore_Idle_Enterer *)eina_inlist_append(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
unlock:
_ecore_unlock();
return ie;
@ -72,7 +71,8 @@ unlock:
* (or ECORE_CALLBACK_CANCEL) deletes the idle enterer.
*/
EAPI Ecore_Idle_Enterer *
ecore_idle_enterer_before_add(Ecore_Task_Cb func, const void *data)
ecore_idle_enterer_before_add(Ecore_Task_Cb func,
const void *data)
{
Ecore_Idle_Enterer *ie = NULL;
@ -84,7 +84,7 @@ ecore_idle_enterer_before_add(Ecore_Task_Cb func, const void *data)
ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_ENTERER);
ie->func = func;
ie->data = (void *)data;
idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_prepend(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
idle_enterers = (Ecore_Idle_Enterer *)eina_inlist_prepend(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
unlock:
_ecore_unlock();
return ie;
@ -126,14 +126,13 @@ _ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer)
return idle_enterer->data;
}
void
_ecore_idle_enterer_shutdown(void)
{
Ecore_Idle_Enterer *ie;
while ((ie = idle_enterers))
{
idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers));
idle_enterers = (Ecore_Idle_Enterer *)eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
free(ie);
}
@ -147,13 +146,13 @@ _ecore_idle_enterer_call(void)
if (!idle_enterer_current)
{
/* regular main loop, start from head */
idle_enterer_current = idle_enterers;
idle_enterer_current = idle_enterers;
}
else
{
/* recursive main loop, continue from where we were */
idle_enterer_current =
(Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next;
idle_enterer_current =
(Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next;
}
while (idle_enterer_current)
@ -177,10 +176,10 @@ _ecore_idle_enterer_call(void)
Ecore_Idle_Enterer *l;
int deleted_idler_enterers_in_use = 0;
for (l = idle_enterers; l;)
for (l = idle_enterers; l; )
{
Ecore_Idle_Enterer *ie = l;
l = (Ecore_Idle_Enterer *) EINA_INLIST_GET(l)->next;
l = (Ecore_Idle_Enterer *)EINA_INLIST_GET(l)->next;
if (ie->delete_me)
{
if (ie->references)
@ -189,7 +188,7 @@ _ecore_idle_enterer_call(void)
continue;
}
idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
idle_enterers = (Ecore_Idle_Enterer *)eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
free(ie);
}
@ -205,3 +204,4 @@ _ecore_idle_enterer_exist(void)
if (idle_enterers) return 1;
return 0;
}

View File

@ -7,21 +7,19 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Idle_Exiter
{
EINA_INLIST;
ECORE_MAGIC;
ECORE_MAGIC;
Ecore_Task_Cb func;
void *data;
int references;
Eina_Bool delete_me : 1;
void *data;
int references;
Eina_Bool delete_me : 1;
};
static Ecore_Idle_Exiter *idle_exiters = NULL;
static Ecore_Idle_Exiter *idle_exiter_current = NULL;
static int idle_exiters_delete_me = 0;
static int idle_exiters_delete_me = 0;
static void *
_ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter);
@ -42,7 +40,8 @@ _ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter);
* (or ECORE_CALLBACK_CANCEL) deletes the idle exiter.
*/
EAPI Ecore_Idle_Exiter *
ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data)
ecore_idle_exiter_add(Ecore_Task_Cb func,
const void *data)
{
Ecore_Idle_Exiter *ie = NULL;
@ -53,7 +52,7 @@ ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data)
ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_EXITER);
ie->func = func;
ie->data = (void *)data;
idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_append(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie));
idle_exiters = (Ecore_Idle_Exiter *)eina_inlist_append(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie));
unlock:
_ecore_unlock();
return ie;
@ -101,7 +100,7 @@ _ecore_idle_exiter_shutdown(void)
Ecore_Idle_Exiter *ie;
while ((ie = idle_exiters))
{
idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(idle_exiters));
idle_exiters = (Ecore_Idle_Exiter *)eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(idle_exiters));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
free(ie);
}
@ -115,13 +114,13 @@ _ecore_idle_exiter_call(void)
if (!idle_exiter_current)
{
/* regular main loop, start from head */
idle_exiter_current = idle_exiters;
idle_exiter_current = idle_exiters;
}
else
{
/* recursive main loop, continue from where we were */
idle_exiter_current =
(Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next;
idle_exiter_current =
(Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next;
}
while (idle_exiter_current)
@ -145,11 +144,11 @@ _ecore_idle_exiter_call(void)
Ecore_Idle_Exiter *l;
int deleted_idler_exiters_in_use = 0;
for (l = idle_exiters; l;)
for (l = idle_exiters; l; )
{
Ecore_Idle_Exiter *ie = l;
l = (Ecore_Idle_Exiter *) EINA_INLIST_GET(l)->next;
l = (Ecore_Idle_Exiter *)EINA_INLIST_GET(l)->next;
if (ie->delete_me)
{
if (ie->references)
@ -158,7 +157,7 @@ _ecore_idle_exiter_call(void)
continue;
}
idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie));
idle_exiters = (Ecore_Idle_Exiter *)eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
free(ie);
}
@ -174,3 +173,4 @@ _ecore_idle_exiter_exist(void)
if (idle_exiters) return 1;
return 0;
}

View File

@ -7,27 +7,26 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Idler
{
EINA_INLIST;
ECORE_MAGIC;
ECORE_MAGIC;
Ecore_Task_Cb func;
void *data;
int references;
Eina_Bool delete_me : 1;
void *data;
int references;
Eina_Bool delete_me : 1;
};
static Ecore_Idler *idlers = NULL;
static Ecore_Idler *idler_current = NULL;
static int idlers_delete_me = 0;
static int idlers_delete_me = 0;
static void *
_ecore_idler_del(Ecore_Idler *idler);
EAPI Ecore_Idler *
ecore_idler_add(Ecore_Task_Cb func, const void *data)
ecore_idler_add(Ecore_Task_Cb func,
const void *data)
{
Ecore_Idler *ie = NULL;
@ -38,7 +37,7 @@ ecore_idler_add(Ecore_Task_Cb func, const void *data)
ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLER);
ie->func = func;
ie->data = (void *)data;
idlers = (Ecore_Idler *) eina_inlist_append(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
idlers = (Ecore_Idler *)eina_inlist_append(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
unlock:
_ecore_unlock();
return ie;
@ -79,14 +78,13 @@ _ecore_idler_del(Ecore_Idler *idler)
return idler->data;
}
void
_ecore_idler_shutdown(void)
{
Ecore_Idler *ie;
while ((ie = idlers))
{
idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers));
idlers = (Ecore_Idler *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
free(ie);
}
@ -100,12 +98,12 @@ _ecore_idler_all_call(void)
if (!idler_current)
{
/* regular main loop, start from head */
idler_current = idlers;
idler_current = idlers;
}
else
{
/* recursive main loop, continue from where we were */
idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next;
idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next;
}
while (idler_current)
@ -127,10 +125,10 @@ _ecore_idler_all_call(void)
{
Ecore_Idler *l;
int deleted_idlers_in_use = 0;
for (l = idlers; l;)
for (l = idlers; l; )
{
Ecore_Idler *ie = l;
l = (Ecore_Idler *) EINA_INLIST_GET(l)->next;
l = (Ecore_Idler *)EINA_INLIST_GET(l)->next;
if (ie->delete_me)
{
if (ie->references)
@ -139,7 +137,7 @@ _ecore_idler_all_call(void)
continue;
}
idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
idlers = (Ecore_Idler *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
free(ie);
}
@ -157,3 +155,4 @@ _ecore_idler_exist(void)
if (idlers) return 1;
return 0;
}

View File

@ -7,18 +7,21 @@
#include "Ecore.h"
#include "ecore_private.h"
static Eina_Bool _ecore_job_event_handler(void *data, int type, void *ev);
static void _ecore_job_event_free(void *data, void *ev);
static Eina_Bool _ecore_job_event_handler(void *data,
int type,
void *ev);
static void _ecore_job_event_free(void *data,
void *ev);
static int ecore_event_job_type = 0;
static Ecore_Event_Handler* _ecore_job_handler = NULL;
static Ecore_Event_Handler *_ecore_job_handler = NULL;
struct _Ecore_Job
{
ECORE_MAGIC;
Ecore_Event *event;
Ecore_Cb func;
void *data;
ECORE_MAGIC;
Ecore_Event *event;
Ecore_Cb func;
void *data;
};
void
@ -51,7 +54,8 @@ _ecore_job_shutdown(void)
* @note Once the job has been executed, the job handle is invalid.
*/
EAPI Ecore_Job *
ecore_job_add(Ecore_Cb func, const void *data)
ecore_job_add(Ecore_Cb func,
const void *data)
{
Ecore_Job *job;
@ -98,7 +102,9 @@ ecore_job_del(Ecore_Job *job)
*/
static Eina_Bool
_ecore_job_event_handler(void *data __UNUSED__, int type __UNUSED__, void *ev)
_ecore_job_event_handler(void *data __UNUSED__,
int type __UNUSED__,
void *ev)
{
Ecore_Job *job;
@ -108,7 +114,9 @@ _ecore_job_event_handler(void *data __UNUSED__, int type __UNUSED__, void *ev)
}
static void
_ecore_job_event_free(void *data __UNUSED__, void *ev)
_ecore_job_event_free(void *data __UNUSED__,
void *ev)
{
free(ev);
}

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
#include <math.h>
#ifdef HAVE_ISFINITE
# define ECORE_FINITE(t) isfinite(t)
# define ECORE_FINITE(t) isfinite(t)
#else
# ifdef _MSC_VER
# define ECORE_FINITE(t) _finite(t)
@ -54,8 +54,8 @@
# define pipe_write(fd, buffer, size) send((fd), (char *)(buffer), size, 0)
# define pipe_read(fd, buffer, size) recv((fd), (char *)(buffer), size, 0)
# define pipe_close(fd) closesocket(fd)
# define PIPE_FD_INVALID INVALID_SOCKET
# define PIPE_FD_ERROR SOCKET_ERROR
# define PIPE_FD_INVALID INVALID_SOCKET
# define PIPE_FD_ERROR SOCKET_ERROR
#else
@ -65,14 +65,14 @@
# define pipe_write(fd, buffer, size) write((fd), buffer, size)
# define pipe_read(fd, buffer, size) read((fd), buffer, size)
# define pipe_close(fd) close(fd)
# define PIPE_FD_INVALID -1
# define PIPE_FD_ERROR -1
# define PIPE_FD_INVALID -1
# define PIPE_FD_ERROR -1
#endif /* ! _WIN32 */
struct _Ecore_Pipe
{
ECORE_MAGIC;
ECORE_MAGIC;
int fd_read;
int fd_write;
Ecore_Fd_Handler *fd_handler;
@ -86,9 +86,8 @@ struct _Ecore_Pipe
Eina_Bool delete_me : 1;
};
static Eina_Bool _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler);
static Eina_Bool _ecore_pipe_read(void *data,
Ecore_Fd_Handler *fd_handler);
/**
* @addtogroup Ecore_Pipe_Group
@ -108,10 +107,11 @@ static Eina_Bool _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler);
* @c NULL otherwise.
*/
EAPI Ecore_Pipe *
ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data)
ecore_pipe_add(Ecore_Pipe_Cb handler,
const void *data)
{
Ecore_Pipe *p;
int fds[2];
int fds[2];
if (!handler) return NULL;
@ -132,10 +132,10 @@ ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data)
fcntl(p->fd_read, F_SETFL, O_NONBLOCK);
p->fd_handler = ecore_main_fd_handler_add(p->fd_read,
ECORE_FD_READ,
_ecore_pipe_read,
p,
NULL, NULL);
ECORE_FD_READ,
_ecore_pipe_read,
p,
NULL, NULL);
return p;
}
@ -250,7 +250,9 @@ ecore_pipe_thaw(Ecore_Pipe *p)
* Negative value for @p wait means infite wait.
*/
EAPI int
ecore_pipe_wait(Ecore_Pipe *p, int message_count, double wait)
ecore_pipe_wait(Ecore_Pipe *p,
int message_count,
double wait)
{
struct timeval tv, *t;
fd_set rset;
@ -274,26 +276,26 @@ ecore_pipe_wait(Ecore_Pipe *p, int message_count, double wait)
if (wait >= 0.0)
{
/* finite() tests for NaN, too big, too small, and infinity. */
if ((!ECORE_FINITE(timeout)) || (timeout == 0.0))
{
tv.tv_sec = 0;
tv.tv_usec = 0;
}
else if (timeout > 0.0)
{
int sec, usec;
if ((!ECORE_FINITE(timeout)) || (timeout == 0.0))
{
tv.tv_sec = 0;
tv.tv_usec = 0;
}
else if (timeout > 0.0)
{
int sec, usec;
#ifdef FIX_HZ
timeout += (0.5 / HZ);
sec = (int)timeout;
usec = (int)((timeout - (double)sec) * 1000000);
timeout += (0.5 / HZ);
sec = (int)timeout;
usec = (int)((timeout - (double)sec) * 1000000);
#else
sec = (int)timeout;
usec = (int)((timeout - (double)sec) * 1000000);
sec = (int)timeout;
usec = (int)((timeout - (double)sec) * 1000000);
#endif
tv.tv_sec = sec;
tv.tv_usec = usec;
}
t = &tv;
tv.tv_sec = sec;
tv.tv_usec = usec;
}
t = &tv;
}
else
{
@ -356,11 +358,13 @@ ecore_pipe_write_close(Ecore_Pipe *p)
* @return Returns EINA_TRUE on a successful write, EINA_FALSE on an error
*/
EAPI Eina_Bool
ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes)
ecore_pipe_write(Ecore_Pipe *p,
const void *buffer,
unsigned int nbytes)
{
ssize_t ret;
size_t already_written = 0;
int retry = ECORE_PIPE_WRITE_RETRY;
size_t already_written = 0;
int retry = ECORE_PIPE_WRITE_RETRY;
if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
{
@ -384,9 +388,9 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes)
else if (ret > 0)
{
/* XXX What should we do here? */
ERR("The length of the data was not written complete"
" to the pipe");
return EINA_FALSE;
ERR("The length of the data was not written complete"
" to the pipe");
return EINA_FALSE;
}
else if (ret == PIPE_FD_ERROR && errno == EPIPE)
{
@ -459,15 +463,16 @@ _ecore_pipe_unhandle(Ecore_Pipe *p)
}
static Eina_Bool
_ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
_ecore_pipe_read(void *data,
Ecore_Fd_Handler *fd_handler __UNUSED__)
{
Ecore_Pipe *p = (Ecore_Pipe *)data;
int i;
Ecore_Pipe *p = (Ecore_Pipe *)data;
int i;
p->handling++;
for (i = 0; i < 16; i++)
{
ssize_t ret;
ssize_t ret;
/* if we already have read some data we don't need to read the len
* but to finish the already started job
@ -475,81 +480,81 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
if (p->len == 0)
{
/* read the len of the passed data */
ret = pipe_read(p->fd_read, &p->len, sizeof(p->len));
ret = pipe_read(p->fd_read, &p->len, sizeof(p->len));
/* catch the non error case first */
/* read amount ok - nothing more to do */
if (ret == sizeof(p->len))
;
else if (ret > 0)
{
/* we got more data than we asked for - definite error */
ERR("Only read %i bytes from the pipe, although"
" we need to read %i bytes.",
(int)ret, (int)sizeof(p->len));
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
else if (ret == 0)
{
/* we got no data */
if (i == 0)
{
/* no data on first try through means an error */
if (!p->delete_me)
p->handler((void *)p->data, NULL, 0);
if (p->passed_data) free(p->passed_data);
p->passed_data = NULL;
p->already_read = 0;
p->len = 0;
p->message++;
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
else
{
/* no data after first loop try is ok */
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
}
/* catch the non error case first */
/* read amount ok - nothing more to do */
if (ret == sizeof(p->len))
;
else if (ret > 0)
{
/* we got more data than we asked for - definite error */
ERR("Only read %i bytes from the pipe, although"
" we need to read %i bytes.",
(int)ret, (int)sizeof(p->len));
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
else if (ret == 0)
{
/* we got no data */
if (i == 0)
{
/* no data on first try through means an error */
if (!p->delete_me)
p->handler((void *)p->data, NULL, 0);
if (p->passed_data) free(p->passed_data);
p->passed_data = NULL;
p->already_read = 0;
p->len = 0;
p->message++;
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
else
{
/* no data after first loop try is ok */
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
}
#ifndef _WIN32
else if ((ret == PIPE_FD_ERROR) &&
((errno == EINTR) || (errno == EAGAIN)))
{
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
else
{
ERR("An unhandled error (ret: %i errno: %i [%s])"
"occurred while reading from the pipe the length",
(int)ret, errno, strerror(errno));
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
else if ((ret == PIPE_FD_ERROR) &&
((errno == EINTR) || (errno == EAGAIN)))
{
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
else
{
ERR("An unhandled error (ret: %i errno: %i [%s])"
"occurred while reading from the pipe the length",
(int)ret, errno, strerror(errno));
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
#else
else /* ret == PIPE_FD_ERROR is the only other case on Windows */
{
if (WSAGetLastError() != WSAEWOULDBLOCK)
{
if (!p->delete_me)
else /* ret == PIPE_FD_ERROR is the only other case on Windows */
{
if (WSAGetLastError() != WSAEWOULDBLOCK)
{
if (!p->delete_me)
p->handler((void *)p->data, NULL, 0);
if (p->passed_data) free(p->passed_data);
p->passed_data = NULL;
p->already_read = 0;
p->len = 0;
p->message++;
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
}
if (p->passed_data) free(p->passed_data);
p->passed_data = NULL;
p->already_read = 0;
p->len = 0;
p->message++;
pipe_close(p->fd_read);
p->fd_read = PIPE_FD_INVALID;
p->fd_handler = NULL;
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_CANCEL;
}
}
#endif
}
@ -559,7 +564,7 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
if (p->len == 0)
{
if (!p->delete_me)
p->handler((void *)p->data, NULL, 0);
p->handler((void *)p->data, NULL, 0);
/* reset all values to 0 */
if (p->passed_data) free(p->passed_data);
p->passed_data = NULL;
@ -578,8 +583,8 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
if (!p->passed_data)
{
if (!p->delete_me)
p->handler((void *)p->data, NULL, 0);
/* close the pipe */
p->handler((void *)p->data, NULL, 0);
/* close the pipe */
p->already_read = 0;
p->len = 0;
p->message++;
@ -601,7 +606,7 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
if (ret == (ssize_t)(p->len - p->already_read))
{
if (!p->delete_me)
p->handler((void *)p->data, p->passed_data, p->len);
p->handler((void *)p->data, p->passed_data, p->len);
free(p->passed_data);
/* reset all values to 0 */
p->passed_data = NULL;
@ -612,15 +617,15 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
else if (ret > 0)
{
/* more data left to read */
p->already_read += ret;
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
p->already_read += ret;
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
else if (ret == 0)
{
/* 0 bytes to read - could be more to read next select wake up */
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}
#ifndef _WIN32
else if ((ret == PIPE_FD_ERROR) &&
@ -643,7 +648,7 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
if (WSAGetLastError() != WSAEWOULDBLOCK)
{
if (!p->delete_me)
p->handler((void *)p->data, NULL, 0);
p->handler((void *)p->data, NULL, 0);
if (p->passed_data) free(p->passed_data);
p->passed_data = NULL;
p->already_read = 0;
@ -664,3 +669,4 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
_ecore_pipe_unhandle(p);
return ECORE_CALLBACK_RENEW;
}

View File

@ -7,40 +7,38 @@
#include "Ecore.h"
#include "ecore_private.h"
struct _Ecore_Poller
{
EINA_INLIST;
ECORE_MAGIC;
ECORE_MAGIC;
int ibit;
unsigned char delete_me : 1;
Ecore_Task_Cb func;
void *data;
void *data;
};
static Ecore_Timer *timer = NULL;
static int min_interval = -1;
static int interval_incr = 0;
static int at_tick = 0;
static int just_added_poller = 0;
static int poller_delete_count = 0;
static int poller_walking = 0;
static double poll_interval = 0.125;
static double poll_cur_interval = 0.0;
static double last_tick = 0.0;
static Ecore_Poller *pollers[16] =
static Ecore_Timer *timer = NULL;
static int min_interval = -1;
static int interval_incr = 0;
static int at_tick = 0;
static int just_added_poller = 0;
static int poller_delete_count = 0;
static int poller_walking = 0;
static double poll_interval = 0.125;
static double poll_cur_interval = 0.0;
static double last_tick = 0.0;
static Ecore_Poller *pollers[16] =
{
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
static unsigned short poller_counters[16] =
static unsigned short poller_counters[16] =
{
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
static void _ecore_poller_next_tick_eval(void);
static void _ecore_poller_next_tick_eval(void);
static Eina_Bool _ecore_poller_cb_timer(void *data);
static void
@ -61,12 +59,12 @@ _ecore_poller_next_tick_eval(void)
if (min_interval < 0)
{
/* no pollers */
if (timer)
{
ecore_timer_del(timer);
timer = NULL;
}
return;
if (timer)
{
ecore_timer_del(timer);
timer = NULL;
}
return;
}
interval_incr = (1 << min_interval);
interval = interval_incr * poll_interval;
@ -91,8 +89,8 @@ _ecore_poller_next_tick_eval(void)
if (interval != poll_cur_interval)
{
t -= last_tick; /* time since we last ticked */
/* delete the timer and reset it to tick off in the new
* time interval. at the tick this will be adjusted */
/* delete the timer and reset it to tick off in the new
* time interval. at the tick this will be adjusted */
ecore_timer_del(timer);
timer = ecore_timer_add(interval - t,
_ecore_poller_cb_timer, NULL);
@ -128,23 +126,23 @@ _ecore_poller_cb_timer(void *data __UNUSED__)
{
/* if the counter is @ 0 - this means that counter "went off" this
* tick interval, so run all pollers hooked to that counter */
if (poller_counters[i] == 0)
{
EINA_INLIST_FOREACH(pollers[i], poller)
{
if (!poller->delete_me)
{
if (!poller->func(poller->data))
{
if (!poller->delete_me)
{
poller->delete_me = 1;
poller_delete_count++;
}
}
}
}
}
if (poller_counters[i] == 0)
{
EINA_INLIST_FOREACH(pollers[i], poller)
{
if (!poller->delete_me)
{
if (!poller->func(poller->data))
{
if (!poller->delete_me)
{
poller->delete_me = 1;
poller_delete_count++;
}
}
}
}
}
}
poller_walking--;
@ -152,23 +150,23 @@ _ecore_poller_cb_timer(void *data __UNUSED__)
if (poller_delete_count > 0)
{
/* FIXME: walk all pollers and remove deleted ones */
for (i = 0; i < 15; i++)
{
for (l = pollers[i]; l;)
{
poller = l;
l = (Ecore_Poller *) EINA_INLIST_GET(l)->next;
if (poller->delete_me)
{
pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller));
free(poller);
poller_delete_count--;
changes++;
if (poller_delete_count <= 0) break;
}
}
if (poller_delete_count <= 0) break;
}
for (i = 0; i < 15; i++)
{
for (l = pollers[i]; l; )
{
poller = l;
l = (Ecore_Poller *)EINA_INLIST_GET(l)->next;
if (poller->delete_me)
{
pollers[i] = (Ecore_Poller *)eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller));
free(poller);
poller_delete_count--;
changes++;
if (poller_delete_count <= 0) break;
}
}
if (poller_delete_count <= 0) break;
}
}
/* if we deleted or added any pollers, then we need to re-evaluate our
* minimum poll interval */
@ -196,7 +194,6 @@ _ecore_poller_cb_timer(void *data __UNUSED__)
* @{
*/
/**
* Sets the time between ticks (in seconds) for the given ticker clock.
* @param type The ticker type to adjust
@ -206,7 +203,8 @@ _ecore_poller_cb_timer(void *data __UNUSED__)
* by @p type to the time period defined by @p poll_time.
*/
EAPI void
ecore_poller_poll_interval_set(Ecore_Poller_Type type __UNUSED__, double poll_time)
ecore_poller_poll_interval_set(Ecore_Poller_Type type __UNUSED__,
double poll_time)
{
poll_interval = poll_time;
_ecore_poller_next_tick_eval();
@ -272,7 +270,10 @@ ecore_poller_poll_interval_get(Ecore_Poller_Type type __UNUSED__)
* invalid.
*/
EAPI Ecore_Poller *
ecore_poller_add(Ecore_Poller_Type type __UNUSED__, int interval, Ecore_Task_Cb func, const void *data)
ecore_poller_add(Ecore_Poller_Type type __UNUSED__,
int interval,
Ecore_Task_Cb func,
const void *data)
{
Ecore_Poller *poller;
int ibit;
@ -297,7 +298,7 @@ ecore_poller_add(Ecore_Poller_Type type __UNUSED__, int interval, Ecore_Task_Cb
poller->ibit = ibit;
poller->func = func;
poller->data = (void *)data;
pollers[poller->ibit] = (Ecore_Poller *) eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
pollers[poller->ibit] = (Ecore_Poller *)eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
if (poller_walking)
just_added_poller++;
else
@ -316,14 +317,15 @@ ecore_poller_add(Ecore_Poller_Type type __UNUSED__, int interval, Ecore_Task_Cb
* a poll rate without deleting and re-creating a poller.
*/
EAPI Eina_Bool
ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval)
ecore_poller_poller_interval_set(Ecore_Poller *poller,
int interval)
{
int ibit;
if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER))
{
ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
"ecore_poller_poller_interval_set");
"ecore_poller_poller_interval_set");
return EINA_FALSE;
}
@ -332,17 +334,17 @@ ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval)
ibit = -1;
while (interval != 0)
{
ibit++;
interval >>= 1;
ibit++;
interval >>= 1;
}
/* only allow up to 32768 - i.e. ibit == 15, so limit it */
if (ibit > 15) ibit = 15;
/* if interval specified is the same as interval set, return true without wasting time */
if (poller->ibit == ibit)
return EINA_TRUE;
pollers[poller->ibit] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
pollers[poller->ibit] = (Ecore_Poller *)eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
poller->ibit = ibit;
pollers[poller->ibit] = (Ecore_Poller *) eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
pollers[poller->ibit] = (Ecore_Poller *)eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
if (poller_walking)
just_added_poller++;
else
@ -366,15 +368,15 @@ ecore_poller_poller_interval_get(Ecore_Poller *poller)
if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER))
{
ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
"ecore_poller_poller_interval_get");
"ecore_poller_poller_interval_get");
return 0;
}
ibit = poller->ibit;
while (ibit != 0)
{
ibit--;
interval <<= 1;
ibit--;
interval <<= 1;
}
return interval;
}
@ -396,7 +398,7 @@ ecore_poller_del(Ecore_Poller *poller)
if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER))
{
ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
"ecore_poller_del");
"ecore_poller_del");
return NULL;
}
/* we are walking the poller list - a bad idea to remove from it while
@ -410,7 +412,7 @@ ecore_poller_del(Ecore_Poller *poller)
}
/* not in loop so safe - delete immediately */
data = poller->data;
pollers[poller->ibit] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
pollers[poller->ibit] = (Ecore_Poller *)eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
free(poller);
_ecore_poller_next_tick_eval();
return data;
@ -430,8 +432,9 @@ _ecore_poller_shutdown(void)
{
while ((poller = pollers[i]))
{
pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i]));
pollers[i] = (Ecore_Poller *)eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i]));
free(poller);
}
}
}

View File

@ -3,7 +3,7 @@
#include <assert.h>
extern int _ecore_log_dom ;
extern int _ecore_log_dom;
#ifdef _ECORE_DEFAULT_LOG_DOM
# undef _ECORE_DEFAULT_LOG_DOM
#endif
@ -44,155 +44,172 @@ extern int _ecore_log_dom ;
#endif
#ifndef MIN
# define MIN(x, y) (((x) > (y)) ? (y) : (x))
# define MIN(x, y) (((x) > (y)) ? (y) : (x))
#endif
#ifndef MAX
# define MAX(x, y) (((x) > (y)) ? (x) : (y))
# define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
#ifndef ABS
# define ABS(x) ((x) < 0 ? -(x) : (x))
# define ABS(x) ((x) < 0 ? -(x) : (x))
#endif
#ifndef CLAMP
# define CLAMP(x, min, max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
#endif
#define EVAS_FRAME_QUEUING 1 /* for test */
#define EVAS_FRAME_QUEUING 1 /* for test */
#define READBUFSIZ 65536
#define READBUFSIZ 65536
#define ECORE_MAGIC_NONE 0x1234fedc
#define ECORE_MAGIC_EXE 0xf7e812f5
#define ECORE_MAGIC_TIMER 0xf7d713f4
#define ECORE_MAGIC_IDLER 0xf7c614f3
#define ECORE_MAGIC_IDLE_ENTERER 0xf7b515f2
#define ECORE_MAGIC_IDLE_EXITER 0xf7601afd
#define ECORE_MAGIC_FD_HANDLER 0xf7a416f1
#define ECORE_MAGIC_EVENT_HANDLER 0xf79317f0
#define ECORE_MAGIC_EVENT_FILTER 0xf78218ff
#define ECORE_MAGIC_EVENT 0xf77119fe
#define ECORE_MAGIC_ANIMATOR 0xf7643ea5
#define ECORE_MAGIC_POLLER 0xf7568127
#define ECORE_MAGIC_PIPE 0xf7458226
#define ECORE_MAGIC_WIN32_HANDLER 0xf7e8f1a3
#define ECORE_MAGIC_JOB 0x76543210
#define ECORE_MAGIC_NONE 0x1234fedc
#define ECORE_MAGIC_EXE 0xf7e812f5
#define ECORE_MAGIC_TIMER 0xf7d713f4
#define ECORE_MAGIC_IDLER 0xf7c614f3
#define ECORE_MAGIC_IDLE_ENTERER 0xf7b515f2
#define ECORE_MAGIC_IDLE_EXITER 0xf7601afd
#define ECORE_MAGIC_FD_HANDLER 0xf7a416f1
#define ECORE_MAGIC_EVENT_HANDLER 0xf79317f0
#define ECORE_MAGIC_EVENT_FILTER 0xf78218ff
#define ECORE_MAGIC_EVENT 0xf77119fe
#define ECORE_MAGIC_ANIMATOR 0xf7643ea5
#define ECORE_MAGIC_POLLER 0xf7568127
#define ECORE_MAGIC_PIPE 0xf7458226
#define ECORE_MAGIC_WIN32_HANDLER 0xf7e8f1a3
#define ECORE_MAGIC_JOB 0x76543210
#define ECORE_MAGIC Ecore_Magic __magic
#define ECORE_MAGIC Ecore_Magic __magic
#define ECORE_MAGIC_SET(d, m) (d)->__magic = (m)
#define ECORE_MAGIC_CHECK(d, m) ((d) && ((d)->__magic == (m)))
#define ECORE_MAGIC_FAIL(d, m, fn) _ecore_magic_fail((d), (d) ? (d)->__magic : 0, (m), (fn));
#define ECORE_MAGIC_SET(d, m) (d)->__magic = (m)
#define ECORE_MAGIC_CHECK(d, m) ((d) && ((d)->__magic == (m)))
#define ECORE_MAGIC_FAIL(d, m, fn) _ecore_magic_fail((d), (d) ? (d)->__magic : 0, (m), (fn));
/* undef the following, we want our version */
#undef FREE
#define FREE(ptr) free(ptr); ptr = NULL;
#define FREE(ptr) free(ptr); ptr = NULL;
#undef IF_FREE
#define IF_FREE(ptr) if (ptr) free(ptr); ptr = NULL;
#define IF_FREE(ptr) if (ptr) free(ptr); ptr = NULL;
#undef IF_FN_DEL
#define IF_FN_DEL(_fn, ptr) if (ptr) { _fn(ptr); ptr = NULL; }
#define IF_FN_DEL(_fn, ptr) if (ptr) { _fn(ptr); ptr = NULL; }
EAPI void ecore_print_warning(const char *function, const char *sparam);
EAPI void
ecore_print_warning(const char *function,
const char *sparam);
/* convenience macros for checking pointer parameters for non-NULL */
#undef CHECK_PARAM_POINTER_RETURN
#define CHECK_PARAM_POINTER_RETURN(sparam, param, ret) \
if (!(param)) \
{ \
ecore_print_warning(__FUNCTION__, sparam); \
return ret; \
}
if (!(param)) \
{ \
ecore_print_warning(__FUNCTION__, sparam); \
return ret; \
}
#undef CHECK_PARAM_POINTER
#define CHECK_PARAM_POINTER(sparam, param) \
if (!(param)) \
{ \
ecore_print_warning(__FUNCTION__, sparam); \
return; \
}
#define CHECK_PARAM_POINTER(sparam, param) \
if (!(param)) \
{ \
ecore_print_warning(__FUNCTION__, sparam); \
return; \
}
typedef unsigned int Ecore_Magic;
typedef unsigned int Ecore_Magic;
EAPI void _ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *fname);
EAPI void _ecore_magic_fail(const void *d,
Ecore_Magic m,
Ecore_Magic req_m,
const char *fname);
void _ecore_time_init(void);
void _ecore_time_init(void);
Ecore_Timer *_ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data);
void *_ecore_timer_del(Ecore_Timer *timer);
void _ecore_timer_delay(Ecore_Timer *timer, double add);
void _ecore_timer_shutdown(void);
void _ecore_timer_cleanup(void);
void _ecore_timer_enable_new(void);
double _ecore_timer_next_get(void);
void _ecore_timer_expired_timers_call(double when);
int _ecore_timers_exists(void);
Ecore_Timer *_ecore_timer_loop_add(double in,
Ecore_Task_Cb func,
const void *data);
void *_ecore_timer_del(Ecore_Timer *timer);
void _ecore_timer_delay(Ecore_Timer *timer,
double add);
void _ecore_timer_shutdown(void);
void _ecore_timer_cleanup(void);
void _ecore_timer_enable_new(void);
double _ecore_timer_next_get(void);
void _ecore_timer_expired_timers_call(double when);
int _ecore_timers_exists(void);
int _ecore_timer_expired_call(double when);
int _ecore_timer_expired_call(double when);
void _ecore_idler_shutdown(void);
int _ecore_idler_all_call(void);
int _ecore_idler_exist(void);
void _ecore_idler_shutdown(void);
int _ecore_idler_all_call(void);
int _ecore_idler_exist(void);
void _ecore_idle_enterer_shutdown(void);
void _ecore_idle_enterer_call(void);
int _ecore_idle_enterer_exist(void);
void _ecore_idle_enterer_shutdown(void);
void _ecore_idle_enterer_call(void);
int _ecore_idle_enterer_exist(void);
void _ecore_idle_exiter_shutdown(void);
void _ecore_idle_exiter_call(void);
int _ecore_idle_exiter_exist(void);
void _ecore_idle_exiter_shutdown(void);
void _ecore_idle_exiter_call(void);
int _ecore_idle_exiter_exist(void);
void _ecore_event_shutdown(void);
int _ecore_event_exist(void);
Ecore_Event *_ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data);
void _ecore_event_call(void);
void *_ecore_event_handler_del(Ecore_Event_Handler *event_handler);
void _ecore_event_shutdown(void);
int _ecore_event_exist(void);
Ecore_Event *_ecore_event_add(int type,
void *ev,
Ecore_End_Cb func_free,
void *data);
void _ecore_event_call(void);
void *_ecore_event_handler_del(Ecore_Event_Handler *event_handler);
Ecore_Timer *_ecore_exe_doomsday_clock_get(Ecore_Exe *exe);
void _ecore_exe_doomsday_clock_set(Ecore_Exe *exe, Ecore_Timer *dc);
Ecore_Timer *_ecore_exe_doomsday_clock_get(Ecore_Exe *exe);
void _ecore_exe_doomsday_clock_set(Ecore_Exe *exe,
Ecore_Timer *dc);
EAPI void *_ecore_event_signal_user_new(void);
void *_ecore_event_signal_hup_new(void);
void *_ecore_event_signal_exit_new(void);
void *_ecore_event_signal_power_new(void);
void *_ecore_event_signal_realtime_new(void);
EAPI void *_ecore_event_signal_user_new(void);
void *_ecore_event_signal_hup_new(void);
void *_ecore_event_signal_exit_new(void);
void *_ecore_event_signal_power_new(void);
void *_ecore_event_signal_realtime_new(void);
void *_ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
void *_ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
void _ecore_main_shutdown(void);
void _ecore_main_shutdown(void);
#if defined (_WIN32) || defined (__lv2ppu__)
static inline void _ecore_signal_shutdown(void) { }
static inline void _ecore_signal_init(void) { }
static inline void _ecore_signal_received_process(void) { }
static inline int _ecore_signal_count_get(void) { return 0; }
static inline int _ecore_signal_count_get(void) { return 0; }
static inline void _ecore_signal_call(void) { }
#else
void _ecore_signal_shutdown(void);
void _ecore_signal_init(void);
void _ecore_signal_received_process(void);
int _ecore_signal_count_get(void);
void _ecore_signal_call(void);
void _ecore_signal_shutdown(void);
void _ecore_signal_init(void);
void _ecore_signal_received_process(void);
int _ecore_signal_count_get(void);
void _ecore_signal_call(void);
#endif
void _ecore_exe_init(void);
void _ecore_exe_shutdown(void);
void _ecore_exe_init(void);
void _ecore_exe_shutdown(void);
#ifndef _WIN32
Ecore_Exe *_ecore_exe_find(pid_t pid);
void *_ecore_exe_event_del_new(void);
void _ecore_exe_event_del_free(void *data, void *ev);
Ecore_Exe *_ecore_exe_find(pid_t pid);
void *_ecore_exe_event_del_new(void);
void _ecore_exe_event_del_free(void *data,
void *ev);
#endif
void _ecore_animator_shutdown(void);
void _ecore_animator_shutdown(void);
void _ecore_poller_shutdown(void);
void _ecore_poller_shutdown(void);
void _ecore_fps_debug_init(void);
void _ecore_fps_debug_shutdown(void);
void _ecore_fps_debug_runtime_add(double t);
void _ecore_fps_debug_init(void);
void _ecore_fps_debug_shutdown(void);
void _ecore_fps_debug_runtime_add(double t);
void _ecore_thread_init(void);
void _ecore_thread_shutdown(void);
@ -238,7 +255,8 @@ _ecore_unlock(void)
* Callback wrappers all assume that ecore _ecore_lock has been called
*/
static inline Eina_Bool
_ecore_call_task_cb(Ecore_Task_Cb func, void *data)
_ecore_call_task_cb(Ecore_Task_Cb func,
void *data)
{
Eina_Bool r;
@ -250,7 +268,8 @@ _ecore_call_task_cb(Ecore_Task_Cb func, void *data)
}
static inline void *
_ecore_call_data_cb(Ecore_Data_Cb func, void *data)
_ecore_call_data_cb(Ecore_Data_Cb func,
void *data)
{
void *r;
@ -262,7 +281,9 @@ _ecore_call_data_cb(Ecore_Data_Cb func, void *data)
}
static inline void
_ecore_call_end_cb(Ecore_End_Cb func, void *user_data, void *func_data)
_ecore_call_end_cb(Ecore_End_Cb func,
void *user_data,
void *func_data)
{
_ecore_unlock();
func(user_data, func_data);
@ -270,8 +291,11 @@ _ecore_call_end_cb(Ecore_End_Cb func, void *user_data, void *func_data)
}
static inline Eina_Bool
_ecore_call_filter_cb(Ecore_Filter_Cb func, void *data,
void *loop_data, int type, void *event)
_ecore_call_filter_cb(Ecore_Filter_Cb func,
void *data,
void *loop_data,
int type,
void *event)
{
Eina_Bool r;
@ -283,7 +307,10 @@ _ecore_call_filter_cb(Ecore_Filter_Cb func, void *data,
}
static inline Eina_Bool
_ecore_call_handler_cb(Ecore_Event_Handler_Cb func, void *data, int type, void *event)
_ecore_call_handler_cb(Ecore_Event_Handler_Cb func,
void *data,
int type,
void *event)
{
Eina_Bool r;
@ -295,7 +322,9 @@ _ecore_call_handler_cb(Ecore_Event_Handler_Cb func, void *data, int type, void *
}
static inline void
_ecore_call_prep_cb(Ecore_Fd_Prep_Cb func, void *data, Ecore_Fd_Handler *fd_handler)
_ecore_call_prep_cb(Ecore_Fd_Prep_Cb func,
void *data,
Ecore_Fd_Handler *fd_handler)
{
_ecore_unlock();
func(data, fd_handler);
@ -303,7 +332,9 @@ _ecore_call_prep_cb(Ecore_Fd_Prep_Cb func, void *data, Ecore_Fd_Handler *fd_hand
}
static inline Eina_Bool
_ecore_call_fd_cb(Ecore_Fd_Cb func, void *data, Ecore_Fd_Handler *fd_handler)
_ecore_call_fd_cb(Ecore_Fd_Cb func,
void *data,
Ecore_Fd_Handler *fd_handler)
{
Eina_Bool r;
@ -314,7 +345,7 @@ _ecore_call_fd_cb(Ecore_Fd_Cb func, void *data, Ecore_Fd_Handler *fd_handler)
return r;
}
extern int _ecore_fps_debug;
extern int _ecore_fps_debug;
extern double _ecore_time_loop_time;
extern Eina_Bool _ecore_glib_always_integrate;
extern Ecore_Select_Function main_loop_select;

View File

@ -18,17 +18,36 @@
typedef void (*Signal_Handler)(int sig, siginfo_t *si, void *foo);
static void _ecore_signal_callback_set(int sig, Signal_Handler func);
static void _ecore_signal_callback_ignore(int sig, siginfo_t *si, void *foo);
static void _ecore_signal_callback_sigchld(int sig, siginfo_t *si, void *foo);
static void _ecore_signal_callback_sigusr1(int sig, siginfo_t *si, void *foo);
static void _ecore_signal_callback_sigusr2(int sig, siginfo_t *si, void *foo);
static void _ecore_signal_callback_sighup(int sig, siginfo_t *si, void *foo);
static void _ecore_signal_callback_sigquit(int sig, siginfo_t *si, void *foo);
static void _ecore_signal_callback_sigint(int sig, siginfo_t *si, void *foo);
static void _ecore_signal_callback_sigterm(int sig, siginfo_t *si, void *foo);
static void _ecore_signal_callback_set(int sig,
Signal_Handler func);
static void _ecore_signal_callback_ignore(int sig,
siginfo_t *si,
void *foo);
static void _ecore_signal_callback_sigchld(int sig,
siginfo_t *si,
void *foo);
static void _ecore_signal_callback_sigusr1(int sig,
siginfo_t *si,
void *foo);
static void _ecore_signal_callback_sigusr2(int sig,
siginfo_t *si,
void *foo);
static void _ecore_signal_callback_sighup(int sig,
siginfo_t *si,
void *foo);
static void _ecore_signal_callback_sigquit(int sig,
siginfo_t *si,
void *foo);
static void _ecore_signal_callback_sigint(int sig,
siginfo_t *si,
void *foo);
static void _ecore_signal_callback_sigterm(int sig,
siginfo_t *si,
void *foo);
#ifdef SIGPWR
static void _ecore_signal_callback_sigpwr(int sig, siginfo_t *si, void *foo);
static void _ecore_signal_callback_sigpwr(int sig,
siginfo_t *si,
void *foo);
#endif
static Eina_Bool _ecore_signal_exe_exit_delay(void *data);
@ -62,17 +81,17 @@ static volatile siginfo_t sigpwr_info[MAXSIGQ];
void
_ecore_signal_shutdown(void)
{
_ecore_signal_callback_set(SIGPIPE, (Signal_Handler) SIG_DFL);
_ecore_signal_callback_set(SIGALRM, (Signal_Handler) SIG_DFL);
_ecore_signal_callback_set(SIGCHLD, (Signal_Handler) SIG_DFL);
_ecore_signal_callback_set(SIGUSR1, (Signal_Handler) SIG_DFL);
_ecore_signal_callback_set(SIGUSR2, (Signal_Handler) SIG_DFL);
_ecore_signal_callback_set(SIGHUP, (Signal_Handler) SIG_DFL);
_ecore_signal_callback_set(SIGQUIT, (Signal_Handler) SIG_DFL);
_ecore_signal_callback_set(SIGINT, (Signal_Handler) SIG_DFL);
_ecore_signal_callback_set(SIGTERM, (Signal_Handler) SIG_DFL);
_ecore_signal_callback_set(SIGPIPE, (Signal_Handler)SIG_DFL);
_ecore_signal_callback_set(SIGALRM, (Signal_Handler)SIG_DFL);
_ecore_signal_callback_set(SIGCHLD, (Signal_Handler)SIG_DFL);
_ecore_signal_callback_set(SIGUSR1, (Signal_Handler)SIG_DFL);
_ecore_signal_callback_set(SIGUSR2, (Signal_Handler)SIG_DFL);
_ecore_signal_callback_set(SIGHUP, (Signal_Handler)SIG_DFL);
_ecore_signal_callback_set(SIGQUIT, (Signal_Handler)SIG_DFL);
_ecore_signal_callback_set(SIGINT, (Signal_Handler)SIG_DFL);
_ecore_signal_callback_set(SIGTERM, (Signal_Handler)SIG_DFL);
#ifdef SIGPWR
_ecore_signal_callback_set(SIGPWR, (Signal_Handler) SIG_DFL);
_ecore_signal_callback_set(SIGPWR, (Signal_Handler)SIG_DFL);
sigpwr_count = 0;
#endif
sigchld_count = 0;
@ -83,7 +102,6 @@ _ecore_signal_shutdown(void)
sigint_count = 0;
sigterm_count = 0;
sig_count = 0;
}
void
@ -94,12 +112,12 @@ _ecore_signal_init(void)
_ecore_signal_callback_set(SIGCHLD, _ecore_signal_callback_sigchld);
_ecore_signal_callback_set(SIGUSR1, _ecore_signal_callback_sigusr1);
_ecore_signal_callback_set(SIGUSR2, _ecore_signal_callback_sigusr2);
_ecore_signal_callback_set(SIGHUP, _ecore_signal_callback_sighup);
_ecore_signal_callback_set(SIGHUP, _ecore_signal_callback_sighup);
_ecore_signal_callback_set(SIGQUIT, _ecore_signal_callback_sigquit);
_ecore_signal_callback_set(SIGINT, _ecore_signal_callback_sigint);
_ecore_signal_callback_set(SIGINT, _ecore_signal_callback_sigint);
_ecore_signal_callback_set(SIGTERM, _ecore_signal_callback_sigterm);
#ifdef SIGPWR
_ecore_signal_callback_set(SIGPWR, _ecore_signal_callback_sigpwr);
_ecore_signal_callback_set(SIGPWR, _ecore_signal_callback_sigpwr);
#endif
}
@ -138,7 +156,7 @@ _ecore_signal_call(void)
sigprocmask(SIG_BLOCK, &newset, &oldset);
if (sigchld_count > MAXSIGQ)
WRN("%i SIGCHLD in queue. max queue size %i. losing "
"siginfo for extra signals.", sigchld_count, MAXSIGQ);
"siginfo for extra signals.", sigchld_count, MAXSIGQ);
for (n = 0; n < sigchld_count; n++)
{
pid_t pid;
@ -168,46 +186,46 @@ _ecore_signal_call(void)
e->exe = _ecore_exe_find(pid);
if ((n < MAXSIGQ) && (sigchld_info[n].si_signo))
e->data = sigchld_info[n]; /* No need to clone this. */
e->data = sigchld_info[n]; /* No need to clone this. */
if ((e->exe) && (ecore_exe_flags_get(e->exe) & (ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR)))
{
/* We want to report the Last Words of the exe, so delay this event.
* This is twice as relevant for stderr.
* There are three possibilities here -
* 1 There are no Last Words.
* 2 There are Last Words, they are not ready to be read.
* 3 There are Last Words, they are ready to be read.
*
* For 1 we don't want to delay, for 3 we want to delay.
* 2 is the problem. If we check for data now and there
* is none, then there is no way to differentiate 1 and 2.
* If we don't delay, we may loose data, but if we do delay,
* there may not be data and the exit event never gets sent.
*
* Any way you look at it, there has to be some time passed
* before the exit event gets sent. So the strategy here is
* to setup a timer event that will send the exit event after
* an arbitrary, but brief, time.
*
* This is probably paranoid, for the less paraniod, we could
* check to see for Last Words, and only delay if there are any.
* This has it's own set of problems.
*/
Ecore_Timer *doomsday_clock;
{
/* We want to report the Last Words of the exe, so delay this event.
* This is twice as relevant for stderr.
* There are three possibilities here -
* 1 There are no Last Words.
* 2 There are Last Words, they are not ready to be read.
* 3 There are Last Words, they are ready to be read.
*
* For 1 we don't want to delay, for 3 we want to delay.
* 2 is the problem. If we check for data now and there
* is none, then there is no way to differentiate 1 and 2.
* If we don't delay, we may loose data, but if we do delay,
* there may not be data and the exit event never gets sent.
*
* Any way you look at it, there has to be some time passed
* before the exit event gets sent. So the strategy here is
* to setup a timer event that will send the exit event after
* an arbitrary, but brief, time.
*
* This is probably paranoid, for the less paraniod, we could
* check to see for Last Words, and only delay if there are any.
* This has it's own set of problems.
*/
Ecore_Timer *doomsday_clock;
doomsday_clock = _ecore_exe_doomsday_clock_get(e->exe);
IF_FN_DEL(ecore_timer_del, doomsday_clock);
_ecore_unlock();
doomsday_clock = ecore_timer_add
(0.1, _ecore_signal_exe_exit_delay, e);
_ecore_lock();
_ecore_exe_doomsday_clock_set(e->exe, doomsday_clock);
}
doomsday_clock = _ecore_exe_doomsday_clock_get(e->exe);
IF_FN_DEL(ecore_timer_del, doomsday_clock);
_ecore_unlock();
doomsday_clock = ecore_timer_add
(0.1, _ecore_signal_exe_exit_delay, e);
_ecore_lock();
_ecore_exe_doomsday_clock_set(e->exe, doomsday_clock);
}
else
{
_ecore_event_add(ECORE_EXE_EVENT_DEL, e,
_ecore_exe_event_del_free, NULL);
_ecore_exe_event_del_free, NULL);
}
}
}
@ -364,9 +382,10 @@ _ecore_signal_call(void)
}
static void
_ecore_signal_callback_set(int sig, Signal_Handler func)
_ecore_signal_callback_set(int sig,
Signal_Handler func)
{
struct sigaction sa;
struct sigaction sa;
sa.sa_sigaction = func;
sa.sa_flags = SA_RESTART | SA_SIGINFO;
@ -375,12 +394,16 @@ _ecore_signal_callback_set(int sig, Signal_Handler func)
}
static void
_ecore_signal_callback_ignore(int sig __UNUSED__, siginfo_t *si __UNUSED__, void *foo __UNUSED__)
_ecore_signal_callback_ignore(int sig __UNUSED__,
siginfo_t *si __UNUSED__,
void *foo __UNUSED__)
{
}
static void
_ecore_signal_callback_sigchld(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
_ecore_signal_callback_sigchld(int sig __UNUSED__,
siginfo_t *si,
void *foo __UNUSED__)
{
volatile sig_atomic_t n;
n = sigchld_count;
@ -397,7 +420,9 @@ _ecore_signal_callback_sigchld(int sig __UNUSED__, siginfo_t *si, void *foo __UN
}
static void
_ecore_signal_callback_sigusr1(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
_ecore_signal_callback_sigusr1(int sig __UNUSED__,
siginfo_t *si,
void *foo __UNUSED__)
{
volatile sig_atomic_t n;
n = sigusr1_count;
@ -413,7 +438,9 @@ _ecore_signal_callback_sigusr1(int sig __UNUSED__, siginfo_t *si, void *foo __UN
}
static void
_ecore_signal_callback_sigusr2(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
_ecore_signal_callback_sigusr2(int sig __UNUSED__,
siginfo_t *si,
void *foo __UNUSED__)
{
volatile sig_atomic_t n;
n = sigusr2_count;
@ -429,7 +456,9 @@ _ecore_signal_callback_sigusr2(int sig __UNUSED__, siginfo_t *si, void *foo __UN
}
static void
_ecore_signal_callback_sighup(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
_ecore_signal_callback_sighup(int sig __UNUSED__,
siginfo_t *si,
void *foo __UNUSED__)
{
volatile sig_atomic_t n;
n = sighup_count;
@ -445,7 +474,9 @@ _ecore_signal_callback_sighup(int sig __UNUSED__, siginfo_t *si, void *foo __UNU
}
static void
_ecore_signal_callback_sigquit(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
_ecore_signal_callback_sigquit(int sig __UNUSED__,
siginfo_t *si,
void *foo __UNUSED__)
{
volatile sig_atomic_t n;
n = sigquit_count;
@ -461,7 +492,9 @@ _ecore_signal_callback_sigquit(int sig __UNUSED__, siginfo_t *si, void *foo __UN
}
static void
_ecore_signal_callback_sigint(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
_ecore_signal_callback_sigint(int sig __UNUSED__,
siginfo_t *si,
void *foo __UNUSED__)
{
volatile sig_atomic_t n;
n = sigint_count;
@ -477,7 +510,9 @@ _ecore_signal_callback_sigint(int sig __UNUSED__, siginfo_t *si, void *foo __UNU
}
static void
_ecore_signal_callback_sigterm(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
_ecore_signal_callback_sigterm(int sig __UNUSED__,
siginfo_t *si,
void *foo __UNUSED__)
{
volatile sig_atomic_t n;
n = sigterm_count;
@ -494,7 +529,9 @@ _ecore_signal_callback_sigterm(int sig __UNUSED__, siginfo_t *si, void *foo __UN
#ifdef SIGPWR
static void
_ecore_signal_callback_sigpwr(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__)
_ecore_signal_callback_sigpwr(int sig __UNUSED__,
siginfo_t *si,
void *foo __UNUSED__)
{
volatile sig_atomic_t n;
n = sigpwr_count;
@ -508,6 +545,7 @@ _ecore_signal_callback_sigpwr(int sig __UNUSED__, siginfo_t *si, void *foo __UNU
sigpwr_count++;
sig_count++;
}
#endif
static Eina_Bool
@ -524,3 +562,4 @@ _ecore_signal_exe_exit_delay(void *data)
}
return ECORE_CALLBACK_CANCEL;
}

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ static int throttle_val = 0;
/**
* Increase throttle amount
*
*
* This will increase or decrease (if @p amount is positive or negative) the
* amount of "voluntary throttling" ecore will do to its main loop while
* running. This is intended to be used to limit animations and wakeups when
@ -26,7 +26,7 @@ static int throttle_val = 0;
* (which can be retrieved by ecore_throttle_get() ), the more throttling
* takes place. If the current throttle value is 0, then no throttling takes
* place at all.
*
*
* The value represents how long the ecore main loop will sleep (in seconds)
* before it goes into a fully idle state waiting for events, input or
* timing events to wake it up. For example, if the current throttle level
@ -37,30 +37,30 @@ static int throttle_val = 0;
* of time. Of course these events, data and timeouts will be buffered,
* thus not losing anything, simply delaying when they get handled by the
* throttle value.
*
*
* Example:
* @code
* void enter_powersave(void) {
* ecore_throttle_adjust(0.2);
* printf("Now at throttle level: %1.3f\n", ecore_throttle_get());
* }
*
*
* void enter_deep_powersave(void) {
* ecore_throttle_adjust(0.5);
* printf("Now at throttle level: %1.3f\n", ecore_throttle_get());
* }
*
*
* void exit_powersave(void) {
* ecore_throttle_adjust(-0.2);
* printf("Now at throttle level: %1.3f\n", ecore_throttle_get());
* }
*
*
* void exit_deep_powersave(void) {
* ecore_throttle_adjust(-0.5);
* printf("Now at throttle level: %1.3f\n", ecore_throttle_get());
* }
* @endcode
*
*
* @param amount Amount (in seconds) to adjust by
*/
EAPI void
@ -73,11 +73,11 @@ ecore_throttle_adjust(double amount)
/**
* Get current throttle level
*
* This gets the current throttling level, which can be adjusted by
*
* This gets the current throttling level, which can be adjusted by
* ecore_throttle_adjust(). The value is in seconds. Please see
* ecore_throttle_adjust() for more information.
*
*
* @return The current throttle level
*/
EAPI double
@ -96,3 +96,4 @@ _ecore_throttle(void)
if (throttle_val <= 0) return;
usleep(throttle_val);
}

View File

@ -56,7 +56,7 @@ ecore_time_get(void)
struct timespec t;
if (EINA_UNLIKELY(_ecore_time_clock_id < 0))
return ecore_time_unix_get();
return ecore_time_unix_get();
if (EINA_UNLIKELY(clock_gettime(_ecore_time_clock_id, &t)))
{
@ -69,7 +69,7 @@ ecore_time_get(void)
#elif defined(HAVE_EVIL)
return evil_time_get();
#elif defined(__APPLE__) && defined(__MACH__)
return _ecore_time_clock_conversion * (double) mach_absolute_time();
return _ecore_time_clock_conversion * (double)mach_absolute_time();
#else
return ecore_time_unix_get();
#endif
@ -127,7 +127,6 @@ ecore_loop_time_get(void)
* @}
*/
/********************** Internal methods ********************************/
/* TODO: Documentation says "All implementations support the system-wide
@ -150,8 +149,8 @@ _ecore_time_init(void)
else if (!clock_gettime(CLOCK_REALTIME, &t))
{
/* may go backwards */
_ecore_time_clock_id = CLOCK_REALTIME;
WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME.");
_ecore_time_clock_id = CLOCK_REALTIME;
WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME.");
}
else
{
@ -166,7 +165,7 @@ _ecore_time_init(void)
kern_return_t err = mach_timebase_info(&info);
if (err == 0)
{
_ecore_time_clock_conversion = 1e-9 * (double) info.numer / (double) info.denom;
_ecore_time_clock_conversion = 1e-9 * (double)info.numer / (double)info.denom;
}
else
{
@ -182,3 +181,4 @@ _ecore_time_init(void)
_ecore_time_loop_time = ecore_time_get();
}

View File

@ -12,42 +12,45 @@
# include <string.h>
# include <execinfo.h>
# define ECORE_TIMER_DEBUG_BT_NUM 64
typedef void (*Ecore_Timer_Bt_Func) ();
typedef void (*Ecore_Timer_Bt_Func)();
#endif
struct _Ecore_Timer
{
EINA_INLIST;
ECORE_MAGIC;
double in;
double at;
double pending;
Ecore_Task_Cb func;
void *data;
ECORE_MAGIC;
double in;
double at;
double pending;
Ecore_Task_Cb func;
void *data;
#ifdef WANT_ECORE_TIMER_DUMP
Ecore_Timer_Bt_Func timer_bt[ECORE_TIMER_DEBUG_BT_NUM];
int timer_bt_num;
#endif
int references;
unsigned char delete_me : 1;
unsigned char just_added : 1;
unsigned char frozen : 1;
int references;
unsigned char delete_me : 1;
unsigned char just_added : 1;
unsigned char frozen : 1;
};
static void _ecore_timer_set(Ecore_Timer *timer,
double at,
double in,
Ecore_Task_Cb func,
void *data);
static int _ecore_timer_cmp(const void *d1,
const void *d2);
static void _ecore_timer_set(Ecore_Timer *timer, double at, double in, Ecore_Task_Cb func, void *data);
static int _ecore_timer_cmp(const void *d1, const void *d2);
static int timers_added = 0;
static int timers_delete_me = 0;
static int timers_added = 0;
static int timers_delete_me = 0;
static Ecore_Timer *timers = NULL;
static Ecore_Timer *timer_current = NULL;
static Ecore_Timer *suspended = NULL;
static double last_check = 0.0;
static double precision = 10.0 / 1000000.0;
static double last_check = 0.0;
static double precision = 10.0 / 1000000.0;
/**
* @addtogroup Ecore_Time_Group
@ -125,7 +128,9 @@ unlock:
* invalid.
*/
EAPI Ecore_Timer *
ecore_timer_add(double in, Ecore_Task_Cb func, const void *data)
ecore_timer_add(double in,
Ecore_Task_Cb func,
const void *data)
{
double now;
Ecore_Timer *timer = NULL;
@ -139,7 +144,7 @@ ecore_timer_add(double in, Ecore_Task_Cb func, const void *data)
now = ecore_time_get();
#ifdef WANT_ECORE_TIMER_DUMP
timer->timer_bt_num = backtrace((void**) (timer->timer_bt),
timer->timer_bt_num = backtrace((void **)(timer->timer_bt),
ECORE_TIMER_DEBUG_BT_NUM);
#endif
@ -162,7 +167,9 @@ unlock:
* ecore_timer_add() for more details.
*/
EAPI Ecore_Timer *
ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data)
ecore_timer_loop_add(double in,
Ecore_Task_Cb func,
const void *data)
{
Ecore_Timer *timer;
@ -211,7 +218,8 @@ unlock:
* @param in The interval in seconds.
*/
EAPI void
ecore_timer_interval_set(Ecore_Timer *timer, double in)
ecore_timer_interval_set(Ecore_Timer *timer,
double in)
{
_ecore_lock();
@ -261,7 +269,8 @@ unlock:
* @param add The dalay to add to the next iteration.
*/
EAPI void
ecore_timer_delay(Ecore_Timer *timer, double add)
ecore_timer_delay(Ecore_Timer *timer,
double add)
{
if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
{
@ -284,8 +293,8 @@ ecore_timer_delay(Ecore_Timer *timer, double add)
EAPI double
ecore_timer_pending_get(Ecore_Timer *timer)
{
double now;
double ret = 0.0;
double now;
double ret = 0.0;
_ecore_lock();
@ -339,8 +348,8 @@ ecore_timer_freeze(Ecore_Timer *timer)
if (timer->frozen)
goto unlock;
timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
suspended = (Ecore_Timer *) eina_inlist_prepend(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
suspended = (Ecore_Timer *)eina_inlist_prepend(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
now = ecore_time_get();
@ -382,7 +391,7 @@ ecore_timer_thaw(Ecore_Timer *timer)
if (!timer->frozen)
goto unlock;
suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
now = ecore_time_get();
_ecore_timer_set(timer, timer->pending + now, timer->in, timer->func, timer->data);
@ -412,15 +421,15 @@ ecore_timer_dump(void)
char **strings;
int j;
if (!tm->frozen && !tm->delete_me)
living_timer++;
if (!tm->frozen && !tm->delete_me)
living_timer++;
strings = backtrace_symbols((void**) tm->timer_bt, tm->timer_bt_num);
strings = backtrace_symbols((void **)tm->timer_bt, tm->timer_bt_num);
if (tm->timer_bt_num <= 0 || strings == NULL)
{
unknow_timer++;
continue ;
}
{
unknow_timer++;
continue;
}
eina_strbuf_append_printf(result, "*** timer: %f ***\n", tm->in);
if (tm->frozen)
@ -450,7 +459,9 @@ ecore_timer_dump(void)
*/
Ecore_Timer *
_ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data)
_ecore_timer_loop_add(double in,
Ecore_Task_Cb func,
const void *data)
{
double now;
Ecore_Timer *timer = NULL;
@ -463,7 +474,7 @@ _ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data)
now = ecore_loop_time_get();
#ifdef WANT_ECORE_TIMER_DUMP
timer->timer_bt_num = backtrace((void**) (timer->timer_bt),
timer->timer_bt_num = backtrace((void **)(timer->timer_bt),
ECORE_TIMER_DEBUG_BT_NUM);
#endif
_ecore_timer_set(timer, now + in, in, func, (void *)data);
@ -471,7 +482,8 @@ _ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data)
}
EAPI void
_ecore_timer_delay(Ecore_Timer *timer, double add)
_ecore_timer_delay(Ecore_Timer *timer,
double add)
{
if (timer->frozen)
{
@ -479,12 +491,11 @@ _ecore_timer_delay(Ecore_Timer *timer, double add)
}
else
{
timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
_ecore_timer_set(timer, timer->at + add, timer->in, timer->func, timer->data);
}
}
void *
_ecore_timer_del(Ecore_Timer *timer)
{
@ -492,7 +503,7 @@ _ecore_timer_del(Ecore_Timer *timer)
{
void *data = timer->data;
suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
if (timer->delete_me)
timers_delete_me--;
@ -514,14 +525,14 @@ _ecore_timer_shutdown(void)
while ((timer = timers))
{
timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timers));
timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timers));
ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
free(timer);
}
while ((timer = suspended))
{
suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(suspended));
suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(suspended));
ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
free(timer);
}
@ -536,11 +547,11 @@ _ecore_timer_cleanup(void)
int in_use = 0, todo = timers_delete_me, done = 0;
if (!timers_delete_me) return;
for (l = timers; l;)
for (l = timers; l; )
{
Ecore_Timer *timer = l;
l = (Ecore_Timer *) EINA_INLIST_GET(l)->next;
l = (Ecore_Timer *)EINA_INLIST_GET(l)->next;
if (timer->delete_me)
{
if (timer->references)
@ -548,7 +559,7 @@ _ecore_timer_cleanup(void)
in_use++;
continue;
}
timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
free(timer);
timers_delete_me--;
@ -556,11 +567,11 @@ _ecore_timer_cleanup(void)
if (timers_delete_me == 0) return;
}
}
for (l = suspended; l;)
for (l = suspended; l; )
{
Ecore_Timer *timer = l;
l = (Ecore_Timer *) EINA_INLIST_GET(l)->next;
l = (Ecore_Timer *)EINA_INLIST_GET(l)->next;
if (timer->delete_me)
{
if (timer->references)
@ -568,7 +579,7 @@ _ecore_timer_cleanup(void)
in_use++;
continue;
}
suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
free(timer);
timers_delete_me--;
@ -614,7 +625,7 @@ _ecore_timer_first_get(void)
Ecore_Timer *timer = timers;
while ((timer) && ((timer->delete_me) || (timer->just_added)))
timer = (Ecore_Timer *) EINA_INLIST_GET(timer)->next;
timer = (Ecore_Timer *)EINA_INLIST_GET(timer)->next;
return timer;
}
@ -622,15 +633,15 @@ _ecore_timer_first_get(void)
static inline Ecore_Timer *
_ecore_timer_after_get(Ecore_Timer *base)
{
Ecore_Timer *timer = (Ecore_Timer *) EINA_INLIST_GET(base)->next;
Ecore_Timer *timer = (Ecore_Timer *)EINA_INLIST_GET(base)->next;
Ecore_Timer *valid_timer = NULL;
double maxtime = base->at + precision;
while ((timer) && (timer->at < maxtime))
{
if (!((timer->delete_me) || (timer->just_added)))
valid_timer = timer;
timer = (Ecore_Timer *) EINA_INLIST_GET(timer)->next;
valid_timer = timer;
timer = (Ecore_Timer *)EINA_INLIST_GET(timer)->next;
}
return valid_timer;
@ -656,11 +667,12 @@ _ecore_timer_next_get(void)
}
static inline void
_ecore_timer_reschedule(Ecore_Timer *timer, double when)
_ecore_timer_reschedule(Ecore_Timer *timer,
double when)
{
if ((timer->delete_me) || (timer->frozen)) return;
timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
/* if the timer would have gone off more than 15 seconds ago,
* assume that the system hung and set the timer to go off
@ -682,7 +694,7 @@ void
_ecore_timer_expired_timers_call(double when)
{
/* call the first expired timer until no expired timers exist */
while (_ecore_timer_expired_call(when));
while (_ecore_timer_expired_call(when)) ;
}
/* assume that we hold the ecore lock when entering this function */
@ -701,14 +713,14 @@ _ecore_timer_expired_call(double when)
if (!timer_current)
{
/* regular main loop, start from head */
timer_current = timers;
timer_current = timers;
}
else
{
/* recursive main loop, continue from where we were */
Ecore_Timer *timer_old = timer_current;
timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next;
_ecore_timer_reschedule(timer_old, when);
Ecore_Timer *timer_old = timer_current;
timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next;
_ecore_timer_reschedule(timer_old, when);
}
while (timer_current)
@ -723,7 +735,7 @@ _ecore_timer_expired_call(double when)
if ((timer->just_added) || (timer->delete_me))
{
timer_current = (Ecore_Timer*)EINA_INLIST_GET(timer_current)->next;
timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next;
continue;
}
@ -743,7 +755,11 @@ _ecore_timer_expired_call(double when)
}
static void
_ecore_timer_set(Ecore_Timer *timer, double at, double in, Ecore_Task_Cb func, void *data)
_ecore_timer_set(Ecore_Timer *timer,
double at,
double in,
Ecore_Task_Cb func,
void *data)
{
Ecore_Timer *t2;
@ -761,19 +777,21 @@ _ecore_timer_set(Ecore_Timer *timer, double at, double in, Ecore_Task_Cb func, v
{
if (timer->at > t2->at)
{
timers = (Ecore_Timer *) eina_inlist_append_relative(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer), EINA_INLIST_GET(t2));
timers = (Ecore_Timer *)eina_inlist_append_relative(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer), EINA_INLIST_GET(t2));
return;
}
}
}
timers = (Ecore_Timer *) eina_inlist_prepend(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
timers = (Ecore_Timer *)eina_inlist_prepend(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
}
static int
_ecore_timer_cmp(const void *d1, const void *d2)
_ecore_timer_cmp(const void *d1,
const void *d2)
{
const Ecore_Timer *t1 = d1;
const Ecore_Timer *t2 = d2;
return (int) ((t1->in - t2->in) * 100);
return (int)((t1->in - t2->in) * 100);
}