configure: better support for extvars
authorMichael Wallner <mike@php.net>
Fri, 21 Oct 2016 05:39:40 +0000 (07:39 +0200)
committerMichael Wallner <mike@php.net>
Fri, 21 Oct 2016 05:39:40 +0000 (07:39 +0200)
m4/posix/netinet_in.m4
m4/posix/signal.m4
m4/posix/time.m4
m4/psi/psi_decl.m4
m4/psi/psi_macro.m4

index e226d0517b1fdb807ac98e60ffa32858f8d4232b..88f054b57120fd50bbe201d9cc0bf1a64458dc0a 100644 (file)
@@ -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)
 }
index fe0c545347e15efe12719f310ee80dd98cdceff1..6895acfbebf561e3d19d9613ffad1c48aa2b7f38 100644 (file)
@@ -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)])
index 250e3c901b6ee208a6213a7fa3a0f90209922805..63906e5fb3254bea39ffc6ccf4f8e256f7b82ba4 100644 (file)
@@ -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)
index c5b90decf6b0e9bb499297f3883d8d4a909a6457..ae44e73e89e85fb4440ea2efecd80302f7af666d 100644 (file)
@@ -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]))])
 ])
 
index b3ee9882ebb7d8fda758b79a2b1cee9e69d98ccc..d26a888774a5a7a2c094ecfeb58a92521620a6d4 100644 (file)
@@ -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"
+       ])
+])