[gnutls-devel] Guile-GnuTLS | Use long when converting to/from time_t. (!33)
Read-only notification of GnuTLS library development activities
gnutls-devel at lists.gnutls.org
Fri Mar 7 10:31:02 CET 2025
Dariqq commented on a discussion: https://gitlab.com/gnutls/guile/-/merge_requests/33#note_2384782326
Maybe something like this? Not sure what to do if the `HAVE_CONFIG_H` is not defined.
Cant really test if it works on 32bit with 64bit time_t. Presumably Id need to recompile everything with 64bit time and not just guile-gnutls/gnutls. Can this be tested on debian i386 somehow which should have 64bit time?
```diff
diff --git a/configure.ac b/configure.ac
index e09b967..738be68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,6 +126,8 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], gnu89_inline=yes, gnu89_inline=no)
AC_MSG_RESULT($gnu89_inline)
CFLAGS="$_gcc_cflags_save"
+AC_CHECK_SIZEOF(time_t)
+
# Optional Guile functions.
save_CFLAGS="$CFLAGS"
save_LIBS="$LIBS"
diff --git a/guile/src/core.c b/guile/src/core.c
index 289a228..ff97e49 100644
--- a/guile/src/core.c
+++ b/guile/src/core.c
@@ -21,6 +21,16 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
+#if SIZEOF_TIME_T == 8
+#define scm_to_time_t scm_to_int64
+#define scm_from_time_t scm_from_int64
+#elif SIZEOF_TIME_T == 4
+#define scm_to_time_t scm_to_int32
+#define scm_from_time_t scm_from_int32
+#else
+#error sizeof(time_t) is not 4 or 8.
+#endif
+/* What to do here? */
#endif
#include <stdio.h>
@@ -3351,7 +3361,7 @@ SCM_DEFINE (scm_gnutls_x509_certificate_activation_time,
c_cert = scm_to_gnutls_x509_certificate (cert, 1, FUNC_NAME);
c_time = gnutls_x509_crt_get_activation_time (c_cert);
- return scm_from_long (c_time);
+ return scm_from_time_t (c_time);
}
#undef FUNC_NAME
@@ -3368,7 +3378,7 @@ SCM_DEFINE (scm_gnutls_set_x509_certificate_activation_time,
time_t c_time;
c_cert = scm_to_gnutls_x509_certificate (cert, 1, FUNC_NAME);
- c_time = scm_to_long (time);
+ c_time = scm_to_time_t (time);
err = gnutls_x509_crt_set_activation_time (c_cert, c_time);
if (EXPECT_FALSE (err))
@@ -3390,7 +3400,7 @@ SCM_DEFINE (scm_gnutls_x509_certificate_expiration_time,
c_cert = scm_to_gnutls_x509_certificate (cert, 1, FUNC_NAME);
c_time = gnutls_x509_crt_get_expiration_time (c_cert);
- return scm_from_long (c_time);
+ return scm_from_time_t (c_time);
}
#undef FUNC_NAME
@@ -3407,7 +3417,7 @@ SCM_DEFINE (scm_gnutls_set_x509_certificate_expiration_time,
time_t c_time;
c_cert = scm_to_gnutls_x509_certificate (cert, 1, FUNC_NAME);
- c_time = scm_to_long (time);
+ c_time = scm_to_time_t (time);
err = gnutls_x509_crt_set_expiration_time (c_cert, c_time);
if (EXPECT_FALSE (err))
```
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/guile/-/merge_requests/33#note_2384782326
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20250307/25a31293/attachment-0001.html>
More information about the Gnutls-devel
mailing list