public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2021-04-19 18:05 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-04-19 18:05 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:18f4a95b57a4d026393f35419e34ee8e37b3c245

commit 18f4a95b57a4d026393f35419e34ee8e37b3c245
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 67d69b721b5..295db5164cc 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index 41b52da7c64..fcd9fcbc29c 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -378,8 +378,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2021-09-17 14:34 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-09-17 14:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2945ad4a31dcd984290598a27ea6668c6fec56f6

commit 2945ad4a31dcd984290598a27ea6668c6fec56f6
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 67d69b721b5..295db5164cc 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index 41b52da7c64..fcd9fcbc29c 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -378,8 +378,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2021-04-10 17:00 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-04-10 17:00 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f44fdcef63a99921c2d3fe258ee54a9195aa7b35

commit f44fdcef63a99921c2d3fe258ee54a9195aa7b35
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 67d69b721b5..295db5164cc 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index 031bcb7341f..b253f86b0ea 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -378,8 +378,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2021-04-10 15:04 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-04-10 15:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:feb64bb30b035984e595bf34288f17696605c09e

commit feb64bb30b035984e595bf34288f17696605c09e
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 67d69b721b5..295db5164cc 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index 031bcb7341f..b253f86b0ea 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -378,8 +378,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2021-03-14 22:00 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-03-14 22:00 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:11262af7629eb13422edb2f3ed722c5c4dac118b

commit 11262af7629eb13422edb2f3ed722c5c4dac118b
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 67d69b721b5..295db5164cc 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index 031bcb7341f..b253f86b0ea 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -378,8 +378,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2021-03-07 17:01 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-03-07 17:01 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f583190c7b10a2edcd9ecd04e4a9e7beb9ba0d84

commit f583190c7b10a2edcd9ecd04e4a9e7beb9ba0d84
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 67d69b721b5..295db5164cc 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index 031bcb7341f..b253f86b0ea 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -378,8 +378,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2021-01-30 19:08 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-01-30 19:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6654f9ee7bafb7f2ae7380c6462a50fa07d1e57a

commit 6654f9ee7bafb7f2ae7380c6462a50fa07d1e57a
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 67d69b721b5..295db5164cc 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index 031bcb7341f..b253f86b0ea 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -378,8 +378,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2021-01-28 17:31 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-01-28 17:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bb8608b26e824e60b5cd9acdc08a03eb91bcd781

commit bb8608b26e824e60b5cd9acdc08a03eb91bcd781
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 67d69b721b5..295db5164cc 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index 031bcb7341f..b253f86b0ea 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -378,8 +378,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2021-01-11 11:39 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2021-01-11 11:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:c72ee91fcf213923b26030be3c64fec4733b1717

commit c72ee91fcf213923b26030be3c64fec4733b1717
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 67d69b721b5..295db5164cc 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index a47aec525e8..0b3f8436254 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -377,8 +377,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2020-12-22 13:41 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2020-12-22 13:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:c0fdb74cba07bf394f562de42bc35cd0587b5390

commit c0fdb74cba07bf394f562de42bc35cd0587b5390
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 7b8c72efe27..9ebc90fd1ca 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index a47aec525e8..0b3f8436254 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -377,8 +377,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2020-12-09  9:51 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2020-12-09  9:51 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:18685099ae2271144781650b6cd21b4120776b4e

commit 18685099ae2271144781650b6cd21b4120776b4e
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 7b8c72efe27..9ebc90fd1ca 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index a47aec525e8..0b3f8436254 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -377,8 +377,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2020-12-05 23:47 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2020-12-05 23:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5feb46e9fd6642d60d30f952ce089648e127e074

commit 5feb46e9fd6642d60d30f952ce089648e127e074
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 7b8c72efe27..9ebc90fd1ca 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index a47aec525e8..0b3f8436254 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -377,8 +377,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo
@ 2020-12-04 23:08 Iain Buclaw
  0 siblings, 0 replies; 13+ messages in thread
From: Iain Buclaw @ 2020-12-04 23:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4026734351e9fe69d6a18b6d26ebc308cd287724

commit 4026734351e9fe69d6a18b6d26ebc308cd287724
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 5 00:08:04 2020 +0100

    darwin: Implement osxVersionMin for getTargetInfo

Diff:
---
 gcc/config/darwin-d.c                        | 54 ++++++++++++++++++++++++++++
 libphobos/libdruntime/core/sys/posix/stdio.d |  7 ++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-d.c b/gcc/config/darwin-d.c
index 7b8c72efe27..9ebc90fd1ca 100644
--- a/gcc/config/darwin-d.c
+++ b/gcc/config/darwin-d.c
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_d.h"
 #include "d/d-target.h"
 #include "d/d-target-def.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_D_OS_VERSIONS for Darwin targets.  */
 
@@ -42,6 +43,58 @@ darwin_d_handle_target_object_format (void)
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
+/* Given an OS X version VERSION_STR, return it as a six digit integer.  */
+
+static unsigned long
+parse_version (const char *version_str)
+{
+  const size_t version_len = strlen (version_str);
+  if (version_len < 1)
+    return 0;
+
+  /* Version string must consist of digits and periods only.  */
+  if (strspn (version_str, "0123456789.") != version_len)
+    return 0;
+
+  if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1]))
+    return 0;
+
+  char *endptr;
+  unsigned long major = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  /* Version string must not contain adjacent periods.  */
+  if (*version_str == '.')
+    return 0;
+
+  unsigned long minor = strtoul (version_str, &endptr, 10);
+  version_str = endptr + ((*endptr == '.') ? 1 : 0);
+
+  unsigned long tiny = strtoul (version_str, &endptr, 10);
+
+  /* Version string must contain no more than three tokens.  */
+  if (*endptr != '\0')
+    return 0;
+
+  return (major * 10000) + (minor * 100) + tiny;
+}
+
+/* Handle a call to `__traits(getTargetInfo, "osxVersionMin")'.  */
+
+static tree
+darwin_d_handle_target_version_min (void)
+{
+  const unsigned long version = parse_version (darwin_macosx_version_min);
+
+  if (version == 0)
+    {
+      error ("unknown value %qs of %<-mmacosx-version-min%>",
+	     darwin_macosx_version_min);
+    }
+
+  return build_int_cst_type (integer_type_node, version);
+}
+
 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Darwin targets.  */
 
 static void
@@ -49,6 +102,7 @@ darwin_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
     { "objectFormat", darwin_d_handle_target_object_format },
+    { "osxVersionMin", darwin_d_handle_target_version_min },
     { NULL, NULL },
   };
 
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index a47aec525e8..0b3f8436254 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -377,8 +377,11 @@ else version (Darwin)
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 
-    ssize_t getdelim(char**, size_t*, int, FILE*);
-    ssize_t getline(char**, size_t*, FILE*);
+    static if (__traits(getTargetInfo, "osxVersionMin") >= 100700)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
 }
 else version (FreeBSD)
 {


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-09-17 14:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19 18:05 [gcc(refs/users/ibuclaw/heads/darwin)] darwin: Implement osxVersionMin for getTargetInfo Iain Buclaw
  -- strict thread matches above, loose matches on Subject: below --
2021-09-17 14:34 Iain Buclaw
2021-04-10 17:00 Iain Buclaw
2021-04-10 15:04 Iain Buclaw
2021-03-14 22:00 Iain Buclaw
2021-03-07 17:01 Iain Buclaw
2021-01-30 19:08 Iain Buclaw
2021-01-28 17:31 Iain Buclaw
2021-01-11 11:39 Iain Buclaw
2020-12-22 13:41 Iain Buclaw
2020-12-09  9:51 Iain Buclaw
2020-12-05 23:47 Iain Buclaw
2020-12-04 23:08 Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).