[Asterisk-code-review] time: add support for time64 libc (asterisk[master])

Sebastian Kemper asteriskteam at digium.com
Sun Oct 17 14:36:48 CDT 2021


Attention is currently required from: Sebastian Kemper.
Hello Friendly Automation, 

I'd like you to reexamine a change. Please visit

    https://gerrit.asterisk.org/c/asterisk/+/16621

to look at the new patch set (#3).

Change subject: time: add support for time64 libc
......................................................................

time: add support for time64 libc

libcs are implementing changes to fix the year 2038 issue on 32 bit
platforms (see [1]). musl libc already went ahead and implemented it,
starting with musl-1.2.0 (see [2]).

Running asterisk on a 32 bit box with a time64 libc causes some
problems. For instance registering to pjsip doesn't work. The
registration completes fine, but the AOR disappears immediately, making
the registered clients unreachable.

This commit adds two new definitions to include/asterisk/time.h:

TIME_T_INT_FMT
TIME_T_UINT_FMT

If __USE_TIME_BITS64 is defined (by a time64 libc, see [1]), they're set
to the proper conversions for type int64_t, PRId64 and PRIu64
respectively. If __USE_TIME_BITS64 is not defined, the status quo
remains unchanged ("%ld" and "%lu" are used).

The new definitions are used in the different parts of asterisk, where
appropriate.

These changes get rid of the new warnings that appeared with musl-1.2.0 and
make the pjsip registration work again. Below an example warning:

In file included from ../include/asterisk.h:23,
                 from res_pjsip/location.c:19:
res_pjsip/location.c: In function 'expiration_struct2str':
../include/asterisk/astmm.h:270:72: warning: format '%ld' expects argument of type 'long int', but argument 6 has type 'time_t' {aka 'long long int'} [-Wformat=]
  270 |         __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__)
      |                                                                        ^~~~~
res_pjsip/location.c:492:17: note: in expansion of macro 'ast_asprintf'
  492 |         return (ast_asprintf(buf, "%ld", contact->expiration_time.tv_sec) < 0) ? -1 : 0;
      |                 ^~~~~~~~~~~~

[1] https://sourceware.org/glibc/wiki/Y2038ProofnessDesign
[2] https://musl.libc.org/time64.html

ASTERISK-29674 #close

Signed-off-by: Sebastian Kemper <sebastian_ml at gmx.net>
Change-Id: Ic8d61b26033f5c486b917e738c9608b0923a844e
---
M include/asterisk/time.h
M res/res_calendar_caldav.c
M res/res_calendar_icalendar.c
M res/res_http_media_cache.c
M res/res_odbc.c
M res/res_pjsip/location.c
M res/res_pjsip/pjsip_options.c
M res/res_pjsip_history.c
M res/res_pjsip_pubsub.c
M res/res_pjsip_registrar.c
M res/res_stir_shaken.c
11 files changed, 32 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/21/16621/3
-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16621
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ic8d61b26033f5c486b917e738c9608b0923a844e
Gerrit-Change-Number: 16621
Gerrit-PatchSet: 3
Gerrit-Owner: Sebastian Kemper <sebastian_ml at gmx.net>
Gerrit-Reviewer: Friendly Automation
Gerrit-Attention: Sebastian Kemper <sebastian_ml at gmx.net>
Gerrit-MessageType: newpatchset
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211017/bd253add/attachment.html>


More information about the asterisk-code-review mailing list