mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Fix build on systems without shm_open()
Notably, this fixes building on Android.
This commit is contained in:
parent
a928517e95
commit
df12ac24b2
5 changed files with 16 additions and 1 deletions
|
@ -252,7 +252,7 @@ AC_DEFINE([NOMACROS], [1], [Define to 1 to disable curses macros that conflict w
|
||||||
# Check for os dependant libraries for all binaries.
|
# Check for os dependant libraries for all binaries.
|
||||||
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
|
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
|
||||||
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
||||||
AC_SEARCH_LIBS( shm_open, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
AC_SEARCH_LIBS( shm_open, rt, [AC_DEFINE([HAVE_SHM_OPEN], [1], [Define to 1 if the shm_open() function exists])] )
|
||||||
AC_SEARCH_LIBS( pthread_create, pthread, , [AC_MSG_ERROR([Cannot find the pthread library, needed to build this package.] )] )
|
AC_SEARCH_LIBS( pthread_create, pthread, , [AC_MSG_ERROR([Cannot find the pthread library, needed to build this package.] )] )
|
||||||
AC_SEARCH_LIBS( setupterm, [ncurses tinfo curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish. If this is Linux, try running 'sudo apt-get install libncurses5-dev' or 'sudo yum install ncurses-devel'])] )
|
AC_SEARCH_LIBS( setupterm, [ncurses tinfo curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish. If this is Linux, try running 'sudo apt-get install libncurses5-dev' or 'sudo yum install ncurses-devel'])] )
|
||||||
AC_SEARCH_LIBS( [dladdr], [dl] )
|
AC_SEARCH_LIBS( [dladdr], [dl] )
|
||||||
|
|
|
@ -190,6 +190,9 @@
|
||||||
/* Perform string translations with gettext */
|
/* Perform string translations with gettext */
|
||||||
/* #undef USE_GETTEXT */
|
/* #undef USE_GETTEXT */
|
||||||
|
|
||||||
|
/* Define to 1 if the shm_open() function exists. */
|
||||||
|
#define HAVE_SHM_OPEN 1
|
||||||
|
|
||||||
/* Enable extensions on AIX 3, Interix. */
|
/* Enable extensions on AIX 3, Interix. */
|
||||||
#ifndef _ALL_SOURCE
|
#ifndef _ALL_SOURCE
|
||||||
# define _ALL_SOURCE 1
|
# define _ALL_SOURCE 1
|
||||||
|
|
|
@ -984,6 +984,7 @@ wcstring get_machine_identifier() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SHM_OPEN
|
||||||
class universal_notifier_shmem_poller_t : public universal_notifier_t {
|
class universal_notifier_shmem_poller_t : public universal_notifier_t {
|
||||||
// This is what our shared memory looks like. Everything here is stored in network byte order
|
// This is what our shared memory looks like. Everything here is stored in network byte order
|
||||||
// (big-endian).
|
// (big-endian).
|
||||||
|
@ -1123,6 +1124,7 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
|
||||||
return usec_per_sec / 3; // 3 times a second
|
return usec_per_sec / 3; // 3 times a second
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/// A notifyd-based notifier. Very straightforward.
|
/// A notifyd-based notifier. Very straightforward.
|
||||||
class universal_notifier_notifyd_t : public universal_notifier_t {
|
class universal_notifier_notifyd_t : public universal_notifier_t {
|
||||||
|
@ -1403,7 +1405,9 @@ static universal_notifier_t::notifier_strategy_t fetch_default_strategy_from_env
|
||||||
const char *name;
|
const char *name;
|
||||||
universal_notifier_t::notifier_strategy_t strat;
|
universal_notifier_t::notifier_strategy_t strat;
|
||||||
} options[] = {{"default", universal_notifier_t::strategy_default},
|
} options[] = {{"default", universal_notifier_t::strategy_default},
|
||||||
|
#ifdef HAVE_SHM_OPEN
|
||||||
{"shmem", universal_notifier_t::strategy_shmem_polling},
|
{"shmem", universal_notifier_t::strategy_shmem_polling},
|
||||||
|
#endif
|
||||||
{"pipe", universal_notifier_t::strategy_named_pipe},
|
{"pipe", universal_notifier_t::strategy_named_pipe},
|
||||||
{"notifyd", universal_notifier_t::strategy_notifyd}};
|
{"notifyd", universal_notifier_t::strategy_notifyd}};
|
||||||
const size_t opt_count = sizeof options / sizeof *options;
|
const size_t opt_count = sizeof options / sizeof *options;
|
||||||
|
@ -1458,9 +1462,11 @@ universal_notifier_t *universal_notifier_t::new_notifier_for_strategy(
|
||||||
strat = resolve_default_strategy(); //!OCLINT(parameter reassignment)
|
strat = resolve_default_strategy(); //!OCLINT(parameter reassignment)
|
||||||
}
|
}
|
||||||
switch (strat) {
|
switch (strat) {
|
||||||
|
#ifdef HAVE_SHM_OPEN
|
||||||
case strategy_shmem_polling: {
|
case strategy_shmem_polling: {
|
||||||
return new universal_notifier_shmem_poller_t();
|
return new universal_notifier_shmem_poller_t();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
case strategy_notifyd: {
|
case strategy_notifyd: {
|
||||||
return new universal_notifier_notifyd_t();
|
return new universal_notifier_notifyd_t();
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,9 +115,11 @@ class universal_notifier_t {
|
||||||
// Default meta-strategy to use the 'best' notifier for the system.
|
// Default meta-strategy to use the 'best' notifier for the system.
|
||||||
strategy_default,
|
strategy_default,
|
||||||
|
|
||||||
|
#ifdef HAVE_SHM_OPEN
|
||||||
// Use a value in shared memory. Simple, but requires polling and therefore semi-frequent
|
// Use a value in shared memory. Simple, but requires polling and therefore semi-frequent
|
||||||
// wakeups.
|
// wakeups.
|
||||||
strategy_shmem_polling,
|
strategy_shmem_polling,
|
||||||
|
#endif
|
||||||
|
|
||||||
// Strategy that uses a named pipe. Somewhat complex, but portable and doesn't require
|
// Strategy that uses a named pipe. Somewhat complex, but portable and doesn't require
|
||||||
// polling most of the time.
|
// polling most of the time.
|
||||||
|
|
|
@ -2499,9 +2499,11 @@ static void trigger_or_wait_for_notification(universal_notifier_t *notifier,
|
||||||
DIE("strategy_default should be passed");
|
DIE("strategy_default should be passed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_SHM_OPEN
|
||||||
case universal_notifier_t::strategy_shmem_polling: {
|
case universal_notifier_t::strategy_shmem_polling: {
|
||||||
break; // nothing required
|
break; // nothing required
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
case universal_notifier_t::strategy_notifyd: {
|
case universal_notifier_t::strategy_notifyd: {
|
||||||
// notifyd requires a round trip to the notifyd server, which means we have to wait a
|
// notifyd requires a round trip to the notifyd server, which means we have to wait a
|
||||||
// little bit to receive it. In practice, this seems to be enough.
|
// little bit to receive it. In practice, this seems to be enough.
|
||||||
|
@ -2585,7 +2587,9 @@ static void test_notifiers_with_strategy(universal_notifier_t::notifier_strategy
|
||||||
static void test_universal_notifiers() {
|
static void test_universal_notifiers() {
|
||||||
if (system("mkdir -p /tmp/fish_uvars_test/ && touch /tmp/fish_uvars_test/varsfile.txt"))
|
if (system("mkdir -p /tmp/fish_uvars_test/ && touch /tmp/fish_uvars_test/varsfile.txt"))
|
||||||
err(L"mkdir failed");
|
err(L"mkdir failed");
|
||||||
|
#ifdef HAVE_SHM_OPEN
|
||||||
test_notifiers_with_strategy(universal_notifier_t::strategy_shmem_polling);
|
test_notifiers_with_strategy(universal_notifier_t::strategy_shmem_polling);
|
||||||
|
#endif
|
||||||
test_notifiers_with_strategy(universal_notifier_t::strategy_named_pipe);
|
test_notifiers_with_strategy(universal_notifier_t::strategy_named_pipe);
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
test_notifiers_with_strategy(universal_notifier_t::strategy_notifyd);
|
test_notifiers_with_strategy(universal_notifier_t::strategy_notifyd);
|
||||||
|
|
Loading…
Reference in a new issue