aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/unix/sys.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-04-24 20:08:53 +0200
committerLukas Larsson <[email protected]>2017-09-15 10:04:42 +0200
commitba93bbc768928bb6213cd583ea91a108fa9d16ca (patch)
treed01f42f2cc16bd528ab1c226fa91b250912cc219 /erts/emulator/sys/unix/sys.c
parent5c7a869b8d0e4aeec9902a1316d672860790076c (diff)
downloadotp-ba93bbc768928bb6213cd583ea91a108fa9d16ca.tar.gz
otp-ba93bbc768928bb6213cd583ea91a108fa9d16ca.tar.bz2
otp-ba93bbc768928bb6213cd583ea91a108fa9d16ca.zip
erts: Refactor move check_io interface from sys to check_io
# Conflicts: # erts/emulator/beam/erl_process.c # erts/emulator/beam/sys.h # erts/emulator/sys/common/erl_check_io.c # erts/emulator/sys/common/erl_check_io.h # erts/emulator/sys/unix/sys.c
Diffstat (limited to 'erts/emulator/sys/unix/sys.c')
-rw-r--r--erts/emulator/sys/unix/sys.c129
1 files changed, 9 insertions, 120 deletions
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
index d05028cabc..e88d7aa6df 100644
--- a/erts/emulator/sys/unix/sys.c
+++ b/erts/emulator/sys/unix/sys.c
@@ -131,121 +131,6 @@ static int replace_intr = 0;
/* assume yes initially, ttsl_init will clear it */
int using_oldshell = 1;
-#ifdef ERTS_ENABLE_KERNEL_POLL
-
-int erts_use_kernel_poll = 0;
-
-struct {
- int (*select)(ErlDrvPort, ErlDrvEvent, int, int);
- int (*enif_select)(ErlNifEnv*, ErlNifEvent, enum ErlNifSelectFlags, void*, const ErlNifPid*, Eterm);
- int (*event)(ErlDrvPort, ErlDrvEvent, ErlDrvEventData);
- void (*check_io_as_interrupt)(void);
- void (*check_io_interrupt)(int);
- void (*check_io_interrupt_tmd)(int, ErtsMonotonicTime);
- void (*check_io)(int);
- Uint (*size)(void);
- Eterm (*info)(void *);
- int (*check_io_debug)(ErtsCheckIoDebugInfo *);
-} io_func = {0};
-
-
-int
-driver_select(ErlDrvPort port, ErlDrvEvent event, int mode, int on)
-{
- return (*io_func.select)(port, event, mode, on);
-}
-
-int
-driver_event(ErlDrvPort port, ErlDrvEvent event, ErlDrvEventData event_data)
-{
- return (*io_func.event)(port, event, event_data);
-}
-
-int enif_select(ErlNifEnv* env, ErlNifEvent event,
- enum ErlNifSelectFlags flags, void* obj, const ErlNifPid* pid, Eterm ref)
-{
- return (*io_func.enif_select)(env, event, flags, obj, pid, ref);
-}
-
-
-Eterm erts_check_io_info(void *p)
-{
- return (*io_func.info)(p);
-}
-
-int
-erts_check_io_debug(ErtsCheckIoDebugInfo *ip)
-{
- return (*io_func.check_io_debug)(ip);
-}
-
-
-static void
-init_check_io(void)
-{
- if (erts_use_kernel_poll) {
- io_func.select = driver_select_kp;
- io_func.enif_select = enif_select_kp;
- io_func.event = driver_event_kp;
- io_func.check_io_interrupt = erts_check_io_interrupt_kp;
- io_func.check_io_interrupt_tmd = erts_check_io_interrupt_timed_kp;
- io_func.check_io = erts_check_io_kp;
- io_func.size = erts_check_io_size_kp;
- io_func.info = erts_check_io_info_kp;
- io_func.check_io_debug = erts_check_io_debug_kp;
- erts_init_check_io_kp();
- max_files = erts_check_io_max_files_kp();
- }
- else {
- io_func.select = driver_select_nkp;
- io_func.enif_select = enif_select_nkp;
- io_func.event = driver_event_nkp;
- io_func.check_io_interrupt = erts_check_io_interrupt_nkp;
- io_func.check_io_interrupt_tmd = erts_check_io_interrupt_timed_nkp;
- io_func.check_io = erts_check_io_nkp;
- io_func.size = erts_check_io_size_nkp;
- io_func.info = erts_check_io_info_nkp;
- io_func.check_io_debug = erts_check_io_debug_nkp;
- erts_init_check_io_nkp();
- max_files = erts_check_io_max_files_nkp();
- }
-}
-
-#define ERTS_CHK_IO_AS_INTR() (*io_func.check_io_interrupt)(1)
-#define ERTS_CHK_IO_INTR (*io_func.check_io_interrupt)
-#define ERTS_CHK_IO_INTR_TMD (*io_func.check_io_interrupt_tmd)
-#define ERTS_CHK_IO (*io_func.check_io)
-#define ERTS_CHK_IO_SZ (*io_func.size)
-
-#else /* !ERTS_ENABLE_KERNEL_POLL */
-
-static void
-init_check_io(void)
-{
- erts_init_check_io();
- max_files = erts_check_io_max_files();
-}
-
-#define ERTS_CHK_IO_AS_INTR() erts_check_io_interrupt(1)
-#define ERTS_CHK_IO_INTR erts_check_io_interrupt
-#define ERTS_CHK_IO_INTR_TMD erts_check_io_interrupt_timed
-#define ERTS_CHK_IO erts_check_io
-#define ERTS_CHK_IO_SZ erts_check_io_size
-
-#endif
-
-void
-erts_sys_schedule_interrupt(int set)
-{
- ERTS_CHK_IO_INTR(set);
-}
-
-void
-erts_sys_schedule_interrupt_timed(int set, ErtsMonotonicTime timeout_time)
-{
- ERTS_CHK_IO_INTR_TMD(set, timeout_time);
-}
-
UWord
erts_sys_get_page_size(void)
{
@@ -261,7 +146,7 @@ erts_sys_get_page_size(void)
Uint
erts_sys_misc_mem_sz(void)
{
- Uint res = ERTS_CHK_IO_SZ();
+ Uint res = erts_check_io_size();
res += erts_atomic_read_mb(&sys_misc_mem_sz);
return res;
}
@@ -625,7 +510,7 @@ break_requested(void)
erts_exit(ERTS_INTR_EXIT, "");
ERTS_SET_BREAK_REQUESTED;
- ERTS_CHK_IO_AS_INTR(); /* Make sure we don't sleep in poll */
+ erts_check_io_sig_interrupt();
}
static RETSIGTYPE request_break(int signum)
@@ -813,7 +698,7 @@ erts_sys_unix_later_init(void)
int sys_max_files(void)
{
- return(max_files);
+ return max_files;
}
/************************** OS info *******************************/
@@ -1198,7 +1083,7 @@ erl_debug(char* fmt, ...)
void
erl_sys_schedule(int runnable)
{
- ERTS_CHK_IO(!runnable);
+ erts_check_io(!runnable);
ERTS_LC_ASSERT(!erts_thr_progress_is_blocking());
}
@@ -1417,6 +1302,8 @@ get_value(char* rest, char** argv, int* ip)
return rest;
}
+int erts_use_kernel_poll = 0;
+
#endif /* ERTS_ENABLE_KERNEL_POLL */
void
@@ -1475,7 +1362,9 @@ erl_sys_args(int* argc, char** argv)
}
#endif
- init_check_io();
+ erts_init_check_io();
+ max_files = erts_check_io_max_files();
+
init_smp_sig_notify();
init_smp_sig_suspend();