forked from enlightenment/efl
Fix Windows compilation
Thanks to vtorri for his help on this delicate issue named Windows
This commit is contained in:
parent
897fc331ce
commit
c0eb231edb
|
@ -16,13 +16,27 @@
|
||||||
* if not, see <http://www.gnu.org/licenses/>.
|
* if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#ifdef HAVE_SYS_EPOLL_H
|
||||||
# include <sys/epoll.h>
|
# include <sys/epoll.h>
|
||||||
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
# include <sys/socket.h>
|
# include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_UN_H
|
||||||
# include <sys/un.h>
|
# include <sys/un.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_NETINET_IN_H
|
||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ARPA_INET_H
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "eina_debug_private.h"
|
#include "eina_debug_private.h"
|
||||||
|
|
||||||
|
@ -598,15 +612,12 @@ err:
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_server_launch()
|
_server_launch()
|
||||||
{
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
struct epoll_event event = {0};
|
struct epoll_event event = {0};
|
||||||
|
|
||||||
_epfd = epoll_create (MAX_EVENTS);
|
_epfd = epoll_create (MAX_EVENTS);
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
_listening_unix_fd = _listening_unix_socket_create();
|
_listening_unix_fd = _listening_unix_socket_create();
|
||||||
#else
|
|
||||||
_listening_unix_fd = -1;
|
|
||||||
#endif
|
|
||||||
if (_listening_unix_fd <= 0) goto err;
|
if (_listening_unix_fd <= 0) goto err;
|
||||||
event.data.fd = _listening_unix_fd;
|
event.data.fd = _listening_unix_fd;
|
||||||
event.events = EPOLLIN;
|
event.events = EPOLLIN;
|
||||||
|
@ -623,6 +634,7 @@ err:
|
||||||
_listening_unix_fd = -1;
|
_listening_unix_fd = -1;
|
||||||
if (_listening_tcp_fd >= 0) close(_listening_tcp_fd);
|
if (_listening_tcp_fd >= 0) close(_listening_tcp_fd);
|
||||||
_listening_tcp_fd = -1;
|
_listening_tcp_fd = -1;
|
||||||
|
#endif
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,18 @@
|
||||||
# define _GNU_SOURCE 1
|
# define _GNU_SOURCE 1
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#ifdef HAVE_SYS_EPOLL_H
|
||||||
# include <sys/epoll.h>
|
# include <sys/epoll.h>
|
||||||
|
#endif
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -34,12 +40,25 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
# include <sys/socket.h>
|
# include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_UN_H
|
||||||
# include <sys/un.h>
|
# include <sys/un.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_NETINET_IN_H
|
||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ARPA_INET_H
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# include <winsock2.h>
|
||||||
|
# include <Evil.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "eina_debug.h"
|
#include "eina_debug.h"
|
||||||
#include "eina_types.h"
|
#include "eina_types.h"
|
||||||
#include "eina_list.h"
|
#include "eina_list.h"
|
||||||
|
@ -50,7 +69,7 @@
|
||||||
#include "eina_stringshare.h"
|
#include "eina_stringshare.h"
|
||||||
#include "eina_debug_private.h"
|
#include "eina_debug_private.h"
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
#if defined(__CYGWIN__) || defined (_WIN32)
|
||||||
# define LIBEXT ".dll"
|
# define LIBEXT ".dll"
|
||||||
#else
|
#else
|
||||||
# define LIBEXT ".so"
|
# define LIBEXT ".so"
|
||||||
|
@ -107,7 +126,9 @@ struct _Eina_Debug_Session
|
||||||
int fd; /* File descriptor */
|
int fd; /* File descriptor */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
static void _opcodes_register_all(Eina_Debug_Session *session);
|
static void _opcodes_register_all(Eina_Debug_Session *session);
|
||||||
|
#endif
|
||||||
static void _thread_start(Eina_Debug_Session *session);
|
static void _thread_start(Eina_Debug_Session *session);
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
|
@ -130,10 +151,13 @@ eina_debug_session_send(Eina_Debug_Session *session, int dest, int op, void *dat
|
||||||
/* Sending payload */
|
/* Sending payload */
|
||||||
if (size) write(session->fd, data, size);
|
if (size) write(session->fd, data, size);
|
||||||
eina_spinlock_release(&_eina_debug_lock);
|
eina_spinlock_release(&_eina_debug_lock);
|
||||||
|
#else
|
||||||
|
(void)data;
|
||||||
#endif
|
#endif
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
static void
|
static void
|
||||||
_daemon_greet(Eina_Debug_Session *session)
|
_daemon_greet(Eina_Debug_Session *session)
|
||||||
{
|
{
|
||||||
|
@ -159,7 +183,6 @@ _daemon_greet(Eina_Debug_Session *session)
|
||||||
eina_debug_session_send(session, 0, EINA_DEBUG_OPCODE_HELLO, buf, size);
|
eina_debug_session_send(session, 0, EINA_DEBUG_OPCODE_HELLO, buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
static int
|
static int
|
||||||
_packet_receive(Eina_Debug_Session *session, unsigned char **buffer)
|
_packet_receive(Eina_Debug_Session *session, unsigned char **buffer)
|
||||||
{
|
{
|
||||||
|
@ -249,6 +272,7 @@ eina_debug_session_dispatch_get(Eina_Debug_Session *session)
|
||||||
else return NULL;
|
else return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
static void
|
static void
|
||||||
_static_opcode_register(Eina_Debug_Session *session,
|
_static_opcode_register(Eina_Debug_Session *session,
|
||||||
int op_id, Eina_Debug_Cb cb)
|
int op_id, Eina_Debug_Cb cb)
|
||||||
|
@ -305,6 +329,7 @@ _callbacks_register_cb(Eina_Debug_Session *session, int src_id EINA_UNUSED, void
|
||||||
|
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_opcodes_registration_send(Eina_Debug_Session *session,
|
_opcodes_registration_send(Eina_Debug_Session *session,
|
||||||
|
@ -323,7 +348,7 @@ _opcodes_registration_send(Eina_Debug_Session *session,
|
||||||
|
|
||||||
buf = malloc(size);
|
buf = malloc(size);
|
||||||
|
|
||||||
uint64_t info_64 = (uint64_t)info;
|
uint64_t info_64 = (uint64_t)(uintptr_t)info;
|
||||||
info_64 = SWAP_64(info_64);
|
info_64 = SWAP_64(info_64);
|
||||||
memcpy(buf, &info_64, sizeof(uint64_t));
|
memcpy(buf, &info_64, sizeof(uint64_t));
|
||||||
int size_curr = sizeof(uint64_t);
|
int size_curr = sizeof(uint64_t);
|
||||||
|
@ -341,6 +366,7 @@ _opcodes_registration_send(Eina_Debug_Session *session,
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
static void
|
static void
|
||||||
_opcodes_register_all(Eina_Debug_Session *session)
|
_opcodes_register_all(Eina_Debug_Session *session)
|
||||||
{
|
{
|
||||||
|
@ -389,7 +415,6 @@ _socket_home_get()
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
#define LENGTH_OF_SOCKADDR_UN(s) \
|
#define LENGTH_OF_SOCKADDR_UN(s) \
|
||||||
(strlen((s)->sun_path) + (size_t)(((struct sockaddr_un *)NULL)->sun_path))
|
(strlen((s)->sun_path) + (size_t)(((struct sockaddr_un *)NULL)->sun_path))
|
||||||
#endif
|
#endif
|
||||||
|
@ -485,6 +510,8 @@ err:
|
||||||
// even if the mainloop is blocked or the app otherwise deadlocked in some
|
// even if the mainloop is blocked or the app otherwise deadlocked in some
|
||||||
// way. this is an alternative to using external debuggers so we can get
|
// way. this is an alternative to using external debuggers so we can get
|
||||||
// users or developers to get useful information about an app at all times
|
// users or developers to get useful information about an app at all times
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
static void *
|
static void *
|
||||||
_monitor(void *_data)
|
_monitor(void *_data)
|
||||||
{
|
{
|
||||||
|
@ -537,11 +564,13 @@ _monitor(void *_data)
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// start up the debug monitor if we haven't already
|
// start up the debug monitor if we haven't already
|
||||||
static void
|
static void
|
||||||
_thread_start(Eina_Debug_Session *session)
|
_thread_start(Eina_Debug_Session *session)
|
||||||
{
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
pthread_t monitor_thread;
|
pthread_t monitor_thread;
|
||||||
int err;
|
int err;
|
||||||
sigset_t oldset, newset;
|
sigset_t oldset, newset;
|
||||||
|
@ -569,6 +598,9 @@ _thread_start(Eina_Debug_Session *session)
|
||||||
e_debug("EINA DEBUG ERROR: Can't create monitor debug thread!");
|
e_debug("EINA DEBUG ERROR: Can't create monitor debug thread!");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void)session;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -21,14 +21,23 @@
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#ifdef HAVE_DLADDR
|
#ifdef HAVE_DLADDR
|
||||||
|
# ifdef _WIN32
|
||||||
|
# include <Evil.h>
|
||||||
|
# else
|
||||||
# include <dlfcn.h>
|
# include <dlfcn.h>
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNWIND
|
||||||
#include <libunwind.h>
|
#include <libunwind.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "eina_debug.h"
|
#include "eina_debug.h"
|
||||||
#include "eina_debug_private.h"
|
#include "eina_debug_private.h"
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
# define SIG SIGPROF
|
# define SIG SIGPROF
|
||||||
|
#endif
|
||||||
|
|
||||||
static Eina_Semaphore _wait_for_bts_sem;
|
static Eina_Semaphore _wait_for_bts_sem;
|
||||||
|
|
||||||
|
@ -45,6 +54,7 @@ static Eina_Debug_Timer *_timer = NULL;
|
||||||
void
|
void
|
||||||
_eina_debug_dump_fhandle_bt(FILE *f, void **bt, int btlen)
|
_eina_debug_dump_fhandle_bt(FILE *f, void **bt, int btlen)
|
||||||
{
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
int i;
|
int i;
|
||||||
Dl_info info;
|
Dl_info info;
|
||||||
const char *file;
|
const char *file;
|
||||||
|
@ -67,12 +77,18 @@ _eina_debug_dump_fhandle_bt(FILE *f, void **bt, int btlen)
|
||||||
if (file) fprintf(f, "%s\t 0x%llx 0x%llx\n", file, offset, base);
|
if (file) fprintf(f, "%s\t 0x%llx 0x%llx\n", file, offset, base);
|
||||||
else fprintf(f, "??\t -\n");
|
else fprintf(f, "??\t -\n");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void)f;
|
||||||
|
(void)bt;
|
||||||
|
(void)btlen;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// a backtracer that uses libunwind to do the job
|
// a backtracer that uses libunwind to do the job
|
||||||
static inline int
|
static inline int
|
||||||
_eina_debug_unwind_bt(void **bt, int max)
|
_eina_debug_unwind_bt(void **bt, int max)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_UNWIND
|
||||||
unw_cursor_t cursor;
|
unw_cursor_t cursor;
|
||||||
unw_context_t uc;
|
unw_context_t uc;
|
||||||
unw_word_t p;
|
unw_word_t p;
|
||||||
|
@ -90,6 +106,11 @@ _eina_debug_unwind_bt(void **bt, int max)
|
||||||
}
|
}
|
||||||
// return our total backtrace stack size
|
// return our total backtrace stack size
|
||||||
return total;
|
return total;
|
||||||
|
#else
|
||||||
|
(void)bt;
|
||||||
|
(void)max;
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// a quick and dirty local time point getter func - not portable
|
// a quick and dirty local time point getter func - not portable
|
||||||
|
@ -107,6 +128,7 @@ get_time(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
static void
|
static void
|
||||||
_signal_handler(int sig EINA_UNUSED,
|
_signal_handler(int sig EINA_UNUSED,
|
||||||
siginfo_t *si EINA_UNUSED, void *foo EINA_UNUSED)
|
siginfo_t *si EINA_UNUSED, void *foo EINA_UNUSED)
|
||||||
|
@ -143,10 +165,12 @@ found:
|
||||||
// backtrace info
|
// backtrace info
|
||||||
eina_semaphore_release(&_wait_for_bts_sem, 1);
|
eina_semaphore_release(&_wait_for_bts_sem, 1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_signal_init(void)
|
_signal_init(void)
|
||||||
{
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
// set up signal handler for our profiling signal - eevery thread should
|
// set up signal handler for our profiling signal - eevery thread should
|
||||||
|
@ -162,6 +186,7 @@ _signal_init(void)
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = 0;
|
||||||
if (sigaction(SIGPIPE, &sa, 0) == -1) perror(0);
|
if (sigaction(SIGPIPE, &sa, 0) == -1) perror(0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -169,7 +194,9 @@ _collect_bt(pthread_t pth)
|
||||||
{
|
{
|
||||||
// this async signals the thread to switch to the deebug signal handler
|
// this async signals the thread to switch to the deebug signal handler
|
||||||
// and collect a backtrace and other info from inside the thread
|
// and collect a backtrace and other info from inside the thread
|
||||||
|
#ifndef _WIN32
|
||||||
pthread_kill(pth, SIG);
|
pthread_kill(pth, SIG);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
|
@ -277,3 +304,4 @@ _eina_debug_bt_shutdown(void)
|
||||||
eina_semaphore_free(&_wait_for_bts_sem);
|
eina_semaphore_free(&_wait_for_bts_sem);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,13 +65,19 @@ void _eina_debug_chunk_tmp_reset(void);
|
||||||
const char *_eina_debug_file_get(const char *fname);
|
const char *_eina_debug_file_get(const char *fname);
|
||||||
|
|
||||||
void _eina_debug_dump_fhandle_bt(FILE *f, void **bt, int btlen);
|
void _eina_debug_dump_fhandle_bt(FILE *f, void **bt, int btlen);
|
||||||
|
|
||||||
#define EINA_MAX_BT 256
|
#define EINA_MAX_BT 256
|
||||||
|
#ifdef HAVE_BACKTRACE
|
||||||
#define EINA_BT(file) \
|
#define EINA_BT(file) \
|
||||||
do { \
|
do { \
|
||||||
void *bt[EINA_MAX_BT]; \
|
void *bt[EINA_MAX_BT]; \
|
||||||
int btlen = backtrace((void **)bt, EINA_MAX_BT); \
|
int btlen = backtrace((void **)bt, EINA_MAX_BT); \
|
||||||
_eina_debug_dump_fhandle_bt(file, bt, btlen); \
|
_eina_debug_dump_fhandle_bt(file, bt, btlen); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#else
|
||||||
|
#define EINA_BT(file) do { } while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Eina_Bool _eina_debug_cpu_init(void);
|
Eina_Bool _eina_debug_cpu_init(void);
|
||||||
Eina_Bool _eina_debug_cpu_shutdown(void);
|
Eina_Bool _eina_debug_cpu_shutdown(void);
|
||||||
|
|
|
@ -20,12 +20,18 @@
|
||||||
# define _GNU_SOURCE 1
|
# define _GNU_SOURCE 1
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#ifdef HAVE_SYS_EPOLL_H
|
||||||
# include <sys/epoll.h>
|
# include <sys/epoll.h>
|
||||||
|
#endif
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -182,7 +188,9 @@ Eina_Bool
|
||||||
_eina_debug_timer_init(void)
|
_eina_debug_timer_init(void)
|
||||||
{
|
{
|
||||||
eina_spinlock_new(&_lock);
|
eina_spinlock_new(&_lock);
|
||||||
|
#ifndef _WIN32
|
||||||
pipe(pipeToThread);
|
pipe(pipeToThread);
|
||||||
|
#endif
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue