From: Michael Wallner Date: Fri, 21 Oct 2016 05:39:40 +0000 (+0200) Subject: configure: better support for extvars X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2f08002ac0b6de75b0ecb6fe57cbbc70cb2424ae;p=m6w6%2Fext-psi configure: better support for extvars --- diff --git a/m4/posix/netinet_in.m4 b/m4/posix/netinet_in.m4 index e226d05..88f054b 100644 --- a/m4/posix/netinet_in.m4 +++ b/m4/posix/netinet_in.m4 @@ -62,5 +62,5 @@ PSI_CHECK_NETINET_IN() { PSI_MACRO(int IN6_IS_ADDR_MC_ORGLOCAL, [(const struct in6_addr *a)]) PSI_MACRO(int IN6_IS_ADDR_MC_GLOBAL, [(const struct in6_addr *a)]) - PSI_EXTVAR(struct in6_addr in6addr_loopback) + PSI_MACRO(struct in6_addr in6addr_loopback) } diff --git a/m4/posix/signal.m4 b/m4/posix/signal.m4 index fe0c545..6895acf 100644 --- a/m4/posix/signal.m4 +++ b/m4/posix/signal.m4 @@ -173,7 +173,7 @@ PSI_CHECK_SIGNAL() { PSI_DECL(int sigignore, [(int sig)]) PSI_DECL(int siginterrupt, [(int sig, int flag)]) PSI_DECL(int sigismember, [(const sigset_t *set, int signum)]) - PSI_DECL(sighandler_t signal, [(int sig, sighandler_t *func)]) + PSI_DECL(sighandler_t signal, [(int sig, sighandler_t func)]) PSI_DECL(int sigpause, [(int sig)]) PSI_DECL(int sigpending, [(sigset_t *set)]) PSI_DECL(int sigprocmask, [(int how, const sigset_t *set, sigset_t *oset)]) diff --git a/m4/posix/time.m4 b/m4/posix/time.m4 index 250e3c9..63906e5 100644 --- a/m4/posix/time.m4 +++ b/m4/posix/time.m4 @@ -57,6 +57,7 @@ PSI_CHECK_TIME() { PSI_DECL(int timer_settime, [(timer_t t, int flags, struct itimerspec *value, struct itimerspec *ovalue)], [], [-lrt]) PSI_DECL(void tzset, [()]) + PSI_MACRO(int getdate_err) PSI_EXTVAR(int daylight) PSI_EXTVAR(long timezone) PSI_EXTVAR(char **tzname) diff --git a/m4/psi/psi_decl.m4 b/m4/psi/psi_decl.m4 index c5b90de..ae44e73 100644 --- a/m4/psi/psi_decl.m4 +++ b/m4/psi/psi_decl.m4 @@ -61,6 +61,7 @@ AC_DEFUN(PSI_DECL_ARGS, [ m4_case([$2], [(void)], [], [()], [], + [], [], [m4_map_args_sep([PSI_DECL_ARG(m4_normalize(], [))], [], m4_bregexp([$2], [(\(.*\))], [\1]))]) ]) diff --git a/m4/psi/psi_macro.m4 b/m4/psi/psi_macro.m4 index b3ee988..d26a888 100644 --- a/m4/psi/psi_macro.m4 +++ b/m4/psi/psi_macro.m4 @@ -9,25 +9,28 @@ EOF dnl PSI_MACRO(macro, decl args, action-if-true) AC_DEFUN(PSI_MACRO, [ AC_CHECK_DECL(PSI_VAR_NAME($1)$2, [ - $3 macro_type="PSI_VAR_TYPE($1)" macro_name="PSI_VAR_NAME($1)" m4_case([$2], [(void)], [ macro_decl="(void)" macro_call="()" + macro_action=call ], [()], [ macro_decl="()" macro_call="()" + macro_action=call ], [], [ macro_decl="()" macro_call="" + macro_action=get ], [ macro_decl="$2" macro_call="(m4_map_args_sep([PSI_VAR_NAME(], [)], [, ], m4_bregexp($2, [(\(.*\))], [\1])))" + macro_action=call ] ) ifelse(PSI_VAR_TYPE($1), [void], [ @@ -35,10 +38,25 @@ AC_DEFUN(PSI_MACRO, [ ], [ macro_body="return $macro_name$macro_call;" ]) - psi_add_macro "$macro_type _psi_redir_$macro_name$macro_decl { $macro_body }" - PSI_REDIR($macro_name, _psi_redir_$macro_name) + $3 + psi_add_macro "$macro_type _psi_${macro_action}_$macro_name$macro_decl { $macro_body }" + PSI_REDIR($macro_name, _psi_${macro_action}_$macro_name) ], [], PSI_INCLUDES) ]) dnl PSI_EXTVAR(type var) -AC_DEFUN(PSI_EXTVAR, [PSI_MACRO($1)]) +AC_DEFUN(PSI_EXTVAR, [ + dnl just a getter + PSI_MACRO($1, [], [ + PSI_DECL_ARGS($1) + psi_add_decl "$psi_decl_args" + dnl explicit getter & setter + PSI_REDIR([${macro_name}_get], [_psi_get_$macro_name]) + PSI_DECL_ARGS($1_get) + psi_add_decl "$psi_decl_args" + psi_add_macro "void _psi_set_${macro_name}($macro_type value) { memcpy(&$macro_name, &value, sizeof(value)); }" + PSI_REDIR([${macro_name}_set], [_psi_set_${macro_name}]) + PSI_DECL_ARGS([void PSI_VAR_NAME($1)_set], [(PSI_VAR_TYPE($1) _v)]) + psi_add_decl "$psi_decl_args" + ]) +])