GCC was configured with @code{--enable-newlib-nano-formatted-io}, which reduces
the code size of Newlib formatted I/O functions.
+@item posix_memalign
+Target supports @code{posix_memalign}.
+
@item pow10
Target provides @code{pow10} function.
@item wchar
Target supports wide characters.
+
+@item weak_undefined
+Target supports weak undefined symbols
@end table
@subsubsection Other attributes
@item tls
Add the target-specific flags needed to use thread-local storage.
+
+@item weak_undefined
+Add the flags needed to enable support for weak undefined symbols.
@end table
@node Require Support
-/* { dg-do run { target { nonpic || pie_enabled } } } */
-/* { dg-require-weak "" } */
+/* { dg-do run { target { { nonpic || pie_enabled } && weak_undefined } } } */
/* { dg-require-alias "" } */
/* { dg-options "-O2 -fdelete-null-pointer-checks" } */
-/* { dg-skip-if "" { powerpc-ibm-aix* } } */
/* { dg-skip-if "function pointers can be NULL" { keeps_null_pointer_checks } } */
+/* { dg-add-options weak_undefined } */
void abort (void);
extern int undef_var0, undef_var1;
extern __attribute__ ((weak)) int weak_undef_var0;
-/* { dg-do run } */
-/* { dg-require-weak "" } */
-/* { dg-skip-if "No undefined" { *-*-mingw* } } */
-/* { dg-skip-if "No undefined weak" { *-*-aix* } } */
-/* { dg-skip-if "No undefined weak" { hppa*-*-hpux* && { ! lp64 } } } */
-/* { dg-skip-if "No undefined weak" { nvptx-*-* } } */
-/* { dg-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */
-/* { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } */
+/* { dg-do run { target { weak_undefined } } } */
+/* { dg-add-options weak_undefined } */
int x(int a)
{
-/* { dg-do run } */
-/* { dg-require-weak "" } */
-/* { dg-skip-if "No undefined weak" { hppa*-*-hpux* && { ! lp64 } } } */
-/* { dg-skip-if "No undefined weak" { nvptx-*-* } } */
-/* { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */
-/* { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } */
+/* { dg-do run { target { posix_memalign } } } */
typedef __SIZE_TYPE__ size_t;
-extern int posix_memalign(void **memptr, size_t alignment, size_t size) __attribute__((weak));
+extern int posix_memalign(void **memptr, size_t alignment, size_t size);
extern void abort(void);
int
main (void)
void *p;
int ret;
- if (!posix_memalign)
- return 0;
-
p = (void *)&ret;
ret = posix_memalign (&p, sizeof (void *), -1);
if (p != (void *)&ret)
-/* { dg-do run } */
-/* { dg-skip-if "No undefined weak" { hppa*-*-hpux* || powerpc-ibm-aix* } } */
-/* { dg-require-weak "" } */
-/* { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */
-/* { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } */
+/* { dg-do run { target { weak_undefined } } } */
+/* { dg-add-options weak_undefined } */
void __attribute__((noinline,noclone))
check (int i)
-/* { dg-require-weak "" } */
-/* { dg-skip-if "No undefined weak" { hppa*-*-hpux* && { ! lp64 } } } */
-/* { dg-skip-if "No undefined weak" { nvptx-*-* } } */
-/* { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */
-/* { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } */
+/* { dg-skip-if "No undefined weak" { ! { posix_memalign } } } */
/* { dg-additional-options "--param vect-epilogues-nomask=1 -mavx2" { target avx2_runtime } } */
#define SIZE 1023
#define ALIGN 64
-extern int posix_memalign(void **memptr, __SIZE_TYPE__ alignment, __SIZE_TYPE__ size) __attribute__((weak));
+extern int posix_memalign(void **memptr, __SIZE_TYPE__ alignment, __SIZE_TYPE__ size);
extern void free (void *);
void __attribute__((noinline))
int
main (int argc, const char **argv)
{
- if (!posix_memalign)
- return 0;
-
run_test ();
return 0;
}
# Test parameter passing. This uses abitest.S which relies on weak
# symbols.
-if { [check_weak_available] } {
+set additional_flags_for_abitest [add_options_for_weak_undefined ""]
+set additional_flags_for_abitest "$additional_flags $additional_flags_for_abitest"
+
+if { [check_effective_target_weak_undefined] } {
foreach src [lsort [glob -nocomplain $srcdir/$subdir/test_*.c]] {
if {[runtest_file_p $runtests $src]} {
c-torture-execute [list $src \
$srcdir/$subdir/abitest.S] \
- $additional_flags
+ $additional_flags_for_abitest
}
}
}
# Test unnamed argument retrieval via the va_arg macro. This uses abitest.S
# which relies on weak symbols.
-if { [check_weak_available] } {
+if { [check_effective_target_weak_undefined] } {
foreach src [lsort [glob -nocomplain $srcdir/$subdir/va_arg-*.c]] {
if {[runtest_file_p $runtests $src]} {
c-torture-execute [list $src \
$srcdir/$subdir/abitest.S] \
- $additional_flags
+ $additional_flags_for_abitest
}
}
}
# Test function return value. This uses abitest.S which relies on
# weak symbols.
-if { [check_weak_available] } {
+if { [check_effective_target_weak_undefined] } {
# Disable -fipa-ra to prevent the compiler from generating
# conflicting code.
- set additional_flags_for_func_ret $additional_flags
+ set additional_flags_for_func_ret $additional_flags_for_abitest
append additional_flags_for_func_ret " -fno-ipa-ra"
foreach src [lsort [glob -nocomplain $srcdir/$subdir/func-ret-*.c]] {
if {[runtest_file_p $runtests $src]} {
c-torture-execute [list $src \
$srcdir/$subdir/abitest.S] \
- $additional_flags_for_func_ret
+ $additional_flags_for_func_ret
}
}
}
}
}
+# return options to add to enable weak undefined symbols.
+
+proc add_options_for_weak_undefined { flags } {
+ if { [istarget *-*-darwin*] } {
+ lappend flags "-Wl,-undefined,dynamic_lookup"
+ if { [istarget *-*-darwin[89]*] } {
+ lappend flags "-Wl,-flat_namespace"
+ }
+ }
+ return $flags
+}
+
# return 1 if weak undefined symbols are supported.
proc check_effective_target_weak_undefined { } {
return [check_runtime weak_undefined {
extern void foo () __attribute__((weak));
int main (void) { if (foo) return 1; return 0; }
- } ""]
+ } [add_options_for_weak_undefined ""]]
}
###############################
return [check_function_available "clone"]
}
+# Return 1 if the target supports posix_memalign, 0 otherwise.
+proc check_effective_target_posix_memalign {} {
+ if { [istarget *-*-vxworks*] } {
+ # VxWorks doesn't have posix_memalign but our way to test
+ # can't tell as we're doing partial links for kernel modules.
+ return 0
+ }
+ return [check_function_available "posix_memalign"]
+}
+
# Return 1 if the target supports setrlimit, 0 otherwise.
proc check_effective_target_setrlimit {} {
# Darwin has non-posix compliant RLIMIT_AS
# VxWorks doesn't have fork but our way to test can't
# tell as we're doing partial links for kernel modules.
return 0
- }
+ }
if { [istarget cris-*-*] } {
# Compiling and linking works, and an executable running e.g.
# gcc.dg/torture/ftrapv-1.c works on now-historical hardware,
} else {
set dg-do-what-default compile
}
- } elseif [istarget "aarch64*-*-*"] {
+ } elseif [istarget aarch64*-*-*] {
set dg-do-what-default run
} elseif [istarget s390*-*-*] {
# The S/390 backend set a default of 2 for that value.