[Git][NTPsec/ntpsec][master] Information hiding.

Eric S. Raymond gitlab at mg.gitlab.com
Sun Oct 23 14:31:06 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
8af33538 by Eric S. Raymond at 2016-10-23T10:27:28-04:00
Information hiding.

- - - - -


2 changed files:

- include/timetoa.h
- libntp/timetoa.c


Changes:

=====================================
include/timetoa.h
=====================================
--- a/include/timetoa.h
+++ b/include/timetoa.h
@@ -28,41 +28,6 @@
 #include "ntp_stdlib.h"
 
 /*
- * Given the size of time_t, guess what can be used as an unsigned value
- * to hold a time_t and the printf() format specifcation.
- *
- * These should be used with the string constant concatenation feature
- * of the compiler like this:
- *
- * printf("a time stamp: %" TIME_FORMAT " and more\n", a_time_t_value);
- *
- * It's not exactly nice, but there's not much leeway once we want to
- * use the printf() family on time_t values.
- */
-
-#if SIZEOF_TIME_T <= SIZEOF_INT
-
-typedef unsigned int u_time;
-#define TIME_FORMAT "d"
-#define UTIME_FORMAT "u"
-
-#elif SIZEOF_TIME_T <= SIZEOF_LONG
-
-typedef unsigned long u_time;
-#define TIME_FORMAT "ld"
-#define UTIME_FORMAT "lu"
-
-#elif defined(SIZEOF_LONG_LONG) && SIZEOF_TIME_T <= SIZEOF_LONG_LONG
-
-typedef unsigned long long u_time;
-#define TIME_FORMAT "lld"
-#define UTIME_FORMAT "llu"
-
-#else
-#include "GRONK: what size has a time_t here?"
-#endif
-
-/*
  * general fractional time stamp formatting.
  *
  * secs - integral seconds of time stamp


=====================================
libntp/timetoa.c
=====================================
--- a/libntp/timetoa.c
+++ b/libntp/timetoa.c
@@ -30,6 +30,41 @@
 #include "lib_strbuf.h"
 
 /*
+ * Given the size of time_t, guess what can be used as an unsigned value
+ * to hold a time_t and the printf() format specifcation.
+ *
+ * These should be used with the string constant concatenation feature
+ * of the compiler like this:
+ *
+ * printf("a time stamp: %" TIME_FORMAT " and more\n", a_time_t_value);
+ *
+ * It's not exactly nice, but there's not much leeway once we want to
+ * use the printf() family on time_t values.
+ */
+
+#if SIZEOF_TIME_T <= SIZEOF_INT
+
+typedef unsigned int u_time;
+#define TIME_FORMAT "d"
+#define UTIME_FORMAT "u"
+
+#elif SIZEOF_TIME_T <= SIZEOF_LONG
+
+typedef unsigned long u_time;
+#define TIME_FORMAT "ld"
+#define UTIME_FORMAT "lu"
+
+#elif defined(SIZEOF_LONG_LONG) && SIZEOF_TIME_T <= SIZEOF_LONG_LONG
+
+typedef unsigned long long u_time;
+#define TIME_FORMAT "lld"
+#define UTIME_FORMAT "llu"
+
+#else
+#include "GRONK: what size has a time_t here?"
+#endif
+
+/*
  * Formatting to string needs at max 40 bytes (even with 64 bit time_t),
  * so we check LIB_BUFLENGTH is big enough for our purpose.
  */



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/8af33538dc55a70adedb289b15b349d5859555b5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161023/21dd2d54/attachment.html>


More information about the vc mailing list