]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2728] See if C99-style structure initialization works
authorHarlan Stenn <stenn@ntp.org>
Sat, 21 Feb 2015 07:15:54 +0000 (07:15 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sat, 21 Feb 2015 07:15:54 +0000 (07:15 +0000)
bk: 54e830aaj33zQmQnsCHG4Ktuk3Z2Ow

ChangeLog
configure.ac
ntpq/ntpq-subs.c
ports/winnt/include/config.h
sntp/m4/ax_c99_struct_init.m4 [new file with mode: 0644]

index 400cf79340f59ef9681a6751226e31f86cd8481e..969166443f84d6c7d29ef3d00e6600ca7daab0dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
 ---
+
+* [Bug 2728] See if C99-style structure initialization works.
+---
 (4.2.8p1) 2015/02/04 Released by Harlan Stenn <stenn@ntp.org>
 
 * Update the NEWS file.
index 6942ceb5333fc5afc39a713b83959cb65a2522e4..d82ad2ed2e4d9b74f41302eaf77f39715008b821 100644 (file)
@@ -68,6 +68,7 @@ AC_PROG_CPP
 AC_PROG_CXX
 AC_PROG_YACC
 AC_PROG_CC_C_O
+AX_C99_STRUCT_INIT
 
 NTP_VPATH_HACK         dnl used only by ntpd/Makefile.am
 
index 56bc2280223ff8ebc0266ffc8b1cdd2f89ae5658..8bd4fdbbcf4e867543bdd23266cea6ecd99e9271 100644 (file)
@@ -330,7 +330,7 @@ typedef struct var_display_collection_tag {
                l_fp            lfp;    /* NTP_LFP */
        } v;                            /* retrieved value */
 } vdc;
-#if !defined(MISSING_C99_STYLE_INIT)
+#if !defined(MISSING_C99_STRUCT_INIT)
 # define VDC_INIT(a, b, c) { .tag = a, .display = b, .type = c }
 #else
 # define VDC_INIT(a, b, c) { a, b, c }
index 6de8857c1fed0c4a87a9bc3276250d49625aab76..f56df9d0b574fae764a7e328d40b93509913dbf3 100644 (file)
@@ -457,7 +457,7 @@ typedef unsigned long uintptr_t;
 #if defined(_MSC_VER) && _MSC_VER<1800
 # define MISSING_INTTYPES_H         1  /* not provided by VS2012 and earlier */
 # define MISSING_STDBOOL_H          1  /* not provided by VS2012 and earlier */
-# define MISSING_C99_STYLE_INIT     1  /* see [Bug 2728] */
+# define MISSING_C99_STRUCT_INIT    1  /* see [Bug 2728] */
 #else
 #if defined(_MSC_VER) && _MSC_VER>=1800
 /* VS2013 and above support C99 types */
diff --git a/sntp/m4/ax_c99_struct_init.m4 b/sntp/m4/ax_c99_struct_init.m4
new file mode 100644 (file)
index 0000000..44a2db3
--- /dev/null
@@ -0,0 +1,59 @@
+# ===========================================================================
+#       http://www.gnu.org/software/autoconf-archive/ax_c99_struct_init.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_C99_STRUCT_INIT
+#
+# DESCRIPTION
+#
+#   This macro defines MISSING_C99_STRUCT_INIT if the C compiler does not
+#   supports the C99 tagged structure initialization.
+#
+#   Given: struct foo_s {int i1; int i2; int i3;};
+#   one can write:
+#      #if !define(MISSING_C99_STRUCT_INIT)
+#      # define FOO_INIT(a, b, c) { .i1 = a, .i2 = b, .i3 = c }
+#      #else
+#      # define FOO_INIT(a, b, c) { a, b, c }
+#
+#      static struct foo_s foo[] = {
+#              FOO_INIT(1, 1, 1),
+#              FOO_INIT(2, 2, 2),
+#              FOO_INIT(0, 0, 0)
+#      };
+#
+# LICENSE
+#
+#   Copyright (c) 2015 Network Time Foundation
+#
+#   Author: Harlan Stenn <stenn@nwtime.org>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([AX_C99_STRUCT_INIT], [
+       AC_MSG_CHECKING([whether the compiler supports C99 structure initialization])
+       AC_REQUIRE([AC_PROG_CC_C99])
+
+       AC_LANG_PUSH([C])
+
+       dnl AC_LINK_IFELSE?
+       AC_COMPILE_IFELSE(
+               [AC_LANG_SOURCE([[
+                       struct foo_s {int i1; int i2;};
+                       int main() { struct foo_s foo[] = { { .i1 = 1, .i2 = 1 }, { .i1 = 2, .i2 = 2 }, { .i1 = 0, .i2 = 0 } }; }
+                       ]])],
+               AC_MSG_RESULT([yes]),
+               AC_MSG_RESULT([no])
+               AC_DEFINE([MISSING_C99_STRUCT_INIT], [1],
+                       [Define to 1 if the compiler does not support C99's structure initialization.]),
+               )
+
+       AC_LANG_POP([C])
+       ]);