summaryrefslogtreecommitdiffstats
path: root/contrib/gcclibs
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2014-01-26 19:49:54 +0000
committerpfg <pfg@FreeBSD.org>2014-01-26 19:49:54 +0000
commitfe288f1b72a13316f613e06cd07d4d777cd59b99 (patch)
tree388002273457e1ebeee9510b9908dc299e3748f1 /contrib/gcclibs
parent5c96f061e7bff64c2387d5fd90ff095b71ce59b2 (diff)
downloadFreeBSD-src-fe288f1b72a13316f613e06cd07d4d777cd59b99.zip
FreeBSD-src-fe288f1b72a13316f613e06cd07d4d777cd59b99.tar.gz
MFC r260311, r260831:
gcc: Add support for Apple's Block extension Block objects [1] are a C-level syntactic and runtime feature. They are similar to standard C functions, but in addition to executable code they may also contain variable bindings to automatic (stack) or managed (heap) memory. A block can therefore maintain a set of state (data) that it can use to impact behavior when executed. This port is based on Apple's GCC 5646 with some bugfixes from Apple GCC 5666.3. It has some small differences with the support in clang, which remains the recommended compiler. Perhaps the most notable difference is that in GCC __block is not actually a keyword, but a macro. There may be workaround for this issue in the future. Other issues can be consulted in the clang documentation [2] For better compatiblity with Apple's GCC and llvm-gcc, some related fixes and features from Apple have been included. Support for the non-standard nested functions in GCC is now off by default. No effort was made to update the ObjC support since FreeBSD doesn't carry ObjC in the base system but some of the code crept in and was more difficult to remove than to adjust. References: [1] https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html [2] http://clang.llvm.org/compatibility.html#block-variable-initialization Obtained from: Apple GCC 4.2
Diffstat (limited to 'contrib/gcclibs')
-rw-r--r--contrib/gcclibs/include/libiberty.h4
-rw-r--r--contrib/gcclibs/libiberty/physmem.c30
2 files changed, 34 insertions, 0 deletions
diff --git a/contrib/gcclibs/include/libiberty.h b/contrib/gcclibs/include/libiberty.h
index c25667c..c0f5151 100644
--- a/contrib/gcclibs/include/libiberty.h
+++ b/contrib/gcclibs/include/libiberty.h
@@ -296,6 +296,10 @@ extern char *xstrndup (const char *, size_t) ATTRIBUTE_MALLOC;
extern void *xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC;
+/* APPLE LOCAL begin retune gc params 6124839 */
+extern unsigned int ncpu_available (void);
+/* APPLE LOCAL end retune gc params 6124839 */
+
/* Physical memory routines. Return values are in BYTES. */
extern double physmem_total (void);
extern double physmem_available (void);
diff --git a/contrib/gcclibs/libiberty/physmem.c b/contrib/gcclibs/libiberty/physmem.c
index 09fbf3f..3c18169 100644
--- a/contrib/gcclibs/libiberty/physmem.c
+++ b/contrib/gcclibs/libiberty/physmem.c
@@ -182,6 +182,36 @@ physmem_total (void)
return 0;
}
+/* APPLE LOCAL begin retune gc params 6124839 */
+unsigned int
+ncpu_available (void)
+{
+#if HAVE_SYSCTL && defined HW_AVAILCPU
+ { /* This works on *bsd and darwin. */
+ unsigned int ncpu;
+ size_t len = sizeof ncpu;
+ static int mib[2] = { CTL_HW, HW_AVAILCPU };
+
+ if (sysctl (mib, ARRAY_SIZE (mib), &ncpu, &len, NULL, 0) == 0
+ && len == sizeof (ncpu))
+ return ncpu;
+ }
+#endif
+#if HAVE_SYSCTL && defined HW_NCPU
+ { /* This works on *bsd and darwin. */
+ unsigned int ncpu;
+ size_t len = sizeof ncpu;
+ static int mib[2] = { CTL_HW, HW_NCPU };
+
+ if (sysctl (mib, ARRAY_SIZE (mib), &ncpu, &len, NULL, 0) == 0
+ && len == sizeof (ncpu))
+ return ncpu;
+ }
+#endif
+ return 1;
+}
+/* APPLE LOCAL end retune gc params 6124839 */
+
/* Return the amount of physical memory available. */
double
physmem_available (void)
OpenPOWER on IntegriCloud