URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k/trunk/linux/uClibc/test
- from Rev 1325 to Rev 1765
- ↔ Reverse comparison
Rev 1325 → Rev 1765
/testsuite.h
0,0 → 1,117
/* vi: set sw=4 ts=4: */ |
/* |
* Some simple macros for use in test applications. |
* |
* Copyright (C) 2000 by Lineo, inc. and Erik Andersen |
* Copyright (C) 2000,2001 by Erik Andersen <andersen@uclibc.org> |
* Written by Erik Andersen <andersen@uclibc.org> |
* |
* This program is free software; you can redistribute it and/or modify it |
* under the terms of the GNU Library General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or (at your |
* option) any later version. |
* |
* This program is distributed in the hope that it will be useful, but WITHOUT |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License |
* for more details. |
* |
* You should have received a copy of the GNU Library General Public License |
* along with this program; if not, write to the Free Software Foundation, |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
|
#ifndef TESTSUITE_H |
#define TESTSUITE_H |
|
#ifdef __NO_TESTCODE__ |
|
extern size_t test_number; |
|
|
extern void init_testsuite(const char* testname); |
extern void done_testing(void) __attribute__((noreturn)); |
extern void success_msg(int result, const char* command); |
extern void error_msg(int result, int line, const char* file, const char* command); |
|
#else |
|
|
size_t test_number = 0; |
static int failures = 0; |
|
void error_msg(int result, int line, const char* file, const char* command) |
{ |
failures++; |
|
printf("\nFAILED TEST %d: \n\t%s\n", test_number, command); |
printf("AT LINE: %d, FILE: %s\n\n", line, file); |
} |
|
void success_msg(int result, const char* command) |
{ |
#if 0 |
printf("passed test: %s == 0\n", command); |
#endif |
} |
|
void done_testing(void) |
{ |
if (0 < failures) { |
printf("Failed %d tests\n", failures); |
exit(EXIT_FAILURE); |
} else { |
printf("All functions tested sucessfully\n"); |
exit( EXIT_SUCCESS ); |
} |
} |
|
void init_testsuite(const char* testname) |
{ |
printf("%s", testname); |
test_number = 0; |
failures = 0; |
atexit(done_testing); |
} |
|
#endif |
|
|
|
#define TEST_STRING_OUTPUT( command, expected_result ) \ |
do { \ |
int result=strcmp( command, expected_result); \ |
test_number++; \ |
if ( result == expected_result ) { \ |
success_msg( result, "command"); \ |
} else { \ |
error_msg(result, __LINE__, __FILE__, command); \ |
}; \ |
} while (0) |
|
#define TEST_NUMERIC( command, expected_result ) \ |
do { \ |
int result=(command); \ |
test_number++; \ |
if ( result == expected_result ) { \ |
success_msg( result, # command); \ |
} else { \ |
error_msg(result, __LINE__, __FILE__, # command); \ |
}; \ |
} while (0) |
|
#define TEST(command) \ |
do { \ |
int result=(command); \ |
test_number++; \ |
if ( result == 1) { \ |
success_msg( result, # command); \ |
} else { \ |
error_msg(result, __LINE__, __FILE__, # command ); \ |
}; \ |
} while (0) |
|
#define STR_CMD(cmd) cmd |
|
#endif /* TESTSUITE_H */ |
/dlopen/dltest.c
0,0 → 1,45
#include <fcntl.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <dlfcn.h> |
#include <stdint.h> |
|
#ifdef __UCLIBC__ |
extern void _dlinfo(void); |
#endif |
|
int main(int argc, char **argv) |
{ |
int ret = EXIT_SUCCESS; |
void *handle; |
void (*mydltest)(void *value1, void *value2); |
char *error; |
uint32_t *value1, *value2; |
|
handle = dlopen (LIBNAME, RTLD_LAZY); |
if (!handle) { |
fprintf(stderr, "Could not open ./libtest.so: %s\n", dlerror()); |
exit(1); |
} |
|
mydltest = dlsym(handle, "dltest"); |
if ((error = dlerror()) != NULL) { |
fprintf(stderr, "Could not locate symbol 'dltest': %s\n", error); |
exit(1); |
} |
|
mydltest(&value1, &value2); |
printf("dltest: __pthread_once=%p\n", value1); |
printf("dltest: pthread_self=%p\n", value2); |
if (value1 == value2) { |
ret = EXIT_FAILURE; |
printf("dltest: values should NOT be equal Weak values resolved incorrectly!\n"); |
} else { |
printf("dltest: weak symbols resoved correctly.\n"); |
} |
|
dlclose(handle); |
|
return ret; |
} |
|
/dlopen/test1.c
0,0 → 1,33
#include <fcntl.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <dlfcn.h> |
|
#ifdef __UCLIBC__ |
extern void _dlinfo(void); |
#endif |
|
int main(int argc, char **argv) { |
void *handle; |
int (*mydltest)(const char *s); |
char *error; |
|
handle = dlopen ("./libtest1.so", RTLD_LAZY); |
if (!handle) { |
fprintf(stderr, "Could not open ./libtest1.so: %s\n", dlerror()); |
exit(1); |
} |
|
mydltest = dlsym(handle, "dltest"); |
if ((error = dlerror()) != NULL) { |
fprintf(stderr, "Could not locate symbol 'dltest': %s\n", error); |
exit(1); |
} |
|
mydltest("hello world!"); |
|
dlclose(handle); |
|
return EXIT_SUCCESS; |
} |
|
/dlopen/test2.c
0,0 → 1,39
#include <fcntl.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <dlfcn.h> |
|
#ifdef __UCLIBC__ |
extern void _dlinfo(void); |
#endif |
|
int main(int argc, char **argv) { |
void *handle; |
int (*mydltest)(const char *s); |
char *error; |
|
handle = dlopen ("./libtest2.so", RTLD_LAZY); |
if (!handle) { |
fprintf(stderr, "Could not open ./libtest2.so: %s\n", dlerror()); |
exit(1); |
} |
|
handle = dlopen ("./libtest1.so", RTLD_LAZY); |
if (!handle) { |
fprintf(stderr, "Could not open ./libtest1.so: %s\n", dlerror()); |
exit(1); |
} |
|
mydltest = dlsym(handle, "dltest"); |
if ((error = dlerror()) != NULL) { |
fprintf(stderr, "Could not locate symbol 'dltest': %s\n", error); |
exit(1); |
} |
|
mydltest("hello world!"); |
|
dlclose(handle); |
|
return EXIT_SUCCESS; |
} |
|
/dlopen/test3.c
0,0 → 1,13
#include <fcntl.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <dlfcn.h> |
|
extern int dltest(const char *s); |
|
int main(int argc, char **argv) |
{ |
dltest("hello world!"); |
return EXIT_SUCCESS; |
} |
|
/dlopen/libtest.c
0,0 → 1,12
#include <stdio.h> |
#include <pthread.h> |
#include <stdint.h> |
|
extern int __pthread_once(void); |
|
void dltest(uint32_t **value1, uint32_t **value2) |
{ |
*value1 = (uint32_t *) __pthread_once; |
*value2 = (uint32_t *) pthread_self; |
} |
|
/dlopen/libtest1.c
0,0 → 1,37
#include <stdio.h> |
|
extern int libtest2_func(const char *s); |
|
|
void __attribute__((constructor)) libtest1_ctor(void) |
{ |
printf("libtest1: constructor!\n"); |
} |
|
void __attribute__((destructor)) libtest1_dtor(void) |
{ |
printf("libtest1: destructor!\n"); |
} |
|
void __attribute__((weak)) function1(void) |
{ |
printf("libtest1: I am weak function1!\n"); |
} |
|
void function2(void) |
{ |
printf("libtest1: I am function2!\n"); |
} |
|
|
int dltest(const char *s) |
{ |
printf( "libtest1: function1 = %p\n" |
"libtest1: function2 = %p\n", |
function1, function2); |
function1(); |
function2(); |
return(libtest2_func(s)); |
} |
|
|
/dlopen/libtest2.c
0,0 → 1,38
#include <stdio.h> |
#include <pthread.h> |
|
|
extern int __pthread_mutex_init (void); |
|
void __attribute__((constructor)) libtest2_ctor(void) |
{ |
printf("libtest2: constructor!\n"); |
} |
|
void __attribute__((destructor)) libtest2_dtor(void) |
{ |
printf("libtest2: destructor!\n"); |
} |
|
void function1(void) |
{ |
printf("libtest2: I am function1!\n"); |
} |
|
void __attribute__((weak)) function2(void) |
{ |
printf("libtest2: I am weak function2!\n"); |
} |
|
|
int libtest2_func(const char *s) |
{ |
printf( "libtest2: function1 = %p\n" |
"libtest2: function2 = %p\n", |
function1, function2); |
function1(); |
function2(); |
return 0; |
} |
|
|
/dlopen/Makefile
0,0 → 1,76
# Makefile for uClibc |
# |
# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org> |
# |
# This program is free software; you can redistribute it and/or modify it under |
# the terms of the GNU Library General Public License as published by the Free |
# Software Foundation; either version 2 of the License, or (at your option) any |
# later version. |
# |
# This program is distributed in the hope that it will be useful, but WITHOUT |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more |
# details. |
# |
# You should have received a copy of the GNU Library General Public License |
# along with this program; if not, write to the Free Software Foundation, Inc., |
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
# Makefile for uClibc |
|
TESTDIR=../ |
include $(TESTDIR)/Rules.mak |
DEBUG_LIBS=X |
#DEBUG_LIBS=LD_DEBUG |
|
all: run |
|
test1: test1.c |
$(CC) $(CFLAGS) $(LDFLAGS) -o test1 test1.c -ldl |
|
test2: test2.c |
$(CC) $(CFLAGS) $(LDFLAGS) -o test2 test2.c -ldl |
|
test3: test3.c |
$(CC) $(CFLAGS) $(LDFLAGS) -o test3 test3.c -ldl ./libtest1.so ./libtest2.so |
|
libtest1.o: libtest1.c |
$(CC) $(CFLAGS) $(LDFLAGS) -fPIC -c libtest1.c -o libtest1.o |
|
libtest2.o: libtest2.c |
$(CC) $(CFLAGS) $(LDFLAGS) -fPIC -c libtest2.c -o libtest2.o |
|
libtest1.so: libtest1.o |
$(CC) $(CFLAGS) -fPIC -shared -o libtest1.so -Wl,-soname,libtest1.so libtest1.o ./libtest2.so |
|
libtest2.so: libtest2.o |
$(CC) $(CFLAGS) -fPIC -shared -o libtest2.so -Wl,-soname,libtest2.so libtest2.o |
|
dltest: dltest.c |
$(CC) $(CFLAGS) $(LDFLAGS) -DLIBNAME="\"./libtest.so\"" dltest.c -ldl -lpthread -o dltest |
|
libtest.so: libtest.c |
$(CC) $(CFLAGS) -fPIC -shared -Wl,-soname,libtest.so libtest.c -o libtest.so |
|
# Second time, directly link libtest3.so with libpthread |
dltest2: dltest.c |
$(CC) $(CFLAGS) $(LDFLAGS) -DLIBNAME="\"./libtest3.so\"" dltest.c -ldl -lpthread -o dltest2 |
|
libtest3.so: libtest.c |
$(CC) $(CFLAGS) -fPIC -shared -Wl,-soname,libtest3.so libtest.c -o libtest3.so -lpthread |
|
run: libtest2.so libtest1.so test1 test2 test3 dltest libtest.so dltest2 libtest3.so |
@echo "----------running test 1--------------" |
-LD_LIBRARY_PATH=`pwd`:. $(DEBUG_LIBS)=all ./test1 |
@echo "----------running test 2--------------" |
-LD_LIBRARY_PATH=`pwd`:. $(DEBUG_LIBS)=all ./test2 |
@echo "----------running test 3--------------" |
-LD_LIBRARY_PATH=`pwd`:. $(DEBUG_LIBS)=all ./test3 |
@echo "----------running test 3--------------" |
-$(DEBUG_LIBS)=all ./dltest2 |
@echo "----------running test 4--------------" |
-$(DEBUG_LIBS)=all ./dltest |
|
clean: |
$(RM) *.o libtest1.so* libtest2.so* test1 test2 test3 \ |
dltest dltest2 libtest.so libtest3.so |
|
dlopen
Property changes :
Added: svn:ignore
## -0,0 +1,13 ##
+dltest
+libhowdy.so
+dltest2
+dlttest
+dlttest2
+test1
+test2
+test3
+dltest
+dltest2
+libtest.so
+libtest3.so
+.gdbinit
Index: stdlib/testatexit.c
===================================================================
--- stdlib/testatexit.c (nonexistent)
+++ stdlib/testatexit.c (revision 1765)
@@ -0,0 +1,75 @@
+/*
+ * This test program will register the maximum number of exit functions
+ * with atexit(). When this program exits, each exit function should get
+ * called in the reverse order in which it was registered. (If the system
+ * supports more than 25 exit functions, the function names will loop, but
+ * the effect will be the same. Feel free to add more functions if desired)
+ */
+#include
+#include
+
+typedef void (*vfuncp) (void);
+
+/* All functions call exit(), in order to test that exit functions can call
+ * exit() without screwing everything up. :)
+ */
+static void exitfunc0(void) { printf("Executing exitfunc0.\n"); exit(0);}
+static void exitfunc1(void) { printf("Executing exitfunc1.\n"); exit(0);}
+static void exitfunc2(void) { printf("Executing exitfunc2.\n"); exit(0);}
+static void exitfunc3(void) { printf("Executing exitfunc3.\n"); exit(0);}
+static void exitfunc4(void) { printf("Executing exitfunc4.\n"); exit(0);}
+static void exitfunc5(void) { printf("Executing exitfunc5.\n"); exit(0);}
+static void exitfunc6(void) { printf("Executing exitfunc6.\n"); exit(0);}
+static void exitfunc7(void) { printf("Executing exitfunc7.\n"); exit(0);}
+static void exitfunc8(void) { printf("Executing exitfunc8.\n"); exit(0);}
+static void exitfunc9(void) { printf("Executing exitfunc9.\n"); exit(0);}
+static void exitfunc10(void) { printf("Executing exitfunc10.\n"); exit(0);}
+static void exitfunc11(void) { printf("Executing exitfunc11.\n"); exit(0);}
+static void exitfunc12(void) { printf("Executing exitfunc12.\n"); exit(0);}
+static void exitfunc13(void) { printf("Executing exitfunc13.\n"); exit(0);}
+static void exitfunc14(void) { printf("Executing exitfunc14.\n"); exit(0);}
+static void exitfunc15(void) { printf("Executing exitfunc15.\n"); exit(0);}
+static void exitfunc16(void) { printf("Executing exitfunc16.\n"); exit(0);}
+static void exitfunc17(void) { printf("Executing exitfunc17.\n"); exit(0);}
+static void exitfunc18(void) { printf("Executing exitfunc18.\n"); exit(0);}
+static void exitfunc19(void) { printf("Executing exitfunc19.\n"); exit(0);}
+static void exitfunc20(void) { printf("Executing exitfunc20.\n"); exit(0);}
+static void exitfunc21(void) { printf("Executing exitfunc21.\n"); exit(0);}
+static void exitfunc22(void) { printf("Executing exitfunc22.\n"); exit(0);}
+static void exitfunc23(void) { printf("Executing exitfunc23.\n"); exit(0);}
+static void exitfunc24(void) { printf("Executing exitfunc24.\n"); exit(0);}
+
+static vfuncp func_table[] =
+ {
+ exitfunc0, exitfunc1, exitfunc2, exitfunc3, exitfunc4,
+ exitfunc5, exitfunc6, exitfunc7, exitfunc8, exitfunc9,
+ exitfunc10, exitfunc11, exitfunc12, exitfunc13, exitfunc14,
+ exitfunc15, exitfunc16, exitfunc17, exitfunc18, exitfunc19,
+ exitfunc20, exitfunc21, exitfunc22, exitfunc23, exitfunc24
+ };
+
+/* glibc dynamically adds exit functions, so it will keep adding until
+ * it runs out of memory! So this will limit the number of exit functions
+ * we add in the loop below. uClibc has a set limit (currently 20), so the
+ * loop will go until it can't add any more (so it should not hit this limit).
+ */
+#define ATEXIT_LIMIT 20
+
+int
+main ( void )
+{
+ int i = 0;
+ int count = 0;
+ int numfuncs = sizeof(func_table)/sizeof(vfuncp);
+
+ /* loop until no more can be added */
+ while(count < ATEXIT_LIMIT && atexit(func_table[i]) >= 0) {
+ printf("Registered exitfunc%d with atexit()\n", i);
+ count++;
+ i = (i+1) % numfuncs;
+ }
+ printf("%d functions registered with atexit.\n", count);
+
+ return 0;
+}
+
Index: stdlib/teston_exit.c
===================================================================
--- stdlib/teston_exit.c (nonexistent)
+++ stdlib/teston_exit.c (revision 1765)
@@ -0,0 +1,75 @@
+/*
+ * This test program will register the maximum number of exit functions
+ * with on_exit(). When this program exits, each exit function should get
+ * called in the reverse order in which it was registered. (If the system
+ * supports more than 25 exit functions, the function names will loop, but
+ * the effect will be the same. Feel free to add more functions if desired)
+ */
+#include
+#include
+
+typedef void (*efuncp) (int, void *);
+
+/* All functions call exit(), in order to test that exit functions can call
+ * exit() without screwing everything up. The value passed in through arg gets
+ * used as the next exit status.
+ */
+static void exitfunc0(int status, void *arg) { printf("Executing exitfunc0 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc1(int status, void *arg) { printf("Executing exitfunc1 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc2(int status, void *arg) { printf("Executing exitfunc2 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc3(int status, void *arg) { printf("Executing exitfunc3 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc4(int status, void *arg) { printf("Executing exitfunc4 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc5(int status, void *arg) { printf("Executing exitfunc5 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc6(int status, void *arg) { printf("Executing exitfunc6 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc7(int status, void *arg) { printf("Executing exitfunc7 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc8(int status, void *arg) { printf("Executing exitfunc8 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc9(int status, void *arg) { printf("Executing exitfunc9 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc10(int status, void *arg) { printf("Executing exitfunc10 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc11(int status, void *arg) { printf("Executing exitfunc11 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc12(int status, void *arg) { printf("Executing exitfunc12 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc13(int status, void *arg) { printf("Executing exitfunc13 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc14(int status, void *arg) { printf("Executing exitfunc14 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc15(int status, void *arg) { printf("Executing exitfunc15 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc16(int status, void *arg) { printf("Executing exitfunc16 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc17(int status, void *arg) { printf("Executing exitfunc17 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc18(int status, void *arg) { printf("Executing exitfunc18 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc19(int status, void *arg) { printf("Executing exitfunc19 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc20(int status, void *arg) { printf("Executing exitfunc20 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc21(int status, void *arg) { printf("Executing exitfunc21 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc22(int status, void *arg) { printf("Executing exitfunc22 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc23(int status, void *arg) { printf("Executing exitfunc23 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+static void exitfunc24(int status, void *arg) { printf("Executing exitfunc24 (status=%d, arg=%d)\n", status, (int)arg); exit((int)arg);}
+
+static efuncp func_table[] =
+ {
+ exitfunc0, exitfunc1, exitfunc2, exitfunc3, exitfunc4,
+ exitfunc5, exitfunc6, exitfunc7, exitfunc8, exitfunc9,
+ exitfunc10, exitfunc11, exitfunc12, exitfunc13, exitfunc14,
+ exitfunc15, exitfunc16, exitfunc17, exitfunc18, exitfunc19,
+ exitfunc20, exitfunc21, exitfunc22, exitfunc23, exitfunc24
+ };
+
+/* glibc dynamically adds exit functions, so it will keep adding until
+ * it runs out of memory! So this will limit the number of exit functions
+ * we add in the loop below. uClibc has a set limit (currently 20), so the
+ * loop will go until it can't add any more (so it should not hit this limit).
+ */
+#define ON_EXIT_LIMIT 20
+
+int
+main ( void )
+{
+ int i = 0;
+ int count = 0;
+ int numfuncs = sizeof(func_table)/sizeof(efuncp);
+
+ /* loop until no more can be added */
+ while(count < ON_EXIT_LIMIT && on_exit(func_table[i], (void *)count) >= 0) {
+ count++;
+ printf("Registered exitfunc%d with on_exit()\n", i);
+ i = (i+1) % numfuncs;
+ }
+ printf("%d functions registered with on_exit.\n", count);
+ exit(count);
+}
+
Index: stdlib/teststrtol.c
===================================================================
--- stdlib/teststrtol.c (nonexistent)
+++ stdlib/teststrtol.c (revision 1765)
@@ -0,0 +1,109 @@
+
+#include
+#include
+
+
+const char *strings[]={
+ /* some simple stuff */
+ "0", "1", "10",
+ "100", "1000", "10000", "100000", "1000000",
+ "10000000", "100000000", "1000000000",
+
+ /* negative */
+ "-0", "-1", "-10",
+ "-100", "-1000", "-10000", "-100000", "-1000000",
+ "-10000000", "-100000000", "-1000000000",
+
+ /* test base>10 */
+ "a", "b", "f", "g", "z",
+
+ /* test hex */
+ "0x0", "0x1", "0xa", "0xf", "0x10",
+
+ /* test octal */
+ "00", "01", "07", "08", "0a", "010",
+
+ /* other */
+ "0x8000000",
+
+ /* check overflow cases: (for 32 bit) */
+ "2147483645",
+ "2147483646",
+ "2147483647",
+ "2147483648",
+ "2147483649",
+ "-2147483645",
+ "-2147483646",
+ "-2147483647",
+ "-2147483648",
+ "-2147483649",
+ "4294967293",
+ "4294967294",
+ "4294967295",
+ "4294967296",
+ "4294967297",
+ "-4294967293",
+ "-4294967294",
+ "-4294967295",
+ "-4294967296",
+ "-4294967297",
+
+ /* bad input tests */
+ "",
+ "00",
+ "0x",
+ "0x0",
+ "-",
+ "+",
+ " ",
+ " -",
+ " - 0",
+};
+int n_tests=sizeof(strings)/sizeof(strings[0]);
+
+void do_test(int base);
+void do_utest(int base);
+
+int main(int argc,char *argv[])
+{
+ do_test(0);
+ do_test(8);
+ do_test(10);
+ do_test(16);
+ do_test(36);
+
+ do_utest(0);
+ do_utest(8);
+ do_utest(10);
+ do_utest(16);
+ do_utest(36);
+
+ return 0;
+}
+
+void do_test(int base)
+{
+ int i;
+ long n;
+ char *endptr;
+
+ for(i=0;i
+#include
+#include
+#include
+
+int select_files(const struct dirent *dirbuf)
+{
+ if (dirbuf->d_name[0] == '.')
+ return 0;
+ else
+ return 1;
+}
+
+
+int main(void)
+{
+ struct dirent **array;
+ struct dirent *dirbuf;
+
+ int i, numdir;
+
+ chdir("/");
+ numdir = scandir(".", &array, select_files, NULL);
+ printf("\nGot %d entries from scandir().\n", numdir);
+ for (i = 0; i < numdir; ++i) {
+ dirbuf = array[i];
+ printf("[%d] %s\n", i, dirbuf->d_name);
+ free(array[i]);
+ }
+ free(array);
+ numdir = scandir(".", &array, select_files, alphasort);
+ printf("\nGot %d entries from scandir() using alphasort().\n", numdir);
+ for (i = 0; i < numdir; ++i) {
+ dirbuf = array[i];
+ printf("[%d] %s\n", i, dirbuf->d_name);
+ }
+ printf("\nCalling qsort()\n");
+ qsort(array, numdir, sizeof(struct dirent *), alphasort);
+ for (i = 0; i < numdir; ++i) {
+ dirbuf = array[i];
+ printf("[%d] %s\n", i, dirbuf->d_name);
+ free(array[i]);
+ }
+ free(array);
+ return(0);
+}
+
Index: stdlib/Makefile
===================================================================
--- stdlib/Makefile (nonexistent)
+++ stdlib/Makefile (revision 1765)
@@ -0,0 +1,192 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+
+TARGETS+=teststrtol teststrtol_glibc teststrtol_diff
+TARGETS+=qsort qsort_glibc qsort_diff
+TARGETS+=teston_exit teston_exit_glibc teston_exit_diff
+TARGETS+=testatexit testatexit_glibc testatexit_diff
+TARGETS+=ptytest
+
+all: $(TARGETS)
+
+teststrtol_source:
+ -@ echo "-------"
+ -@ echo "teststrtol.c source: "
+ -@ echo " "
+ -@ cat teststrtol.c
+ -@ echo " "
+
+teststrtol: teststrtol.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@ > $@.out
+ -@ echo " "
+
+teststrtol_glibc: teststrtol.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@ > $@.out
+ -@ echo " "
+
+teststrtol_diff: teststrtol_glibc teststrtol
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u teststrtol_glibc.out teststrtol.out
+ -@ echo " "
+
+qsort: qsort.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@ > $@.out
+ -@ echo " "
+
+qsort_glibc: qsort.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@ > $@.out
+ -@ echo " "
+
+qsort_diff: qsort_glibc qsort
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u qsort_glibc.out qsort.out
+ -@ echo " "
+
+teston_exit: teston_exit.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@ > $@.out
+ -@ echo " "
+
+teston_exit_glibc: teston_exit.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@ > $@.out
+ -@ echo " "
+
+teston_exit_diff: teston_exit_glibc teston_exit
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u teston_exit_glibc.out teston_exit.out
+ -@ echo " "
+
+testatexit: testatexit.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@ > $@.out
+ -@ echo " "
+
+testatexit_glibc: testatexit.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@ > $@.out
+ -@ echo " "
+
+testatexit_diff: testatexit_glibc testatexit
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u testatexit_glibc.out testatexit.out
+ -@ echo " "
+
+ptytest: ptytest.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS) *.out
+
+
Index: stdlib/ptytest.c
===================================================================
--- stdlib/ptytest.c (nonexistent)
+++ stdlib/ptytest.c (revision 1765)
@@ -0,0 +1,20 @@
+#define _XOPEN_SOURCE
+#include
+#include
+#include
+#include
+#include
+
+int main()
+{
+ int fd;
+ char *cp;
+
+ fd=open("/dev/ptmx",O_NOCTTY|O_RDWR);
+ cp=ptsname(fd);
+ if (cp==NULL)
+ return EXIT_FAILURE;
+ printf("ptsname %s\n",cp);
+ return EXIT_SUCCESS;
+}
+
Index: stdlib
===================================================================
--- stdlib (nonexistent)
+++ stdlib (revision 1765)
stdlib
Property changes :
Added: svn:ignore
## -0,0 +1,22 ##
+teststrtol
+teststrtol_glibc
+teststrtol.o
+teststrtol.out
+teststrtol_glibc.out
+qsort
+qsort_glibc
+qsort.out
+qsort_glibc.out
+mallocbug
+mallocbug_glibc
+testatexit
+testatexit.out
+testatexit_glibc
+testatexit_glibc.out
+testmalloc
+testmalloc_glibc
+teston_exit
+teston_exit.out
+teston_exit_glibc
+teston_exit_glibc.out
+ptytest
Index: termios/termios.c
===================================================================
--- termios/termios.c (nonexistent)
+++ termios/termios.c (revision 1765)
@@ -0,0 +1,24 @@
+#include
+#include
+#include
+#include
+#include
+
+int main(int argc,char *argv[])
+{
+ struct termios t;
+ int ret;
+
+ printf("TCGETS = 0x%08x\n",TCGETS);
+ printf("sizeof(struct termios) = %d\n",sizeof(struct termios));
+
+ ret = ioctl(fileno(stdout),TCGETS,&t);
+
+ if(ret<0){
+ perror("ioctl");
+ }else{
+ printf("ioctl returned %d\n",ret);
+ }
+
+ return 0;
+}
Index: termios/Makefile
===================================================================
--- termios/Makefile (nonexistent)
+++ termios/Makefile (revision 1765)
@@ -0,0 +1,57 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+
+TARGETS=termios termios_glibc
+
+all: $(TARGETS)
+
+termios: termios.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+termios_glibc: termios.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
+
Index: termios
===================================================================
--- termios (nonexistent)
+++ termios (revision 1765)
termios
Property changes :
Added: svn:ignore
## -0,0 +1,4 ##
+termios
+termios.o
+termios_glibc
+termios_glibc.o
Index: ctype/ctype.c
===================================================================
--- ctype/ctype.c (nonexistent)
+++ ctype/ctype.c (revision 1765)
@@ -0,0 +1,264 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Test application for functions defined in ctype.h
+ *
+ * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 2000,2001 by Erik Andersen
+ * Written by Erik Andersen
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include "../testsuite.h"
+
+
+int main( int argc, char **argv)
+{
+ int i, c;
+
+
+ init_testsuite("Testing functions defined in ctype.h\n");
+
+ /* isalnum() */
+ {
+ int buffer[]={ '1', '4', 'a', 'z', 'A', 'Z', '5', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isalnum(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 2, 128, 254, '\n', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isalnum(c)==0);
+ }
+ }
+
+
+
+ /* isalpha() */
+ {
+ int buffer[]={ 'a', 'z', 'A', 'Z', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isalpha(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 2, 63, 128, 254, '\n', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isalpha(c)==0);
+ }
+ }
+
+
+
+ /* isascii() */
+ {
+ int buffer[]={ 'a', 'z', 'A', 'Z', '\n', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isascii(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 128, 254, -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isascii(c)==0);
+ }
+ }
+
+
+ /* iscntrl() */
+ {
+ int buffer[]={ 0x7F, 6, '\t', '\n', 0x7F, -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( iscntrl(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 63, 128, 254, -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( iscntrl(c)==0);
+ }
+ }
+
+
+ /* isdigit() */
+ {
+ int buffer[]={ '1', '5', '7', '9', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isdigit(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 2, 'a', 'z', 'A', 'Z', 63, 128, 254, '\n', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isdigit(c)==0);
+ }
+ }
+
+
+
+ /* isgraph() */
+ {
+ int buffer[]={ ')', '~', '9', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isgraph(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 9, ' ', '\t', '\n', 200, 0x7F, -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isgraph(c)==0);
+ }
+ }
+
+
+ /* islower() */
+ {
+ int buffer[]={ 'a', 'g', 'z', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( islower(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 9, 'A', 'Z', 128, 254, ' ', '\t', '\n', 0x7F, -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( islower(c)==0);
+ }
+ }
+
+
+ /* isprint() */
+ {
+ int buffer[]={ ' ', ')', '~', '9', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isprint(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ '\b', '\t', '\n', 9, 128, 254, 200, 0x7F, -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isprint(c)==0);
+ }
+ }
+
+
+ /* ispunct() */
+ {
+ int buffer[]={ '.', '#', '@', ';', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( ispunct(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 2, 'a', 'Z', '1', 128, 254, '\n', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( ispunct(c)==0);
+ }
+ }
+
+
+ /* isspace() */
+ {
+ int buffer[]={ ' ', '\t', '\r', '\v', '\n', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isspace(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 2, 'a', 'Z', '1', 128, 254, -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isspace(c)==0);
+ }
+ }
+
+
+ /* isupper() */
+ {
+ int buffer[]={ 'A', 'G', 'Z', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isupper(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 2, 'a', 'z', '1', 128, 254, -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isupper(c)==0);
+ }
+ }
+
+
+
+ /* isxdigit() */
+ {
+ int buffer[]={ 'f', 'A', '1', '8', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isxdigit(c)!=0);
+ }
+ }
+ {
+ int buffer[]={ 2, 'g', 'G', 'x', '\n', -1};
+ for(i=0; buffer[i]!=-1; i++) {
+ c = buffer[i];
+ TEST( isxdigit(c)==0);
+ }
+ }
+
+
+ /* tolower() */
+ c='A';
+ TEST_NUMERIC( tolower(c), 'a');
+ c='a';
+ TEST_NUMERIC( tolower(c), 'a');
+ c='#';
+ TEST_NUMERIC( tolower(c), c);
+
+ /* toupper() */
+ c='a';
+ TEST_NUMERIC( toupper(c), 'A');
+ c='A';
+ TEST_NUMERIC( toupper(c), 'A');
+ c='#';
+ TEST_NUMERIC( toupper(c), c);
+
+ exit(0);
+}
Index: ctype/Makefile
===================================================================
--- ctype/Makefile (nonexistent)
+++ ctype/Makefile (revision 1765)
@@ -0,0 +1,40 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+TARGETS=ctype ctype_run
+all: $(TARGETS)
+
+ctype: ctype.c ../testsuite.h Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+
+ctype_run:
+ ./ctype
+ -@ echo " "
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
+
Index: ctype
===================================================================
--- ctype (nonexistent)
+++ ctype (revision 1765)
ctype
Property changes :
Added: svn:ignore
## -0,0 +1,4 ##
+ctype
+ctype.o
+ctype_glibc
+ctype_glibc.o
Index: pthread/ex2.c
===================================================================
--- pthread/ex2.c (nonexistent)
+++ pthread/ex2.c (revision 1765)
@@ -0,0 +1,113 @@
+/* The classic producer-consumer example.
+ Illustrates mutexes and conditions.
+ All integers between 0 and 9999 should be printed exactly twice,
+ once to the right of the arrow and once to the left. */
+
+#include
+#include "pthread.h"
+
+#define BUFFER_SIZE 16
+
+/* Circular buffer of integers. */
+
+struct prodcons {
+ int buffer[BUFFER_SIZE]; /* the actual data */
+ pthread_mutex_t lock; /* mutex ensuring exclusive access to buffer */
+ int readpos, writepos; /* positions for reading and writing */
+ pthread_cond_t notempty; /* signaled when buffer is not empty */
+ pthread_cond_t notfull; /* signaled when buffer is not full */
+};
+
+/* Initialize a buffer */
+
+void init(struct prodcons * b)
+{
+ pthread_mutex_init(&b->lock, NULL);
+ pthread_cond_init(&b->notempty, NULL);
+ pthread_cond_init(&b->notfull, NULL);
+ b->readpos = 0;
+ b->writepos = 0;
+}
+
+/* Store an integer in the buffer */
+
+void put(struct prodcons * b, int data)
+{
+ pthread_mutex_lock(&b->lock);
+ /* Wait until buffer is not full */
+ while ((b->writepos + 1) % BUFFER_SIZE == b->readpos) {
+ pthread_cond_wait(&b->notfull, &b->lock);
+ /* pthread_cond_wait reacquired b->lock before returning */
+ }
+ /* Write the data and advance write pointer */
+ b->buffer[b->writepos] = data;
+ b->writepos++;
+ if (b->writepos >= BUFFER_SIZE) b->writepos = 0;
+ /* Signal that the buffer is now not empty */
+ pthread_cond_signal(&b->notempty);
+ pthread_mutex_unlock(&b->lock);
+}
+
+/* Read and remove an integer from the buffer */
+
+int get(struct prodcons * b)
+{
+ int data;
+ pthread_mutex_lock(&b->lock);
+ /* Wait until buffer is not empty */
+ while (b->writepos == b->readpos) {
+ pthread_cond_wait(&b->notempty, &b->lock);
+ }
+ /* Read the data and advance read pointer */
+ data = b->buffer[b->readpos];
+ b->readpos++;
+ if (b->readpos >= BUFFER_SIZE) b->readpos = 0;
+ /* Signal that the buffer is now not full */
+ pthread_cond_signal(&b->notfull);
+ pthread_mutex_unlock(&b->lock);
+ return data;
+}
+
+/* A test program: one thread inserts integers from 1 to 10000,
+ the other reads them and prints them. */
+
+#define OVER (-1)
+
+struct prodcons buffer;
+
+void * producer(void * data)
+{
+ int n;
+ for (n = 0; n < 10000; n++) {
+ printf("%d --->\n", n);
+ put(&buffer, n);
+ }
+ put(&buffer, OVER);
+ return NULL;
+}
+
+void * consumer(void * data)
+{
+ int d;
+ while (1) {
+ d = get(&buffer);
+ if (d == OVER) break;
+ printf("---> %d\n", d);
+ }
+ return NULL;
+}
+
+int main(void)
+{
+ pthread_t th_a, th_b;
+ void * retval;
+
+ init(&buffer);
+ /* Create the threads */
+ pthread_create(&th_a, NULL, producer, 0);
+ pthread_create(&th_b, NULL, consumer, 0);
+ /* Wait until producer and consumer finish. */
+ pthread_join(th_a, &retval);
+ pthread_join(th_b, &retval);
+ return 0;
+}
Index: pthread/ex3.c
===================================================================
--- pthread/ex3.c (nonexistent)
+++ pthread/ex3.c (revision 1765)
@@ -0,0 +1,152 @@
+/* Multi-thread searching.
+ Illustrates: thread cancellation, cleanup handlers. */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+/* Defines the number of searching threads */
+#define NUM_THREADS 5
+
+/* Function prototypes */
+void *search(void *);
+void print_it(void *);
+
+/* Global variables */
+pthread_t threads[NUM_THREADS];
+pthread_mutex_t lock;
+int tries;
+volatile int started;
+
+int main(int argc, char ** argv)
+{
+ int i;
+ int pid;
+
+ /* create a number to search for */
+ pid = getpid();
+ printf("Searching for the number = %d...\n", pid);
+
+ /* Initialize the mutex lock */
+ pthread_mutex_init(&lock, NULL);
+
+ /* Create the searching threads */
+ for (started=0; started
+#include
+#include
+#include
+#include
+
+/* This is a typical example of a library function that uses
+ static variables to accumulate results between calls.
+ Here, it just returns the concatenation of all string arguments
+ that were given to it. */
+
+#if 0
+
+char * str_accumulate(char * s)
+{
+ static char accu[1024] = { 0 };
+ strcat(accu, s);
+ return accu;
+}
+
+#endif
+
+/* Of course, this cannot be used in a multi-threaded program
+ because all threads store "accu" at the same location.
+ So, we'll use thread-specific data to have a different "accu"
+ for each thread. */
+
+/* Key identifying the thread-specific data */
+static pthread_key_t str_key;
+/* "Once" variable ensuring that the key for str_alloc will be allocated
+ exactly once. */
+static pthread_once_t str_alloc_key_once = PTHREAD_ONCE_INIT;
+
+/* Forward functions */
+static void str_alloc_key(void);
+static void str_alloc_destroy_accu(void * accu);
+
+/* Thread-safe version of str_accumulate */
+
+char * str_accumulate(const char * s)
+{
+ char * accu;
+
+ /* Make sure the key is allocated */
+ pthread_once(&str_alloc_key_once, str_alloc_key);
+ /* Get the thread-specific data associated with the key */
+ accu = (char *) pthread_getspecific(str_key);
+ /* It's initially NULL, meaning that we must allocate the buffer first. */
+ if (accu == NULL) {
+ accu = malloc(1024);
+ if (accu == NULL) return NULL;
+ accu[0] = 0;
+ /* Store the buffer pointer in the thread-specific data. */
+ pthread_setspecific(str_key, (void *) accu);
+ printf("Thread %lx: allocating buffer at %p\n", pthread_self(), accu);
+ }
+ /* Now we can use accu just as in the non thread-safe code. */
+ strcat(accu, s);
+ return accu;
+}
+
+/* Function to allocate the key for str_alloc thread-specific data. */
+
+static void str_alloc_key(void)
+{
+ pthread_key_create(&str_key, str_alloc_destroy_accu);
+ printf("Thread %lx: allocated key %d\n", pthread_self(), str_key);
+}
+
+/* Function to free the buffer when the thread exits. */
+/* Called only when the thread-specific data is not NULL. */
+
+static void str_alloc_destroy_accu(void * accu)
+{
+ printf("Thread %lx: freeing buffer at %p\n", pthread_self(), accu);
+ free(accu);
+}
+
+/* Test program */
+
+void * process(void * arg)
+{
+ char * res;
+ res = str_accumulate("Result of ");
+ res = str_accumulate((char *) arg);
+ res = str_accumulate(" thread");
+ printf("Thread %lx: \"%s\"\n", pthread_self(), res);
+ return NULL;
+}
+
+int main(int argc, char ** argv)
+{
+ char * res;
+ pthread_t th1, th2;
+
+ res = str_accumulate("Result of ");
+ pthread_create(&th1, NULL, process, (void *) "first");
+ pthread_create(&th2, NULL, process, (void *) "second");
+ res = str_accumulate("initial thread");
+ printf("Thread %lx: \"%s\"\n", pthread_self(), res);
+ pthread_join(th1, NULL);
+ pthread_join(th2, NULL);
+ exit(0);
+}
Index: pthread/ex5.c
===================================================================
--- pthread/ex5.c (nonexistent)
+++ pthread/ex5.c (revision 1765)
@@ -0,0 +1,102 @@
+/* The classic producer-consumer example, implemented with semaphores.
+ All integers between 0 and 9999 should be printed exactly twice,
+ once to the right of the arrow and once to the left. */
+
+#include
+#include "pthread.h"
+#include "semaphore.h"
+
+#define BUFFER_SIZE 16
+
+/* Circular buffer of integers. */
+
+struct prodcons {
+ int buffer[BUFFER_SIZE]; /* the actual data */
+ int readpos, writepos; /* positions for reading and writing */
+ sem_t sem_read; /* number of elements available for reading */
+ sem_t sem_write; /* number of locations available for writing */
+};
+
+/* Initialize a buffer */
+
+void init(struct prodcons * b)
+{
+ sem_init(&b->sem_write, 0, BUFFER_SIZE - 1);
+ sem_init(&b->sem_read, 0, 0);
+ b->readpos = 0;
+ b->writepos = 0;
+}
+
+/* Store an integer in the buffer */
+
+void put(struct prodcons * b, int data)
+{
+ /* Wait until buffer is not full */
+ sem_wait(&b->sem_write);
+ /* Write the data and advance write pointer */
+ b->buffer[b->writepos] = data;
+ b->writepos++;
+ if (b->writepos >= BUFFER_SIZE) b->writepos = 0;
+ /* Signal that the buffer contains one more element for reading */
+ sem_post(&b->sem_read);
+}
+
+/* Read and remove an integer from the buffer */
+
+int get(struct prodcons * b)
+{
+ int data;
+ /* Wait until buffer is not empty */
+ sem_wait(&b->sem_read);
+ /* Read the data and advance read pointer */
+ data = b->buffer[b->readpos];
+ b->readpos++;
+ if (b->readpos >= BUFFER_SIZE) b->readpos = 0;
+ /* Signal that the buffer has now one more location for writing */
+ sem_post(&b->sem_write);
+ return data;
+}
+
+/* A test program: one thread inserts integers from 1 to 10000,
+ the other reads them and prints them. */
+
+#define OVER (-1)
+
+struct prodcons buffer;
+
+void * producer(void * data)
+{
+ int n;
+ for (n = 0; n < 10000; n++) {
+ printf("%d --->\n", n);
+ put(&buffer, n);
+ }
+ put(&buffer, OVER);
+ return NULL;
+}
+
+void * consumer(void * data)
+{
+ int d;
+ while (1) {
+ d = get(&buffer);
+ if (d == OVER) break;
+ printf("---> %d\n", d);
+ }
+ return NULL;
+}
+
+int main(void)
+{
+ pthread_t th_a, th_b;
+ void * retval;
+
+ init(&buffer);
+ /* Create the threads */
+ pthread_create(&th_a, NULL, producer, 0);
+ pthread_create(&th_b, NULL, consumer, 0);
+ /* Wait until producer and consumer finish. */
+ pthread_join(th_a, &retval);
+ pthread_join(th_b, &retval);
+ return 0;
+}
Index: pthread/ex6.c
===================================================================
--- pthread/ex6.c (nonexistent)
+++ pthread/ex6.c (revision 1765)
@@ -0,0 +1,41 @@
+#include
+#include
+#include
+#include
+#include
+
+void *
+test_thread (void *v_param)
+{
+ return NULL;
+}
+
+int
+main (void)
+{
+ unsigned long count;
+
+ setvbuf (stdout, NULL, _IONBF, 0);
+
+ for (count = 0; count < 2000; ++count)
+ {
+ pthread_t thread;
+ int status;
+
+ status = pthread_create (&thread, NULL, test_thread, NULL);
+ if (status != 0)
+ {
+ printf ("status = %d, count = %lu: %s\n", status, count,
+ strerror (errno));
+ return 1;
+ }
+ else
+ {
+ printf ("count = %lu\n", count);
+ }
+ /* pthread_detach (thread); */
+ pthread_join (thread, NULL);
+ usleep (10);
+ }
+ return 0;
+}
Index: pthread/ex7.c
===================================================================
--- pthread/ex7.c (nonexistent)
+++ pthread/ex7.c (revision 1765)
@@ -0,0 +1,103 @@
+/* ex7
+ *
+ * Test case that illustrates a timed wait on a condition variable.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+/* Our event variable using a condition variable contruct. */
+typedef struct {
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ int flag;
+} event_t;
+
+
+/* Global event to signal main thread the timeout of the child thread. */
+event_t main_event;
+
+
+void *
+test_thread (void *ms_param)
+{
+ int status = 0;
+ event_t foo;
+ struct timespec time;
+ struct timeval now;
+ long ms = (long) ms_param;
+
+ /* initialize cond var */
+ pthread_cond_init(&foo.cond, NULL);
+ pthread_mutex_init(&foo.mutex, NULL);
+ foo.flag = 0;
+
+ /* set the time out value */
+ printf("waiting %ld ms ...\n", ms);
+ gettimeofday(&now, NULL);
+ time.tv_sec = now.tv_sec + ms/1000 + (now.tv_usec + (ms%1000)*1000)/1000000;
+ time.tv_nsec = ((now.tv_usec + (ms%1000)*1000) % 1000000) * 1000;
+
+ /* Just use this to test the time out. The cond var is never signaled. */
+ pthread_mutex_lock(&foo.mutex);
+ while (foo.flag == 0 && status != ETIMEDOUT) {
+ status = pthread_cond_timedwait(&foo.cond, &foo.mutex, &time);
+ }
+ pthread_mutex_unlock(&foo.mutex);
+
+ /* post the main event */
+ pthread_mutex_lock(&main_event.mutex);
+ main_event.flag = 1;
+ pthread_cond_signal(&main_event.cond);
+ pthread_mutex_unlock(&main_event.mutex);
+
+ /* that's it, bye */
+ return (void*) status;
+}
+
+int
+main (void)
+{
+ unsigned long count;
+
+ setvbuf (stdout, NULL, _IONBF, 0);
+
+ /* initialize main event cond var */
+ pthread_cond_init(&main_event.cond, NULL);
+ pthread_mutex_init(&main_event.mutex, NULL);
+ main_event.flag = 0;
+
+ for (count = 0; count < 20; ++count)
+ {
+ pthread_t thread;
+ int status;
+
+ /* pass down the milli-second timeout in the void* param */
+ status = pthread_create (&thread, NULL, test_thread, (void*) (count*100));
+ if (status != 0) {
+ printf ("status = %d, count = %lu: %s\n", status, count,
+ strerror (errno));
+ return 1;
+ }
+ else {
+
+ /* wait for the event posted by the child thread */
+ pthread_mutex_lock(&main_event.mutex);
+ while (main_event.flag == 0) {
+ pthread_cond_wait(&main_event.cond, &main_event.mutex);
+ }
+ main_event.flag = 0;
+ pthread_mutex_unlock(&main_event.mutex);
+
+ printf ("count = %lu\n", count);
+ }
+
+ usleep (10);
+ }
+
+ return 0;
+}
Index: pthread/Makefile
===================================================================
--- pthread/Makefile (nonexistent)
+++ pthread/Makefile (revision 1765)
@@ -0,0 +1,90 @@
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+LDFLAGS +=
+#EXTRA_LIBS += -lc -lgcc -lpthread
+EXTRA_LIBS += -lpthread
+
+TARGETS=ex1 ex2 ex3 ex4 ex5 ex6 ex7
+all: $(TARGETS)
+
+ex1: ex1.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+ex2: ex2.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+ex3: ex3.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+ex4: ex4.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+ex5: ex5.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+ex6: ex6.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+ex7: ex7.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
Index: pthread/ex1.c
===================================================================
--- pthread/ex1.c (nonexistent)
+++ pthread/ex1.c (revision 1765)
@@ -0,0 +1,39 @@
+/* Creates two threads, one printing 10000 "a"s, the other printing
+ 10000 "b"s.
+ Illustrates: thread creation, thread joining. */
+
+#include
+#include
+#include
+#include "pthread.h"
+
+void * process(void * arg)
+{
+ int i;
+ fprintf(stderr, "Starting process %s\n", (char *) arg);
+ for (i = 0; i < 10000; i++) {
+ write(1, (char *) arg, 1);
+ }
+ return NULL;
+}
+
+int main(void)
+{
+ int retcode;
+ pthread_t th_a, th_b;
+ void * retval;
+
+ retcode = pthread_create(&th_a, NULL, process, (void *) "a");
+ if (retcode != 0) fprintf(stderr, "create a failed %d\n", retcode);
+ else fprintf(stderr, "create a succeeded %d\n", retcode);
+ retcode = pthread_create(&th_b, NULL, process, (void *) "b");
+ if (retcode != 0) fprintf(stderr, "create b failed %d\n", retcode);
+ else fprintf(stderr, "create b succeeded %d\n", retcode);
+ retcode = pthread_join(th_a, &retval);
+ if (retcode != 0) fprintf(stderr, "join a failed %d\n", retcode);
+ else fprintf(stderr, "join a succeeded %d\n", retcode);
+ retcode = pthread_join(th_b, &retval);
+ if (retcode != 0) fprintf(stderr, "join b failed %d\n", retcode);
+ else fprintf(stderr, "join b succeeded %d\n", retcode);
+ return 0;
+}
Index: pthread
===================================================================
--- pthread (nonexistent)
+++ pthread (revision 1765)
pthread
Property changes :
Added: svn:ignore
## -0,0 +1,7 ##
+ex1
+ex2
+ex3
+ex4
+ex5
+ex6
+ex7
Index: math/test-idouble.c
===================================================================
--- math/test-idouble.c (nonexistent)
+++ math/test-idouble.c (revision 1765)
@@ -0,0 +1,35 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger , 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define FUNC(function) function
+#define FLOAT double
+#define TEST_MSG "testing double (inline functions)\n"
+#define MATHCONST(x) x
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinedouble
+#define PRINTF_EXPR "e"
+#define PRINTF_XEXPR "a"
+#define PRINTF_NEXPR "f"
+#define TEST_DOUBLE 1
+#define TEST_INLINE
+
+#ifdef __NO_MATH_INLINES
+# undef __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: math/gen-libm-test.pl
===================================================================
--- math/gen-libm-test.pl (nonexistent)
+++ math/gen-libm-test.pl (revision 1765)
@@ -0,0 +1,738 @@
+#!/usr/bin/perl -w
+# Copyright (C) 1999 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Andreas Jaeger , 1999.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# This file needs to be tidied up
+# Note that functions and tests share the same namespace.
+
+# Information about tests are stored in: %results
+# $results{$test}{"kind"} is either "fct" or "test" and flags whether this
+# is a maximal error of a function or a single test.
+# $results{$test}{"type"} is the result type, e.g. normal or complex.
+# $results{$test}{"has_ulps"} is set if deltas exist.
+# $results{$test}{"has_fails"} is set if exptected failures exist.
+# In the following description $type and $float are:
+# - $type is either "normal", "real" (for the real part of a complex number)
+# or "imag" (for the imaginary part # of a complex number).
+# - $float is either of float, ifloat, double, idouble, ldouble, ildouble;
+# It represents the underlying floating point type (float, double or long
+# double) and if inline functions (the leading i stands for inline)
+# are used.
+# $results{$test}{$type}{"fail"}{$float} is defined and has a 1 if
+# the test is expected to fail
+# $results{$test}{$type}{"ulp"}{$float} is defined and has a delta as value
+
+
+use Getopt::Std;
+
+use strict;
+
+use vars qw ($input $output);
+use vars qw (%results);
+use vars qw (@tests @functions);
+use vars qw ($count);
+use vars qw (%beautify @all_floats);
+use vars qw ($output_dir $ulps_file);
+
+# all_floats is sorted and contains all recognised float types
+@all_floats = ('double', 'float', 'idouble',
+ 'ifloat', 'ildouble', 'ldouble');
+
+%beautify =
+ ( "minus_zero" => "-0",
+ "plus_zero" => "+0",
+ "minus_infty" => "-inf",
+ "plus_infty" => "inf",
+ "nan_value" => "NaN",
+ "M_El" => "e",
+ "M_E2l" => "e^2",
+ "M_E3l" => "e^3",
+ "M_LOG10El", "log10(e)",
+ "M_PIl" => "pi",
+ "M_PI_34l" => "3/4 pi",
+ "M_PI_2l" => "pi/2",
+ "M_PI_4l" => "pi/4",
+ "M_PI_6l" => "pi/6",
+ "M_PI_34_LOG10El" => "3/4 pi*log10(e)",
+ "M_PI_LOG10El" => "pi*log10(e)",
+ "M_PI2_LOG10El" => "pi/2*log10(e)",
+ "M_PI4_LOG10El" => "pi/4*log10(e)",
+ "M_LOG_SQRT_PIl" => "log(sqrt(pi))",
+ "M_LOG_2_SQRT_PIl" => "log(2*sqrt(pi))",
+ "M_2_SQRT_PIl" => "2 sqrt (pi)",
+ "M_SQRT_PIl" => "sqrt (pi)",
+ "INVALID_EXCEPTION" => "invalid exception",
+ "DIVIDE_BY_ZERO_EXCEPTION" => "division by zero exception",
+ "INVALID_EXCEPTION_OK" => "invalid exception allowed",
+ "DIVIDE_BY_ZERO_EXCEPTION_OK" => "division by zero exception allowed",
+ "EXCEPTIONS_OK" => "exceptions allowed",
+ "IGNORE_ZERO_INF_SIGN" => "sign of zero/inf not specified",
+"INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN" => "invalid exception and sign of zero/inf not specified"
+ );
+
+
+# get Options
+# Options:
+# u: ulps-file
+# h: help
+# o: output-directory
+# n: generate new ulps file
+use vars qw($opt_u $opt_h $opt_o $opt_n);
+getopts('u:o:nh');
+
+$ulps_file = 'libm-test-ulps';
+$output_dir = '';
+
+if ($opt_h) {
+ print "Usage: gen-libm-test.pl [OPTIONS]\n";
+ print " -h print this help, then exit\n";
+ print " -o DIR directory where generated files will be placed\n";
+ print " -n only generate sorted file NewUlps from libm-test-ulps\n";
+ print " -u FILE input file with ulps\n";
+ exit 0;
+}
+
+$ulps_file = $opt_u if ($opt_u);
+$output_dir = $opt_o if ($opt_o);
+
+$input = "libm-test.inc";
+$output = "${output_dir}libm-test.c";
+
+$count = 0;
+
+&parse_ulps ($ulps_file);
+&generate_testfile ($input, $output) unless ($opt_n);
+&output_ulps ("${output_dir}libm-test-ulps.h", $ulps_file) unless ($opt_n);
+&print_ulps_file ("${output_dir}NewUlps") if ($opt_n);
+
+# Return a nicer representation
+sub beautify {
+ my ($arg) = @_;
+ my ($tmp);
+
+ if (exists $beautify{$arg}) {
+ return $beautify{$arg};
+ }
+ if ($arg =~ /^-/) {
+ $tmp = $arg;
+ $tmp =~ s/^-//;
+ if (exists $beautify{$tmp}) {
+ return '-' . $beautify{$tmp};
+ }
+ }
+ if ($arg =~ /[0-9]L$/) {
+ $arg =~ s/L$//;
+ }
+ return $arg;
+}
+
+# Return a nicer representation of a complex number
+sub build_complex_beautify {
+ my ($r, $i) = @_;
+ my ($str1, $str2);
+
+ $str1 = &beautify ($r);
+ $str2 = &beautify ($i);
+ if ($str2 =~ /^-/) {
+ $str2 =~ s/^-//;
+ $str1 .= ' - ' . $str2;
+ } else {
+ $str1 .= ' + ' . $str2;
+ }
+ $str1 .= ' i';
+ return $str1;
+}
+
+# Return name of a variable
+sub get_variable {
+ my ($number) = @_;
+
+ return "x" if ($number == 1);
+ return "y" if ($number == 2);
+ return "z" if ($number == 3);
+ # return x1,x2,...
+ $number =-3;
+ return "x$number";
+}
+
+# Add a new test to internal data structures and fill in the
+# ulps, failures and exception information for the C line.
+sub new_test {
+ my ($test, $exception) = @_;
+ my $rest;
+
+ # Add ulp, xfail
+ if (exists $results{$test}{'has_ulps'}) {
+ $rest = ", DELTA$count";
+ } else {
+ $rest = ', 0';
+ }
+ if (exists $results{$test}{'has_fails'}) {
+ $rest .= ", FAIL$count";
+ } else {
+ $rest .= ', 0';
+ }
+ if (defined $exception) {
+ $rest .= ", $exception";
+ } else {
+ $rest .= ', 0';
+ }
+ $rest .= ");\n";
+ # We must increment here to keep @tests and count in sync
+ push @tests, $test;
+ ++$count;
+ return $rest;
+}
+
+# Treat some functions especially.
+# Currently only sincos needs extra treatment.
+sub special_functions {
+ my ($file, $args) = @_;
+ my (@args, $str, $test, $cline);
+
+ @args = split /,\s*/, $args;
+
+ unless ($args[0] =~ /sincos/) {
+ die ("Don't know how to handle $args[0] extra.");
+ }
+ print $file " FUNC (sincos) ($args[1], &sin_res, &cos_res);\n";
+
+ $str = 'sincos (' . &beautify ($args[1]) . ', &sin_res, &cos_res)';
+ # handle sin
+ $test = $str . ' puts ' . &beautify ($args[2]) . ' in sin_res';
+ if ($#args == 4) {
+ $test .= " plus " . &beautify ($args[4]);
+ }
+
+ $cline = " check_float (\"$test\", sin_res, $args[2]";
+ $cline .= &new_test ($test, $args[4]);
+ print $file $cline;
+
+ # handle cos
+ $test = $str . ' puts ' . &beautify ($args[3]) . ' in cos_res';
+ $cline = " check_float (\"$test\", cos_res, $args[3]";
+ # only tests once for exception
+ $cline .= &new_test ($test, undef);
+ print $file $cline;
+}
+
+# Parse the arguments to TEST_x_y
+sub parse_args {
+ my ($file, $descr, $args) = @_;
+ my (@args, $str, $descr_args, $descr_res, @descr);
+ my ($current_arg, $cline, $i);
+ my ($pre, $post, @special);
+ my ($extra_var, $call, $c_call);
+
+ if ($descr eq 'extra') {
+ &special_functions ($file, $args);
+ return;
+ }
+ ($descr_args, $descr_res) = split /_/,$descr, 2;
+
+ @args = split /,\s*/, $args;
+
+ $call = "$args[0] (";
+
+ # Generate first the string that's shown to the user
+ $current_arg = 1;
+ $extra_var = 0;
+ @descr = split //,$descr_args;
+ for ($i = 0; $i <= $#descr; $i++) {
+ if ($i >= 1) {
+ $call .= ', ';
+ }
+ # FLOAT, int, long int, long long int
+ if ($descr[$i] =~ /f|i|l|L/) {
+ $call .= &beautify ($args[$current_arg]);
+ ++$current_arg;
+ next;
+ }
+ # &FLOAT, &int - argument is added here
+ if ($descr[$i] =~ /F|I/) {
+ ++$extra_var;
+ $call .= '&' . &get_variable ($extra_var);
+ next;
+ }
+ # complex
+ if ($descr[$i] eq 'c') {
+ $call .= &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
+ $current_arg += 2;
+ next;
+ }
+
+ die ("$descr[$i] is unknown");
+ }
+ $call .= ')';
+ $str = "$call == ";
+
+ # Result
+ @descr = split //,$descr_res;
+ foreach (@descr) {
+ if ($_ =~ /f|i|l|L/) {
+ $str .= &beautify ($args[$current_arg]);
+ ++$current_arg;
+ } elsif ($_ eq 'c') {
+ $str .= &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
+ $current_arg += 2;
+ } elsif ($_ eq 'b') {
+ # boolean
+ $str .= ($args[$current_arg] == 0) ? "false" : "true";
+ ++$current_arg;
+ } elsif ($_ eq '1') {
+ ++$current_arg;
+ } else {
+ die ("$_ is unknown");
+ }
+ }
+ # consistency check
+ if ($current_arg == $#args) {
+ die ("wrong number of arguments")
+ unless ($args[$current_arg] =~ /EXCEPTION|IGNORE_ZERO_INF_SIGN/);
+ } elsif ($current_arg < $#args) {
+ die ("wrong number of arguments");
+ } elsif ($current_arg > ($#args+1)) {
+ die ("wrong number of arguments");
+ }
+
+
+ # check for exceptions
+ if ($current_arg <= $#args) {
+ $str .= " plus " . &beautify ($args[$current_arg]);
+ }
+
+ # Put the C program line together
+ # Reset some variables to start again
+ $current_arg = 1;
+ $extra_var = 0;
+ if (substr($descr_res,0,1) eq 'f') {
+ $cline = 'check_float'
+ } elsif (substr($descr_res,0,1) eq 'b') {
+ $cline = 'check_bool';
+ } elsif (substr($descr_res,0,1) eq 'c') {
+ $cline = 'check_complex';
+ } elsif (substr($descr_res,0,1) eq 'i') {
+ $cline = 'check_int';
+ } elsif (substr($descr_res,0,1) eq 'l') {
+ $cline = 'check_long';
+ } elsif (substr($descr_res,0,1) eq 'L') {
+ $cline = 'check_longlong';
+ }
+ # Special handling for some macros:
+ $cline .= " (\"$str\", ";
+ if ($args[0] =~ /fpclassify|isnormal|isfinite|signbit/) {
+ $c_call = "$args[0] (";
+ } else {
+ $c_call = " FUNC($args[0]) (";
+ }
+ @descr = split //,$descr_args;
+ for ($i=0; $i <= $#descr; $i++) {
+ if ($i >= 1) {
+ $c_call .= ', ';
+ }
+ # FLOAT, int, long int, long long int
+ if ($descr[$i] =~ /f|i|l|L/) {
+ $c_call .= $args[$current_arg];
+ $current_arg++;
+ next;
+ }
+ # &FLOAT, &int
+ if ($descr[$i] =~ /F|I/) {
+ ++$extra_var;
+ $c_call .= '&' . &get_variable ($extra_var);
+ next;
+ }
+ # complex
+ if ($descr[$i] eq 'c') {
+ $c_call .= "BUILD_COMPLEX ($args[$current_arg], $args[$current_arg+1])";
+ $current_arg += 2;
+ next;
+ }
+ }
+ $c_call .= ')';
+ $cline .= "$c_call, ";
+
+ @descr = split //,$descr_res;
+ foreach (@descr) {
+ if ($_ =~ /b|f|i|l|L/ ) {
+ $cline .= $args[$current_arg];
+ $current_arg++;
+ } elsif ($_ eq 'c') {
+ $cline .= "BUILD_COMPLEX ($args[$current_arg], $args[$current_arg+1])";
+ $current_arg += 2;
+ } elsif ($_ eq '1') {
+ push @special, $args[$current_arg];
+ ++$current_arg;
+ }
+ }
+ # Add ulp, xfail
+ $cline .= &new_test ($str, ($current_arg <= $#args) ? $args[$current_arg] : undef);
+
+ # special treatment for some functions
+ if ($args[0] eq 'frexp') {
+ if (defined $special[0] && $special[0] ne "IGNORE") {
+ my ($str) = "$call sets x to $special[0]";
+ $post = " check_int (\"$str\", x, $special[0]";
+ $post .= &new_test ($str, undef);
+ }
+ } elsif ($args[0] eq 'gamma' || $args[0] eq 'lgamma') {
+ $pre = " signgam = 0;\n";
+ if (defined $special[0] && $special[0] ne "IGNORE") {
+ my ($str) = "$call sets signgam to $special[0]";
+ $post = " check_int (\"$str\", signgam, $special[0]";
+ $post .= &new_test ($str, undef);
+ }
+ } elsif ($args[0] eq 'modf') {
+ if (defined $special[0] && $special[0] ne "IGNORE") {
+ my ($str) = "$call sets x to $special[0]";
+ $post = " check_float (\"$str\", x, $special[0]";
+ $post .= &new_test ($str, undef);
+ }
+ } elsif ($args[0] eq 'remquo') {
+ if (defined $special[0] && $special[0] ne "IGNORE") {
+ my ($str) = "$call sets x to $special[0]";
+ $post = " check_int (\"$str\", x, $special[0]";
+ $post .= &new_test ($str, undef);
+ }
+ }
+
+ print $file $pre if (defined $pre);
+
+ print $file " $cline";
+
+ print $file $post if (defined $post);
+}
+
+# Generate libm-test.c
+sub generate_testfile {
+ my ($input, $output) = @_;
+ my ($lasttext);
+ my (@args, $i, $str);
+
+ open INPUT, $input or die ("Can't open $input: $!");
+ open OUTPUT, ">$output" or die ("Can't open $output: $!");
+
+ # Replace the special macros
+ while () {
+
+ # TEST_...
+ if (/^\s*TEST_/) {
+ my ($descr, $args);
+ chop;
+ ($descr, $args) = ($_ =~ /TEST_(\w+)\s*\((.*)\)/);
+ &parse_args (\*OUTPUT, $descr, $args);
+ next;
+ }
+ # START (function)
+ if (/START/) {
+ print OUTPUT " init_max_error ();\n";
+ next;
+ }
+ # END (function)
+ if (/END/) {
+ my ($fct, $line, $type);
+ if (/complex/) {
+ s/,\s*complex\s*//;
+ $type = 'complex';
+ } else {
+ $type = 'normal';
+ }
+ ($fct) = ($_ =~ /END\s*\((.*)\)/);
+ if ($type eq 'complex') {
+ $line = " print_complex_max_error (\"$fct\", ";
+ } else {
+ $line = " print_max_error (\"$fct\", ";
+ }
+ if (exists $results{$fct}{'has_ulps'}) {
+ $line .= "DELTA$fct";
+ } else {
+ $line .= '0';
+ }
+ if (exists $results{$fct}{'has_fails'}) {
+ $line .= ", FAIL$fct";
+ } else {
+ $line .= ', 0';
+ }
+ $line .= ");\n";
+ print OUTPUT $line;
+ push @functions, $fct;
+ next;
+ }
+ print OUTPUT;
+ }
+ close INPUT;
+ close OUTPUT;
+}
+
+
+
+# Parse ulps file
+sub parse_ulps {
+ my ($file) = @_;
+ my ($test, $type, $float, $eps, $kind);
+
+ # $type has the following values:
+ # "normal": No complex variable
+ # "real": Real part of complex result
+ # "imag": Imaginary part of complex result
+ open ULP, $file or die ("Can't open $file: $!");
+ while () {
+ chop;
+ # ignore comments and empty lines
+ next if /^#/;
+ next if /^\s*$/;
+ if (/^Test/) {
+ if (/Real part of:/) {
+ s/Real part of: //;
+ $type = 'real';
+ } elsif (/Imaginary part of:/) {
+ s/Imaginary part of: //;
+ $type = 'imag';
+ } else {
+ $type = 'normal';
+ }
+ s/^.+\"(.*)\".*$/$1/;
+ $test = $_;
+ $kind = 'test';
+ next;
+ }
+ if (/^Function: /) {
+ if (/Real part of/) {
+ s/Real part of //;
+ $type = 'real';
+ } elsif (/Imaginary part of/) {
+ s/Imaginary part of //;
+ $type = 'imag';
+ } else {
+ $type = 'normal';
+ }
+ ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
+ $kind = 'fct';
+ next;
+ }
+ if (/^i?(float|double|ldouble):/) {
+ ($float, $eps) = split /\s*:\s*/,$_,2;
+
+ if ($eps eq 'fail') {
+ $results{$test}{$type}{'fail'}{$float} = 1;
+ $results{$test}{'has_fails'} = 1;
+ } elsif ($eps eq "0") {
+ # ignore
+ next;
+ } else {
+ $results{$test}{$type}{'ulp'}{$float} = $eps;
+ $results{$test}{'has_ulps'} = 1;
+ }
+ if ($type =~ /^real|imag$/) {
+ $results{$test}{'type'} = 'complex';
+ } elsif ($type eq 'normal') {
+ $results{$test}{'type'} = 'normal';
+ }
+ $results{$test}{'kind'} = $kind;
+ next;
+ }
+ print "Skipping unknown entry: `$_'\n";
+ }
+ close ULP;
+}
+
+
+# Clean up a floating point number
+sub clean_up_number {
+ my ($number) = @_;
+
+ # Remove trailing zeros
+ $number =~ s/0+$//;
+ $number =~ s/\.$//;
+ return $number;
+}
+
+# Output a file which can be read in as ulps file.
+sub print_ulps_file {
+ my ($file) = @_;
+ my ($test, $type, $float, $eps, $fct, $last_fct);
+
+ $last_fct = '';
+ open NEWULP, ">$file" or die ("Can't open $file: $!");
+ print NEWULP "# Begin of automatic generation\n";
+ # first the function calls
+ foreach $test (sort keys %results) {
+ next if ($results{$test}{'kind'} ne 'test');
+ foreach $type ('real', 'imag', 'normal') {
+ if (exists $results{$test}{$type}) {
+ if (defined $results{$test}) {
+ ($fct) = ($test =~ /^(\w+)\s/);
+ if ($fct ne $last_fct) {
+ $last_fct = $fct;
+ print NEWULP "\n# $fct\n";
+ }
+ }
+ if ($type eq 'normal') {
+ print NEWULP "Test \"$test\":\n";
+ } elsif ($type eq 'real') {
+ print NEWULP "Test \"Real part of: $test\":\n";
+ } elsif ($type eq 'imag') {
+ print NEWULP "Test \"Imaginary part of: $test\":\n";
+ }
+ foreach $float (@all_floats) {
+ if (exists $results{$test}{$type}{'ulp'}{$float}) {
+ print NEWULP "$float: ",
+ &clean_up_number ($results{$test}{$type}{'ulp'}{$float}),
+ "\n";
+ }
+ if (exists $results{$test}{$type}{'fail'}{$float}) {
+ print NEWULP "$float: fail\n";
+ }
+ }
+ }
+ }
+ }
+ print NEWULP "\n# Maximal error of functions:\n";
+
+ foreach $fct (sort keys %results) {
+ next if ($results{$fct}{'kind'} ne 'fct');
+ foreach $type ('real', 'imag', 'normal') {
+ if (exists $results{$fct}{$type}) {
+ if ($type eq 'normal') {
+ print NEWULP "Function: \"$fct\":\n";
+ } elsif ($type eq 'real') {
+ print NEWULP "Function: Real part of \"$fct\":\n";
+ } elsif ($type eq 'imag') {
+ print NEWULP "Function: Imaginary part of \"$fct\":\n";
+ }
+ foreach $float (@all_floats) {
+ if (exists $results{$fct}{$type}{'ulp'}{$float}) {
+ print NEWULP "$float: ",
+ &clean_up_number ($results{$fct}{$type}{'ulp'}{$float}),
+ "\n";
+ }
+ if (exists $results{$fct}{$type}{'fail'}{$float}) {
+ print NEWULP "$float: fail\n";
+ }
+ }
+ print NEWULP "\n";
+ }
+ }
+ }
+ print NEWULP "# end of automatic generation\n";
+ close NEWULP;
+}
+
+sub get_ulps {
+ my ($test, $type, $float) = @_;
+
+ if ($type eq 'complex') {
+ my ($res);
+ # Return 0 instead of BUILD_COMPLEX (0,0)
+ if (!exists $results{$test}{'real'}{'ulp'}{$float} &&
+ !exists $results{$test}{'imag'}{'ulp'}{$float}) {
+ return "0";
+ }
+ $res = 'BUILD_COMPLEX (';
+ $res .= (exists $results{$test}{'real'}{'ulp'}{$float}
+ ? $results{$test}{'real'}{'ulp'}{$float} : "0");
+ $res .= ', ';
+ $res .= (exists $results{$test}{'imag'}{'ulp'}{$float}
+ ? $results{$test}{'imag'}{'ulp'}{$float} : "0");
+ $res .= ')';
+ return $res;
+ }
+ return (exists $results{$test}{'normal'}{'ulp'}{$float}
+ ? $results{$test}{'normal'}{'ulp'}{$float} : "0");
+}
+
+sub get_failure {
+ my ($test, $type, $float) = @_;
+ if ($type eq 'complex') {
+ # return x,y
+ my ($res);
+ # Return 0 instead of BUILD_COMPLEX_INT (0,0)
+ if (!exists $results{$test}{'real'}{'ulp'}{$float} &&
+ !exists $results{$test}{'imag'}{'ulp'}{$float}) {
+ return "0";
+ }
+ $res = 'BUILD_COMPLEX_INT (';
+ $res .= (exists $results{$test}{'real'}{'fail'}{$float}
+ ? $results{$test}{'real'}{'fail'}{$float} : "0");
+ $res .= ', ';
+ $res .= (exists $results{$test}{'imag'}{'fail'}{$float}
+ ? $results{$test}{'imag'}{'fail'}{$float} : "0");
+ $res .= ')';
+ return $res;
+ }
+ return (exists $results{$test}{'normal'}{'fail'}{$float}
+ ? $results{$test}{'normal'}{'fail'}{$float} : "0");
+
+}
+
+# Output the defines for a single test
+sub output_test {
+ my ($file, $test, $name) = @_;
+ my ($ldouble, $double, $float, $ildouble, $idouble, $ifloat);
+ my ($type);
+
+ # Do we have ulps/failures?
+ if (!exists $results{$test}{'type'}) {
+ return;
+ }
+ $type = $results{$test}{'type'};
+ if (exists $results{$test}{'has_ulps'}) {
+ # XXX use all_floats (change order!)
+ $ldouble = &get_ulps ($test, $type, "ldouble");
+ $double = &get_ulps ($test, $type, "double");
+ $float = &get_ulps ($test, $type, "float");
+ $ildouble = &get_ulps ($test, $type, "ildouble");
+ $idouble = &get_ulps ($test, $type, "idouble");
+ $ifloat = &get_ulps ($test, $type, "ifloat");
+ print $file "#define DELTA$name CHOOSE($ldouble, $double, $float, $ildouble, $idouble, $ifloat)\t/* $test */\n";
+ }
+
+ if (exists $results{$test}{'has_fails'}) {
+ $ldouble = &get_failure ($test, "ldouble");
+ $double = &get_failure ($test, "double");
+ $float = &get_failure ($test, "float");
+ $ildouble = &get_failure ($test, "ildouble");
+ $idouble = &get_failure ($test, "idouble");
+ $ifloat = &get_failure ($test, "ifloat");
+ print $file "#define FAIL$name CHOOSE($ldouble, $double, $float $ildouble, $idouble, $ifloat)\t/* $test */\n";
+ }
+}
+
+# Print include file
+sub output_ulps {
+ my ($file, $ulps_filename) = @_;
+ my ($i, $fct);
+
+ open ULP, ">$file" or die ("Can't open $file: $!");
+
+ print ULP "/* This file is automatically generated\n";
+ print ULP " from $ulps_filename with gen-libm-test.pl.\n";
+ print ULP " Don't change it - change instead the master files. */\n\n";
+
+ print ULP "\n/* Maximal error of functions. */\n";
+ foreach $fct (@functions) {
+ output_test (\*ULP, $fct, $fct);
+ }
+
+ print ULP "\n/* Error of single function calls. */\n";
+ for ($i = 0; $i < $count; $i++) {
+ output_test (\*ULP, $tests[$i], $i);
+ }
+ close ULP;
+}
math/gen-libm-test.pl
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: math/test-float.c
===================================================================
--- math/test-float.c (nonexistent)
+++ math/test-float.c (revision 1765)
@@ -0,0 +1,34 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger , 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define FUNC(function) function ## f
+#define FLOAT float
+#define TEST_MSG "testing float (without inline functions)\n"
+#define MATHCONST(x) x
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat
+#define PRINTF_EXPR "e"
+#define PRINTF_XEXPR "a"
+#define PRINTF_NEXPR "f"
+#define TEST_FLOAT 1
+
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: math/test-ldouble.c
===================================================================
--- math/test-ldouble.c (nonexistent)
+++ math/test-ldouble.c (revision 1765)
@@ -0,0 +1,34 @@
+/* Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger , 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define FUNC(function) function##l
+#define FLOAT long double
+#define TEST_MSG "testing long double (without inline functions)\n"
+#define MATHCONST(x) x##L
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Clongdouble
+#define PRINTF_EXPR "Le"
+#define PRINTF_XEXPR "La"
+#define PRINTF_NEXPR "Lf"
+#define TEST_LDOUBLE 1
+
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: math/test-ildoubl.c
===================================================================
--- math/test-ildoubl.c (nonexistent)
+++ math/test-ildoubl.c (revision 1765)
@@ -0,0 +1,35 @@
+/* Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger , 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define FUNC(function) function##l
+#define FLOAT long double
+#define TEST_MSG "testing long double (inline functions)\n"
+#define MATHCONST(x) x##L
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinelongdouble
+#define PRINTF_EXPR "Le"
+#define PRINTF_XEXPR "La"
+#define PRINTF_NEXPR "Lf"
+#define TEST_INLINE
+#define TEST_LDOUBLE 1
+
+#ifdef __NO_MATH_INLINES
+# undef __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: math/test-double.c
===================================================================
--- math/test-double.c (nonexistent)
+++ math/test-double.c (revision 1765)
@@ -0,0 +1,34 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger , 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define FUNC(function) function
+#define FLOAT double
+#define TEST_MSG "testing double (without inline functions)\n"
+#define MATHCONST(x) x
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble
+#define PRINTF_EXPR "e"
+#define PRINTF_XEXPR "a"
+#define PRINTF_NEXPR "f"
+#define TEST_DOUBLE 1
+
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: math/libm-test.inc
===================================================================
--- math/libm-test.inc (nonexistent)
+++ math/libm-test.inc (revision 1765)
@@ -0,0 +1,4521 @@
+/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger , 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Part of testsuite for libm.
+
+ This file is processed by a perl script. The resulting file has to
+ be included by a master file that defines:
+
+ Makros:
+ FUNC(function): converts general function name (like cos) to
+ name with correct suffix (e.g. cosl or cosf)
+ MATHCONST(x): like FUNC but for constants (e.g convert 0.0 to 0.0L)
+ FLOAT: floating point type to test
+ - TEST_MSG: informal message to be displayed
+ CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat):
+ chooses one of the parameters as delta for testing
+ equality
+ PRINTF_EXPR Floating point conversion specification to print a variable
+ of type FLOAT with printf. PRINTF_EXPR just contains
+ the specifier, not the percent and width arguments,
+ e.g. "f".
+ PRINTF_XEXPR Like PRINTF_EXPR, but print in hexadecimal format.
+ PRINTF_NEXPR Like PRINTF_EXPR, but print nice. */
+
+/* This testsuite has currently tests for:
+ acos, acosh, asin, asinh, atan, atan2, atanh,
+ cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp10, exp2, expm1,
+ fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify,
+ frexp, gamma, hypot,
+ ilogb, isfinite, isinf, isnan, isnormal,
+ isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered,
+ j0, j1, jn,
+ ldexp, lgamma, log, log10, log1p, log2, logb,
+ modf, nearbyint, nextafter,
+ pow, remainder, remquo, rint, lrint, llrint,
+ round, lround, llround,
+ scalb, scalbn, scalbln, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, trunc,
+ y0, y1, yn
+
+ and for the following complex math functions:
+ cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
+ ccos, ccosh, cexp, clog, cpow, cproj, csin, csinh, csqrt, ctan, ctanh.
+
+ At the moment the following functions aren't tested:
+ drem, significand, nan
+
+ Parameter handling is primitive in the moment:
+ --verbose=[0..3] for different levels of output:
+ 0: only error count
+ 1: basic report on failed tests (default)
+ 2: full report on all tests
+ -v for full output (equals --verbose=3)
+ -u for generation of an ULPs file
+ */
+
+/* "Philosophy":
+
+ This suite tests some aspects of the correct implementation of
+ mathematical functions in libm. Some simple, specific parameters
+ are tested for correctness but there's no exhaustive
+ testing. Handling of specific inputs (e.g. infinity, not-a-number)
+ is also tested. Correct handling of exceptions is checked
+ against. These implemented tests should check all cases that are
+ specified in ISO C99.
+
+ Exception testing: At the moment only divide-by-zero and invalid
+ exceptions are tested. Overflow/underflow and inexact exceptions
+ aren't checked at the moment.
+
+ NaN values: There exist signalling and quiet NaNs. This implementation
+ only uses signalling NaN as parameter but does not differenciate
+ between the two kinds of NaNs as result.
+
+ Inline functions: Inlining functions should give an improvement in
+ speed - but not in precission. The inlined functions return
+ reasonable values for a reasonable range of input values. The
+ result is not necessarily correct for all values and exceptions are
+ not correctly raised in all cases. Problematic input and return
+ values are infinity, not-a-number and minus zero. This suite
+ therefore does not check these specific inputs and the exception
+ handling for inlined mathematical functions - just the "reasonable"
+ values are checked.
+
+ Beware: The tests might fail for any of the following reasons:
+ - Tests are wrong
+ - Functions are wrong
+ - Floating Point Unit not working properly
+ - Compiler has errors
+
+ With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error.
+
+
+ To Do: All parameter should be numbers that can be represented as
+ exact floating point values. Currently some values cannot be represented
+ exactly and therefore the result is not the expected result.
+*/
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include "libm-test-ulps.h"
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+//#include
+#define feclearexcept(X)
+#define fetestexcept(X) 0
+
+/* Possible exceptions */
+#define NO_EXCEPTION 0x0
+#define INVALID_EXCEPTION 0x1
+#define DIVIDE_BY_ZERO_EXCEPTION 0x2
+/* The next flags signals that those exceptions are allowed but not required. */
+#define INVALID_EXCEPTION_OK 0x4
+#define DIVIDE_BY_ZERO_EXCEPTION_OK 0x8
+#define EXCEPTIONS_OK INVALID_EXCEPTION_OK+DIVIDE_BY_ZERO_EXCEPTION_OK
+/* Some special test flags, passed togther with exceptions. */
+#define IGNORE_ZERO_INF_SIGN 0x10
+
+/* Various constants (we must supply them precalculated for accuracy). */
+#define M_PI_6l .52359877559829887307710723054658383L
+#define M_E2l 7.389056098930650227230427460575008L
+#define M_E3l 20.085536923187667740928529654581719L
+#define M_2_SQRT_PIl 3.5449077018110320545963349666822903L /* 2 sqrt (M_PIl) */
+#define M_SQRT_PIl 1.7724538509055160272981674833411451L /* sqrt (M_PIl) */
+#define M_LOG_SQRT_PIl 0.57236494292470008707171367567652933L /* log(sqrt(M_PIl)) */
+#define M_LOG_2_SQRT_PIl 1.265512123484645396488945797134706L /* log(2*sqrt(M_PIl)) */
+#define M_PI_34l (M_PIl - M_PI_4l) /* 3*pi/4 */
+#define M_PI_34_LOG10El (M_PIl - M_PI_4l) * M_LOG10El
+#define M_PI2_LOG10El M_PI_2l * M_LOG10El
+#define M_PI4_LOG10El M_PI_4l * M_LOG10El
+#define M_PI_LOG10El M_PIl * M_LOG10El
+
+static FILE *ulps_file; /* File to document difference. */
+static int output_ulps; /* Should ulps printed? */
+
+static int noErrors; /* number of errors */
+static int noTests; /* number of tests (without testing exceptions) */
+static int noExcTests; /* number of tests for exception flags */
+static int noXFails; /* number of expected failures. */
+static int noXPasses; /* number of unexpected passes. */
+
+static int verbose;
+static int output_max_error; /* Should the maximal errors printed? */
+static int output_points; /* Should the single function results printed? */
+static int ignore_max_ulp; /* Should we ignore max_ulp? */
+
+static FLOAT minus_zero, plus_zero;
+static FLOAT plus_infty, minus_infty, nan_value;
+
+static FLOAT max_error, real_max_error, imag_max_error;
+
+
+#define BUILD_COMPLEX(real, imag) \
+ ({ __complex__ FLOAT __retval; \
+ __real__ __retval = (real); \
+ __imag__ __retval = (imag); \
+ __retval; })
+
+#define BUILD_COMPLEX_INT(real, imag) \
+ ({ __complex__ int __retval; \
+ __real__ __retval = (real); \
+ __imag__ __retval = (imag); \
+ __retval; })
+
+
+#define MANT_DIG CHOOSE ((LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1), \
+ (LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
+
+static void
+init_max_error (void)
+{
+ max_error = 0;
+ real_max_error = 0;
+ imag_max_error = 0;
+ feclearexcept (FE_ALL_EXCEPT);
+}
+
+static void
+set_max_error (FLOAT current, FLOAT *curr_max_error)
+{
+ if (current > *curr_max_error)
+ *curr_max_error = current;
+}
+
+
+/* Should the message print to screen? This depends on the verbose flag,
+ and the test status. */
+static int
+print_screen (int ok, int xfail)
+{
+ if (output_points
+ && (verbose > 1
+ || (verbose == 1 && ok == xfail)))
+ return 1;
+ return 0;
+}
+
+
+/* Should the message print to screen? This depends on the verbose flag,
+ and the test status. */
+static int
+print_screen_max_error (int ok, int xfail)
+{
+ if (output_max_error
+ && (verbose > 1
+ || ((verbose == 1) && (ok == xfail))))
+ return 1;
+ return 0;
+}
+
+/* Update statistic counters. */
+static void
+update_stats (int ok, int xfail)
+{
+ ++noTests;
+ if (ok && xfail)
+ ++noXPasses;
+ else if (!ok && xfail)
+ ++noXFails;
+ else if (!ok && !xfail)
+ ++noErrors;
+}
+
+static void
+print_ulps (const char *test_name, FLOAT ulp)
+{
+ if (output_ulps)
+ {
+ fprintf (ulps_file, "Test \"%s\":\n", test_name);
+ fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
+ CHOOSE("ldouble", "double", "float",
+ "ildouble", "idouble", "ifloat"),
+ FUNC(ceil) (ulp));
+ }
+}
+
+static void
+print_function_ulps (const char *function_name, FLOAT ulp)
+{
+ if (output_ulps)
+ {
+ fprintf (ulps_file, "Function: \"%s\":\n", function_name);
+ fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
+ CHOOSE("ldouble", "double", "float",
+ "ildouble", "idouble", "ifloat"),
+ FUNC(ceil) (ulp));
+ }
+}
+
+
+static void
+print_complex_function_ulps (const char *function_name, FLOAT real_ulp,
+ FLOAT imag_ulp)
+{
+ if (output_ulps)
+ {
+ if (real_ulp != 0.0)
+ {
+ fprintf (ulps_file, "Function: Real part of \"%s\":\n", function_name);
+ fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
+ CHOOSE("ldouble", "double", "float",
+ "ildouble", "idouble", "ifloat"),
+ FUNC(ceil) (real_ulp));
+ }
+ if (imag_ulp != 0.0)
+ {
+ fprintf (ulps_file, "Function: Imaginary part of \"%s\":\n", function_name);
+ fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
+ CHOOSE("ldouble", "double", "float",
+ "ildouble", "idouble", "ifloat"),
+ FUNC(ceil) (imag_ulp));
+ }
+
+
+ }
+}
+
+
+
+/* Test if Floating-Point stack hasn't changed */
+static void
+fpstack_test (const char *test_name)
+{
+#ifdef i386
+ static int old_stack;
+ int sw;
+
+ asm ("fnstsw" : "=a" (sw));
+ sw >>= 11;
+ sw &= 7;
+
+ if (sw != old_stack)
+ {
+ printf ("FP-Stack wrong after test %s (%d, should be %d)\n",
+ test_name, sw, old_stack);
+ ++noErrors;
+ old_stack = sw;
+ }
+#endif
+}
+
+
+static void
+print_max_error (const char *func_name, FLOAT allowed, int xfail)
+{
+ int ok = 0;
+
+ if (max_error == 0.0 || (max_error <= allowed && !ignore_max_ulp))
+ {
+ ok = 1;
+ }
+
+ if (!ok)
+ print_function_ulps (func_name, max_error);
+
+
+ if (print_screen_max_error (ok, xfail))
+ {
+ printf ("Maximal error of `%s'\n", func_name);
+ printf (" is : %.0" PRINTF_NEXPR " ulp\n", FUNC(ceil) (max_error));
+ printf (" accepted: %.0" PRINTF_NEXPR " ulp\n", FUNC(ceil) (allowed));
+ }
+
+ update_stats (ok, xfail);
+}
+
+
+static void
+print_complex_max_error (const char *func_name, __complex__ FLOAT allowed,
+ __complex__ int xfail)
+{
+ int ok = 0;
+
+ if ((real_max_error == 0 && imag_max_error == 0)
+ || (real_max_error <= __real__ allowed
+ && imag_max_error <= __imag__ allowed
+ && !ignore_max_ulp))
+ {
+ ok = 1;
+ }
+
+ if (!ok)
+ print_complex_function_ulps (func_name, real_max_error, imag_max_error);
+
+
+ if (print_screen_max_error (ok, xfail))
+ {
+ printf ("Maximal error of real part of: %s\n", func_name);
+ printf (" is : %.0" PRINTF_NEXPR " ulp\n",
+ FUNC(ceil) (real_max_error));
+ printf (" accepted: %.0" PRINTF_NEXPR " ulp\n",
+ FUNC(ceil) (__real__ allowed));
+ printf ("Maximal error of imaginary part of: %s\n", func_name);
+ printf (" is : %.0" PRINTF_NEXPR " ulp\n",
+ FUNC(ceil) (imag_max_error));
+ printf (" accepted: %.0" PRINTF_NEXPR " ulp\n",
+ FUNC(ceil) (__imag__ allowed));
+ }
+
+ update_stats (ok, xfail);
+}
+
+
+/* Test whether a given exception was raised. */
+static void
+test_single_exception (const char *test_name,
+ int exception,
+ int exc_flag,
+ int fe_flag,
+ const char *flag_name)
+{
+#ifndef TEST_INLINE
+ int ok = 1;
+ if (exception & exc_flag)
+ {
+ if (fetestexcept (fe_flag))
+ {
+ if (print_screen (1, 0))
+ printf ("Pass: %s: Exception \"%s\" set\n", test_name, flag_name);
+ }
+ else
+ {
+ ok = 0;
+ if (print_screen (0, 0))
+ printf ("Failure: %s: Exception \"%s\" not set\n",
+ test_name, flag_name);
+ }
+ }
+ else
+ {
+ if (fetestexcept (fe_flag))
+ {
+ ok = 0;
+ if (print_screen (0, 0))
+ printf ("Failure: %s: Exception \"%s\" set\n",
+ test_name, flag_name);
+ }
+ else
+ {
+ if (print_screen (1, 0))
+ printf ("%s: Exception \"%s\" not set\n", test_name,
+ flag_name);
+ }
+ }
+ if (!ok)
+ ++noErrors;
+
+#endif
+}
+
+
+/* Test whether exceptions given by EXCEPTION are raised. Ignore thereby
+ allowed but not required exceptions.
+*/
+static void
+test_exceptions (const char *test_name, int exception)
+{
+ ++noExcTests;
+#ifdef FE_DIVBYZERO
+ if ((exception & DIVIDE_BY_ZERO_EXCEPTION_OK) == 0)
+ test_single_exception (test_name, exception,
+ DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
+ "Divide by zero");
+#endif
+#ifdef FE_INVALID
+ if ((exception & INVALID_EXCEPTION_OK) == 0)
+ test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
+ "Invalid operation");
+#endif
+ feclearexcept (FE_ALL_EXCEPT);
+}
+
+
+static void
+check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
+ FLOAT max_ulp, int xfail, int exceptions,
+ FLOAT *curr_max_error)
+{
+ int ok = 0;
+ int print_diff = 0;
+ FLOAT diff = 0;
+ FLOAT ulp = 0;
+
+ test_exceptions (test_name, exceptions);
+ if (isnan (computed) && isnan (expected))
+ ok = 1;
+ else if (isinf (computed) && isinf (expected))
+ {
+ /* Test for sign of infinities. */
+ if ((exceptions & IGNORE_ZERO_INF_SIGN) == 0
+ && signbit (computed) != signbit (expected))
+ {
+ ok = 0;
+ printf ("infinity has wrong sign.\n");
+ }
+ else
+ ok = 1;
+ }
+ /* Don't calc ulp for NaNs or infinities. */
+ else if (isinf (computed) || isnan (computed) || isinf (expected) || isnan (expected))
+ ok = 0;
+ else
+ {
+ diff = FUNC(fabs) (computed - expected);
+ /* ilogb (0) isn't allowed. */
+ if (expected == 0.0)
+ ulp = diff / FUNC(ldexp) (1.0, - MANT_DIG);
+ else
+ ulp = diff / FUNC(ldexp) (1.0, FUNC(ilogb) (expected) - MANT_DIG);
+ set_max_error (ulp, curr_max_error);
+ print_diff = 1;
+ if ((exceptions & IGNORE_ZERO_INF_SIGN) == 0
+ && computed == 0.0 && expected == 0.0
+ && signbit(computed) != signbit (expected))
+ ok = 0;
+ else if (ulp == 0.0 || (ulp <= max_ulp && !ignore_max_ulp))
+ ok = 1;
+ else
+ {
+ ok = 0;
+ print_ulps (test_name, ulp);
+ }
+
+ }
+ if (print_screen (ok, xfail))
+ {
+ if (!ok)
+ printf ("Failure: ");
+ printf ("Test: %s\n", test_name);
+ printf ("Result:\n");
+ printf (" is: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
+ computed, computed);
+ printf (" should be: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
+ expected, expected);
+ if (print_diff)
+ {
+ printf (" difference: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR
+ "\n", diff, diff);
+ printf (" ulp : % .4" PRINTF_NEXPR "\n", ulp);
+ printf (" max.ulp : % .4" PRINTF_NEXPR "\n", max_ulp);
+ }
+ }
+ update_stats (ok, xfail);
+
+ fpstack_test (test_name);
+}
+
+
+static void
+check_float (const char *test_name, FLOAT computed, FLOAT expected,
+ FLOAT max_ulp, int xfail, int exceptions)
+{
+ check_float_internal (test_name, computed, expected, max_ulp, xfail,
+ exceptions, &max_error);
+}
+
+
+static void
+check_complex (const char *test_name, __complex__ FLOAT computed,
+ __complex__ FLOAT expected,
+ __complex__ FLOAT max_ulp, __complex__ int xfail,
+ int exception)
+{
+ FLOAT part_comp, part_exp, part_max_ulp;
+ int part_xfail;
+ char str[200];
+
+ sprintf (str, "Real part of: %s", test_name);
+ part_comp = __real__ computed;
+ part_exp = __real__ expected;
+ part_max_ulp = __real__ max_ulp;
+ part_xfail = __real__ xfail;
+
+ check_float_internal (str, part_comp, part_exp, part_max_ulp, part_xfail,
+ exception, &real_max_error);
+
+ sprintf (str, "Imaginary part of: %s", test_name);
+ part_comp = __imag__ computed;
+ part_exp = __imag__ expected;
+ part_max_ulp = __imag__ max_ulp;
+ part_xfail = __imag__ xfail;
+
+ /* Don't check again for exceptions, just pass through the
+ zero/inf sign test. */
+ check_float_internal (str, part_comp, part_exp, part_max_ulp, part_xfail,
+ exception & IGNORE_ZERO_INF_SIGN,
+ &imag_max_error);
+}
+
+
+/* Check that computed and expected values are equal (int values). */
+static void
+check_int (const char *test_name, int computed, int expected, int max_ulp,
+ int xfail, int exceptions)
+{
+ int diff = computed - expected;
+ int ok = 0;
+
+ test_exceptions (test_name, exceptions);
+ noTests++;
+ if (abs (diff) <= max_ulp)
+ ok = 1;
+
+ if (!ok)
+ print_ulps (test_name, diff);
+
+ if (print_screen (ok, xfail))
+ {
+ if (!ok)
+ printf ("Failure: ");
+ printf ("Test: %s\n", test_name);
+ printf ("Result:\n");
+ printf (" is: %d\n", computed);
+ printf (" should be: %d\n", expected);
+ }
+
+ update_stats (ok, xfail);
+ fpstack_test (test_name);
+}
+
+
+/* Check that computed and expected values are equal (long int values). */
+static void
+check_long (const char *test_name, long int computed, long int expected,
+ long int max_ulp, int xfail, int exceptions)
+{
+ long int diff = computed - expected;
+ int ok = 0;
+
+ test_exceptions (test_name, exceptions);
+ noTests++;
+ if (labs (diff) <= max_ulp)
+ ok = 1;
+
+ if (!ok)
+ print_ulps (test_name, diff);
+
+ if (print_screen (ok, xfail))
+ {
+ if (!ok)
+ printf ("Failure: ");
+ printf ("Test: %s\n", test_name);
+ printf ("Result:\n");
+ printf (" is: %ld\n", computed);
+ printf (" should be: %ld\n", expected);
+ }
+
+ update_stats (ok, xfail);
+ fpstack_test (test_name);
+}
+
+
+/* Check that computed value is true/false. */
+static void
+check_bool (const char *test_name, int computed, int expected,
+ long int max_ulp, int xfail, int exceptions)
+{
+ int ok = 0;
+
+ test_exceptions (test_name, exceptions);
+ noTests++;
+ if ((computed == 0) == (expected == 0))
+ ok = 1;
+
+ if (print_screen (ok, xfail))
+ {
+ if (!ok)
+ printf ("Failure: ");
+ printf ("Test: %s\n", test_name);
+ printf ("Result:\n");
+ printf (" is: %d\n", computed);
+ printf (" should be: %d\n", expected);
+ }
+
+ update_stats (ok, xfail);
+ fpstack_test (test_name);
+}
+
+
+/* check that computed and expected values are equal (long int values) */
+static void
+check_longlong (const char *test_name, long long int computed,
+ long long int expected,
+ long long int max_ulp, int xfail,
+ int exceptions)
+{
+ long long int diff = computed - expected;
+ int ok = 0;
+
+ test_exceptions (test_name, exceptions);
+ noTests++;
+ if (llabs (diff) <= max_ulp)
+ ok = 1;
+
+ if (!ok)
+ print_ulps (test_name, diff);
+
+ if (print_screen (ok, xfail))
+ {
+ if (!ok)
+ printf ("Failure:");
+ printf ("Test: %s\n", test_name);
+ printf ("Result:\n");
+ printf (" is: %lld\n", computed);
+ printf (" should be: %lld\n", expected);
+ }
+
+ update_stats (ok, xfail);
+ fpstack_test (test_name);
+}
+
+
+
+/* This is to prevent messages from the SVID libm emulation. */
+int
+matherr (struct exception *x __attribute__ ((unused)))
+{
+ return 1;
+}
+
+
+/****************************************************************************
+ Tests for single functions of libm.
+ Please keep them alphabetically sorted!
+****************************************************************************/
+
+static void
+acos_test (void)
+{
+ errno = 0;
+ FUNC(acos) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (acos);
+
+ TEST_f_f (acos, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (acos, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (acos, nan_value, nan_value);
+
+ /* |x| > 1: */
+ TEST_f_f (acos, 1.1L, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (acos, -1.1L, nan_value, INVALID_EXCEPTION);
+
+ TEST_f_f (acos, 0, M_PI_2l);
+ TEST_f_f (acos, minus_zero, M_PI_2l);
+ TEST_f_f (acos, 1, 0);
+ TEST_f_f (acos, -1, M_PIl);
+ TEST_f_f (acos, 0.5, M_PI_6l*2.0);
+ TEST_f_f (acos, -0.5, M_PI_6l*4.0);
+ TEST_f_f (acos, 0.7L, 0.79539883018414355549096833892476432L);
+
+ END (acos);
+}
+
+static void
+acosh_test (void)
+{
+ errno = 0;
+ FUNC(acosh) (7);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (acosh);
+
+ TEST_f_f (acosh, plus_infty, plus_infty);
+ TEST_f_f (acosh, minus_infty, nan_value, INVALID_EXCEPTION);
+
+ /* x < 1: */
+ TEST_f_f (acosh, -1.1L, nan_value, INVALID_EXCEPTION);
+
+ TEST_f_f (acosh, 1, 0);
+ TEST_f_f (acosh, 7, 2.633915793849633417250092694615937L);
+
+ END (acosh);
+}
+
+static void
+asin_test (void)
+{
+ errno = 0;
+ FUNC(asin) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (asin);
+
+ TEST_f_f (asin, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (asin, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (asin, nan_value, nan_value);
+
+ /* asin x == NaN plus invalid exception for |x| > 1. */
+ TEST_f_f (asin, 1.1L, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (asin, -1.1L, nan_value, INVALID_EXCEPTION);
+
+ TEST_f_f (asin, 0, 0);
+ TEST_f_f (asin, minus_zero, minus_zero);
+ TEST_f_f (asin, 0.5, M_PI_6l);
+ TEST_f_f (asin, -0.5, -M_PI_6l);
+ TEST_f_f (asin, 1.0, M_PI_2l);
+ TEST_f_f (asin, -1.0, -M_PI_2l);
+ TEST_f_f (asin, 0.7L, 0.77539749661075306374035335271498708L);
+
+ END (asin);
+}
+
+static void
+asinh_test (void)
+{
+ errno = 0;
+ FUNC(asinh) (0.7L);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (asinh);
+
+ TEST_f_f (asinh, 0, 0);
+ TEST_f_f (asinh, minus_zero, minus_zero);
+#ifndef TEST_INLINE
+ TEST_f_f (asinh, plus_infty, plus_infty);
+ TEST_f_f (asinh, minus_infty, minus_infty);
+#endif
+ TEST_f_f (asinh, nan_value, nan_value);
+ TEST_f_f (asinh, 0.7L, 0.652666566082355786L);
+
+ END (asinh);
+}
+
+static void
+atan_test (void)
+{
+ errno = 0;
+ FUNC(atan) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (atan);
+
+ TEST_f_f (atan, 0, 0);
+ TEST_f_f (atan, minus_zero, minus_zero);
+
+ TEST_f_f (atan, plus_infty, M_PI_2l);
+ TEST_f_f (atan, minus_infty, -M_PI_2l);
+ TEST_f_f (atan, nan_value, nan_value);
+
+ TEST_f_f (atan, 1, M_PI_4l);
+ TEST_f_f (atan, -1, -M_PI_4l);
+
+ TEST_f_f (atan, 0.7L, 0.61072596438920861654375887649023613L);
+
+ END (atan);
+}
+
+
+
+static void
+atanh_test (void)
+{
+ errno = 0;
+ FUNC(atanh) (0.7L);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (atanh);
+
+
+ TEST_f_f (atanh, 0, 0);
+ TEST_f_f (atanh, minus_zero, minus_zero);
+
+ TEST_f_f (atanh, 1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (atanh, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (atanh, nan_value, nan_value);
+
+ /* atanh (x) == NaN plus invalid exception if |x| > 1. */
+ TEST_f_f (atanh, 1.1L, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (atanh, -1.1L, nan_value, INVALID_EXCEPTION);
+
+ TEST_f_f (atanh, 0.7L, 0.8673005276940531944L);
+
+ END (atanh);
+}
+
+static void
+atan2_test (void)
+{
+ errno = 0;
+ FUNC(atan2) (-0, 1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (atan2);
+
+ /* atan2 (0,x) == 0 for x > 0. */
+ TEST_ff_f (atan2, 0, 1, 0);
+
+ /* atan2 (-0,x) == -0 for x > 0. */
+ TEST_ff_f (atan2, minus_zero, 1, minus_zero);
+
+ TEST_ff_f (atan2, 0, 0, 0);
+ TEST_ff_f (atan2, minus_zero, 0, minus_zero);
+
+ /* atan2 (+0,x) == +pi for x < 0. */
+ TEST_ff_f (atan2, 0, -1, M_PIl);
+
+ /* atan2 (-0,x) == -pi for x < 0. */
+ TEST_ff_f (atan2, minus_zero, -1, -M_PIl);
+
+ TEST_ff_f (atan2, 0, minus_zero, M_PIl);
+ TEST_ff_f (atan2, minus_zero, minus_zero, -M_PIl);
+
+ /* atan2 (y,+0) == pi/2 for y > 0. */
+ TEST_ff_f (atan2, 1, 0, M_PI_2l);
+
+ /* atan2 (y,-0) == pi/2 for y > 0. */
+ TEST_ff_f (atan2, 1, minus_zero, M_PI_2l);
+
+ /* atan2 (y,+0) == -pi/2 for y < 0. */
+ TEST_ff_f (atan2, -1, 0, -M_PI_2l);
+
+ /* atan2 (y,-0) == -pi/2 for y < 0. */
+ TEST_ff_f (atan2, -1, minus_zero, -M_PI_2l);
+
+ /* atan2 (y,inf) == +0 for finite y > 0. */
+ TEST_ff_f (atan2, 1, plus_infty, 0);
+
+ /* atan2 (y,inf) == -0 for finite y < 0. */
+ TEST_ff_f (atan2, -1, plus_infty, minus_zero);
+
+ /* atan2(+inf, x) == pi/2 for finite x. */
+ TEST_ff_f (atan2, plus_infty, -1, M_PI_2l);
+
+ /* atan2(-inf, x) == -pi/2 for finite x. */
+ TEST_ff_f (atan2, minus_infty, 1, -M_PI_2l);
+
+ /* atan2 (y,-inf) == +pi for finite y > 0. */
+ TEST_ff_f (atan2, 1, minus_infty, M_PIl);
+
+ /* atan2 (y,-inf) == -pi for finite y < 0. */
+ TEST_ff_f (atan2, -1, minus_infty, -M_PIl);
+
+ TEST_ff_f (atan2, plus_infty, plus_infty, M_PI_4l);
+ TEST_ff_f (atan2, minus_infty, plus_infty, -M_PI_4l);
+ TEST_ff_f (atan2, plus_infty, minus_infty, M_PI_34l);
+ TEST_ff_f (atan2, minus_infty, minus_infty, -M_PI_34l);
+ TEST_ff_f (atan2, nan_value, nan_value, nan_value);
+
+ TEST_ff_f (atan2, 0.7L, 1, 0.61072596438920861654375887649023613L);
+ TEST_ff_f (atan2, -0.7L, 1.0L, -0.61072596438920861654375887649023613L);
+ TEST_ff_f (atan2, 0.7L, -1.0L, 2.530866689200584621918884506789267L);
+ TEST_ff_f (atan2, -0.7L, -1.0L, -2.530866689200584621918884506789267L);
+ TEST_ff_f (atan2, 0.4L, 0.0003L, 1.5700463269355215717704032607580829L);
+ TEST_ff_f (atan2, 1.4L, -0.93L, 2.1571487668237843754887415992772736L);
+
+ END (atan2);
+}
+
+
+static void
+cabs_test (void)
+{
+ errno = 0;
+ FUNC(cabs) (BUILD_COMPLEX (0.7L, 12.4L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (cabs);
+
+ /* cabs (x + iy) is specified as hypot (x,y) */
+
+ /* cabs (+inf + i x) == +inf. */
+ TEST_c_f (cabs, plus_infty, 1.0, plus_infty);
+ /* cabs (-inf + i x) == +inf. */
+ TEST_c_f (cabs, minus_infty, 1.0, plus_infty);
+
+ TEST_c_f (cabs, minus_infty, nan_value, plus_infty);
+ TEST_c_f (cabs, minus_infty, nan_value, plus_infty);
+
+ TEST_c_f (cabs, nan_value, nan_value, nan_value);
+
+ /* cabs (x,y) == cabs (y,x). */
+ TEST_c_f (cabs, 0.7L, 12.4L, 12.419742348374220601176836866763271L);
+ /* cabs (x,y) == cabs (-x,y). */
+ TEST_c_f (cabs, -12.4L, 0.7L, 12.419742348374220601176836866763271L);
+ /* cabs (x,y) == cabs (-y,x). */
+ TEST_c_f (cabs, -0.7L, 12.4L, 12.419742348374220601176836866763271L);
+ /* cabs (x,y) == cabs (-x,-y). */
+ TEST_c_f (cabs, -12.4L, -0.7L, 12.419742348374220601176836866763271L);
+ /* cabs (x,y) == cabs (-y,-x). */
+ TEST_c_f (cabs, -0.7L, -12.4L, 12.419742348374220601176836866763271L);
+ /* cabs (x,0) == fabs (x). */
+ TEST_c_f (cabs, -0.7L, 0, 0.7L);
+ TEST_c_f (cabs, 0.7L, 0, 0.7L);
+ TEST_c_f (cabs, -1.0L, 0, 1.0L);
+ TEST_c_f (cabs, 1.0L, 0, 1.0L);
+ TEST_c_f (cabs, -5.7e7L, 0, 5.7e7L);
+ TEST_c_f (cabs, 5.7e7L, 0, 5.7e7L);
+
+ TEST_c_f (cabs, 0.7L, 1.2L, 1.3892443989449804508432547041028554L);
+
+ END (cabs);
+}
+
+#if 0
+static void
+cacos_test (void)
+{
+ errno = 0;
+ FUNC(cacos) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (cacos);
+
+
+ TEST_c_c (cacos, 0, 0, M_PI_2l, minus_zero);
+ TEST_c_c (cacos, minus_zero, 0, M_PI_2l, minus_zero);
+ TEST_c_c (cacos, minus_zero, minus_zero, M_PI_2l, 0.0);
+ TEST_c_c (cacos, 0, minus_zero, M_PI_2l, 0.0);
+
+ TEST_c_c (cacos, minus_infty, plus_infty, M_PI_34l, minus_infty);
+ TEST_c_c (cacos, minus_infty, minus_infty, M_PI_34l, plus_infty);
+
+ TEST_c_c (cacos, plus_infty, plus_infty, M_PI_4l, minus_infty);
+ TEST_c_c (cacos, plus_infty, minus_infty, M_PI_4l, plus_infty);
+
+ TEST_c_c (cacos, -10.0, plus_infty, M_PI_2l, minus_infty);
+ TEST_c_c (cacos, -10.0, minus_infty, M_PI_2l, plus_infty);
+ TEST_c_c (cacos, 0, plus_infty, M_PI_2l, minus_infty);
+ TEST_c_c (cacos, 0, minus_infty, M_PI_2l, plus_infty);
+ TEST_c_c (cacos, 0.1L, plus_infty, M_PI_2l, minus_infty);
+ TEST_c_c (cacos, 0.1L, minus_infty, M_PI_2l, plus_infty);
+
+ TEST_c_c (cacos, minus_infty, 0, M_PIl, minus_infty);
+ TEST_c_c (cacos, minus_infty, minus_zero, M_PIl, plus_infty);
+ TEST_c_c (cacos, minus_infty, 100, M_PIl, minus_infty);
+ TEST_c_c (cacos, minus_infty, -100, M_PIl, plus_infty);
+
+ TEST_c_c (cacos, plus_infty, 0, 0.0, minus_infty);
+ TEST_c_c (cacos, plus_infty, minus_zero, 0.0, plus_infty);
+ TEST_c_c (cacos, plus_infty, 0.5, 0.0, minus_infty);
+ TEST_c_c (cacos, plus_infty, -0.5, 0.0, plus_infty);
+
+ TEST_c_c (cacos, plus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (cacos, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (cacos, 0, nan_value, M_PI_2l, nan_value);
+ TEST_c_c (cacos, minus_zero, nan_value, M_PI_2l, nan_value);
+
+ TEST_c_c (cacos, nan_value, plus_infty, nan_value, minus_infty);
+ TEST_c_c (cacos, nan_value, minus_infty, nan_value, plus_infty);
+
+ TEST_c_c (cacos, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (cacos, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (cacos, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (cacos, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (cacos, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (cacos, 0.7L, 1.2L, 1.1351827477151551088992008271819053L, -1.0927647857577371459105272080819308L);
+ TEST_c_c (cacos, -2, -3, 2.1414491111159960199416055713254211L, 1.9833870299165354323470769028940395L);
+
+ END (cacos, complex);
+}
+
+
+static void
+cacosh_test (void)
+{
+ errno = 0;
+ FUNC(cacosh) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (cacosh);
+
+
+ TEST_c_c (cacosh, 0, 0, 0.0, M_PI_2l);
+ TEST_c_c (cacosh, minus_zero, 0, 0.0, M_PI_2l);
+ TEST_c_c (cacosh, 0, minus_zero, 0.0, -M_PI_2l);
+ TEST_c_c (cacosh, minus_zero, minus_zero, 0.0, -M_PI_2l);
+ TEST_c_c (cacosh, minus_infty, plus_infty, plus_infty, M_PI_34l);
+ TEST_c_c (cacosh, minus_infty, minus_infty, plus_infty, -M_PI_34l);
+
+ TEST_c_c (cacosh, plus_infty, plus_infty, plus_infty, M_PI_4l);
+ TEST_c_c (cacosh, plus_infty, minus_infty, plus_infty, -M_PI_4l);
+
+ TEST_c_c (cacosh, -10.0, plus_infty, plus_infty, M_PI_2l);
+ TEST_c_c (cacosh, -10.0, minus_infty, plus_infty, -M_PI_2l);
+ TEST_c_c (cacosh, 0, plus_infty, plus_infty, M_PI_2l);
+ TEST_c_c (cacosh, 0, minus_infty, plus_infty, -M_PI_2l);
+ TEST_c_c (cacosh, 0.1L, plus_infty, plus_infty, M_PI_2l);
+ TEST_c_c (cacosh, 0.1L, minus_infty, plus_infty, -M_PI_2l);
+
+ TEST_c_c (cacosh, minus_infty, 0, plus_infty, M_PIl);
+ TEST_c_c (cacosh, minus_infty, minus_zero, plus_infty, -M_PIl);
+ TEST_c_c (cacosh, minus_infty, 100, plus_infty, M_PIl);
+ TEST_c_c (cacosh, minus_infty, -100, plus_infty, -M_PIl);
+
+ TEST_c_c (cacosh, plus_infty, 0, plus_infty, 0.0);
+ TEST_c_c (cacosh, plus_infty, minus_zero, plus_infty, minus_zero);
+ TEST_c_c (cacosh, plus_infty, 0.5, plus_infty, 0.0);
+ TEST_c_c (cacosh, plus_infty, -0.5, plus_infty, minus_zero);
+
+ TEST_c_c (cacosh, plus_infty, nan_value, plus_infty, nan_value);
+ TEST_c_c (cacosh, minus_infty, nan_value, plus_infty, nan_value);
+
+ TEST_c_c (cacosh, 0, nan_value, nan_value, nan_value);
+ TEST_c_c (cacosh, minus_zero, nan_value, nan_value, nan_value);
+
+ TEST_c_c (cacosh, nan_value, plus_infty, plus_infty, nan_value);
+ TEST_c_c (cacosh, nan_value, minus_infty, plus_infty, nan_value);
+
+ TEST_c_c (cacosh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (cacosh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (cacosh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (cacosh, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (cacosh, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (cacosh, 0.7L, 1.2L, 1.0927647857577371459105272080819308L, 1.1351827477151551088992008271819053L);
+ TEST_c_c (cacosh, -2, -3, -1.9833870299165354323470769028940395L, 2.1414491111159960199416055713254211L);
+
+ END (cacosh, complex);
+}
+
+static void
+carg_test (void)
+{
+ START (carg);
+
+ /* carg (x + iy) is specified as atan2 (y, x) */
+
+ /* carg (x + i 0) == 0 for x > 0. */
+ TEST_c_f (carg, 2.0, 0, 0);
+ /* carg (x - i 0) == -0 for x > 0. */
+ TEST_c_f (carg, 2.0, minus_zero, minus_zero);
+
+ TEST_c_f (carg, 0, 0, 0);
+ TEST_c_f (carg, 0, minus_zero, minus_zero);
+
+ /* carg (x + i 0) == +pi for x < 0. */
+ TEST_c_f (carg, -2.0, 0, M_PIl);
+
+ /* carg (x - i 0) == -pi for x < 0. */
+ TEST_c_f (carg, -2.0, minus_zero, -M_PIl);
+
+ TEST_c_f (carg, minus_zero, 0, M_PIl);
+ TEST_c_f (carg, minus_zero, minus_zero, -M_PIl);
+
+ /* carg (+0 + i y) == pi/2 for y > 0. */
+ TEST_c_f (carg, 0, 2.0, M_PI_2l);
+
+ /* carg (-0 + i y) == pi/2 for y > 0. */
+ TEST_c_f (carg, minus_zero, 2.0, M_PI_2l);
+
+ /* carg (+0 + i y) == -pi/2 for y < 0. */
+ TEST_c_f (carg, 0, -2.0, -M_PI_2l);
+
+ /* carg (-0 + i y) == -pi/2 for y < 0. */
+ TEST_c_f (carg, minus_zero, -2.0, -M_PI_2l);
+
+ /* carg (inf + i y) == +0 for finite y > 0. */
+ TEST_c_f (carg, plus_infty, 2.0, 0);
+
+ /* carg (inf + i y) == -0 for finite y < 0. */
+ TEST_c_f (carg, plus_infty, -2.0, minus_zero);
+
+ /* carg(x + i inf) == pi/2 for finite x. */
+ TEST_c_f (carg, 10.0, plus_infty, M_PI_2l);
+
+ /* carg(x - i inf) == -pi/2 for finite x. */
+ TEST_c_f (carg, 10.0, minus_infty, -M_PI_2l);
+
+ /* carg (-inf + i y) == +pi for finite y > 0. */
+ TEST_c_f (carg, minus_infty, 10.0, M_PIl);
+
+ /* carg (-inf + i y) == -pi for finite y < 0. */
+ TEST_c_f (carg, minus_infty, -10.0, -M_PIl);
+
+ TEST_c_f (carg, plus_infty, plus_infty, M_PI_4l);
+
+ TEST_c_f (carg, plus_infty, minus_infty, -M_PI_4l);
+
+ TEST_c_f (carg, minus_infty, plus_infty, 3 * M_PI_4l);
+
+ TEST_c_f (carg, minus_infty, minus_infty, -3 * M_PI_4l);
+
+ TEST_c_f (carg, nan_value, nan_value, nan_value);
+
+ END (carg);
+}
+
+static void
+casin_test (void)
+{
+ errno = 0;
+ FUNC(casin) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (casin);
+
+ TEST_c_c (casin, 0, 0, 0.0, 0.0);
+ TEST_c_c (casin, minus_zero, 0, minus_zero, 0.0);
+ TEST_c_c (casin, 0, minus_zero, 0.0, minus_zero);
+ TEST_c_c (casin, minus_zero, minus_zero, minus_zero, minus_zero);
+
+ TEST_c_c (casin, plus_infty, plus_infty, M_PI_4l, plus_infty);
+ TEST_c_c (casin, plus_infty, minus_infty, M_PI_4l, minus_infty);
+ TEST_c_c (casin, minus_infty, plus_infty, -M_PI_4l, plus_infty);
+ TEST_c_c (casin, minus_infty, minus_infty, -M_PI_4l, minus_infty);
+
+ TEST_c_c (casin, -10.0, plus_infty, minus_zero, plus_infty);
+ TEST_c_c (casin, -10.0, minus_infty, minus_zero, minus_infty);
+ TEST_c_c (casin, 0, plus_infty, 0.0, plus_infty);
+ TEST_c_c (casin, 0, minus_infty, 0.0, minus_infty);
+ TEST_c_c (casin, minus_zero, plus_infty, minus_zero, plus_infty);
+ TEST_c_c (casin, minus_zero, minus_infty, minus_zero, minus_infty);
+ TEST_c_c (casin, 0.1L, plus_infty, 0.0, plus_infty);
+ TEST_c_c (casin, 0.1L, minus_infty, 0.0, minus_infty);
+
+ TEST_c_c (casin, minus_infty, 0, -M_PI_2l, plus_infty);
+ TEST_c_c (casin, minus_infty, minus_zero, -M_PI_2l, minus_infty);
+ TEST_c_c (casin, minus_infty, 100, -M_PI_2l, plus_infty);
+ TEST_c_c (casin, minus_infty, -100, -M_PI_2l, minus_infty);
+
+ TEST_c_c (casin, plus_infty, 0, M_PI_2l, plus_infty);
+ TEST_c_c (casin, plus_infty, minus_zero, M_PI_2l, minus_infty);
+ TEST_c_c (casin, plus_infty, 0.5, M_PI_2l, plus_infty);
+ TEST_c_c (casin, plus_infty, -0.5, M_PI_2l, minus_infty);
+
+ TEST_c_c (casin, nan_value, plus_infty, nan_value, plus_infty);
+ TEST_c_c (casin, nan_value, minus_infty, nan_value, minus_infty);
+
+ TEST_c_c (casin, 0.0, nan_value, 0.0, nan_value);
+ TEST_c_c (casin, minus_zero, nan_value, minus_zero, nan_value);
+
+ TEST_c_c (casin, plus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (casin, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (casin, nan_value, 10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (casin, nan_value, -10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (casin, 0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (casin, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (casin, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (casin, 0.7L, 1.2L, 0.4356135790797415103321208644578462L, 1.0927647857577371459105272080819308L);
+ TEST_c_c (casin, -2, -3, -0.57065278432109940071028387968566963L, -1.9833870299165354323470769028940395L);
+
+ END (casin, complex);
+}
+
+
+static void
+casinh_test (void)
+{
+ errno = 0;
+ FUNC(casinh) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (casinh);
+
+ TEST_c_c (casinh, 0, 0, 0.0, 0.0);
+ TEST_c_c (casinh, minus_zero, 0, minus_zero, 0);
+ TEST_c_c (casinh, 0, minus_zero, 0.0, minus_zero);
+ TEST_c_c (casinh, minus_zero, minus_zero, minus_zero, minus_zero);
+
+ TEST_c_c (casinh, plus_infty, plus_infty, plus_infty, M_PI_4l);
+ TEST_c_c (casinh, plus_infty, minus_infty, plus_infty, -M_PI_4l);
+ TEST_c_c (casinh, minus_infty, plus_infty, minus_infty, M_PI_4l);
+ TEST_c_c (casinh, minus_infty, minus_infty, minus_infty, -M_PI_4l);
+
+ TEST_c_c (casinh, -10.0, plus_infty, minus_infty, M_PI_2l);
+ TEST_c_c (casinh, -10.0, minus_infty, minus_infty, -M_PI_2l);
+ TEST_c_c (casinh, 0, plus_infty, plus_infty, M_PI_2l);
+ TEST_c_c (casinh, 0, minus_infty, plus_infty, -M_PI_2l);
+ TEST_c_c (casinh, minus_zero, plus_infty, minus_infty, M_PI_2l);
+ TEST_c_c (casinh, minus_zero, minus_infty, minus_infty, -M_PI_2l);
+ TEST_c_c (casinh, 0.1L, plus_infty, plus_infty, M_PI_2l);
+ TEST_c_c (casinh, 0.1L, minus_infty, plus_infty, -M_PI_2l);
+
+ TEST_c_c (casinh, minus_infty, 0, minus_infty, 0.0);
+ TEST_c_c (casinh, minus_infty, minus_zero, minus_infty, minus_zero);
+ TEST_c_c (casinh, minus_infty, 100, minus_infty, 0.0);
+ TEST_c_c (casinh, minus_infty, -100, minus_infty, minus_zero);
+
+ TEST_c_c (casinh, plus_infty, 0, plus_infty, 0.0);
+ TEST_c_c (casinh, plus_infty, minus_zero, plus_infty, minus_zero);
+ TEST_c_c (casinh, plus_infty, 0.5, plus_infty, 0.0);
+ TEST_c_c (casinh, plus_infty, -0.5, plus_infty, minus_zero);
+
+ TEST_c_c (casinh, plus_infty, nan_value, plus_infty, nan_value);
+ TEST_c_c (casinh, minus_infty, nan_value, minus_infty, nan_value);
+
+ TEST_c_c (casinh, nan_value, 0, nan_value, 0.0);
+ TEST_c_c (casinh, nan_value, minus_zero, nan_value, minus_zero);
+
+ TEST_c_c (casinh, nan_value, plus_infty, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (casinh, nan_value, minus_infty, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (casinh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (casinh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (casinh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (casinh, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (casinh, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (casinh, 0.7L, 1.2L, 0.97865459559367387689317593222160964L, 0.91135418953156011567903546856170941L);
+ TEST_c_c (casinh, -2, -3, -1.9686379257930962917886650952454982L, -0.96465850440760279204541105949953237L);
+
+ END (casinh, complex);
+}
+
+
+static void
+catan_test (void)
+{
+ errno = 0;
+ FUNC(catan) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (catan);
+
+ TEST_c_c (catan, 0, 0, 0, 0);
+ TEST_c_c (catan, minus_zero, 0, minus_zero, 0);
+ TEST_c_c (catan, 0, minus_zero, 0, minus_zero);
+ TEST_c_c (catan, minus_zero, minus_zero, minus_zero, minus_zero);
+
+ TEST_c_c (catan, plus_infty, plus_infty, M_PI_2l, 0);
+ TEST_c_c (catan, plus_infty, minus_infty, M_PI_2l, minus_zero);
+ TEST_c_c (catan, minus_infty, plus_infty, -M_PI_2l, 0);
+ TEST_c_c (catan, minus_infty, minus_infty, -M_PI_2l, minus_zero);
+
+
+ TEST_c_c (catan, plus_infty, -10.0, M_PI_2l, minus_zero);
+ TEST_c_c (catan, minus_infty, -10.0, -M_PI_2l, minus_zero);
+ TEST_c_c (catan, plus_infty, minus_zero, M_PI_2l, minus_zero);
+ TEST_c_c (catan, minus_infty, minus_zero, -M_PI_2l, minus_zero);
+ TEST_c_c (catan, plus_infty, 0.0, M_PI_2l, 0);
+ TEST_c_c (catan, minus_infty, 0.0, -M_PI_2l, 0);
+ TEST_c_c (catan, plus_infty, 0.1L, M_PI_2l, 0);
+ TEST_c_c (catan, minus_infty, 0.1L, -M_PI_2l, 0);
+
+ TEST_c_c (catan, 0.0, minus_infty, M_PI_2l, minus_zero);
+ TEST_c_c (catan, minus_zero, minus_infty, -M_PI_2l, minus_zero);
+ TEST_c_c (catan, 100.0, minus_infty, M_PI_2l, minus_zero);
+ TEST_c_c (catan, -100.0, minus_infty, -M_PI_2l, minus_zero);
+
+ TEST_c_c (catan, 0.0, plus_infty, M_PI_2l, 0);
+ TEST_c_c (catan, minus_zero, plus_infty, -M_PI_2l, 0);
+ TEST_c_c (catan, 0.5, plus_infty, M_PI_2l, 0);
+ TEST_c_c (catan, -0.5, plus_infty, -M_PI_2l, 0);
+
+ TEST_c_c (catan, nan_value, 0.0, nan_value, 0);
+ TEST_c_c (catan, nan_value, minus_zero, nan_value, minus_zero);
+
+ TEST_c_c (catan, nan_value, plus_infty, nan_value, 0);
+ TEST_c_c (catan, nan_value, minus_infty, nan_value, minus_zero);
+
+ TEST_c_c (catan, 0.0, nan_value, nan_value, nan_value);
+ TEST_c_c (catan, minus_zero, nan_value, nan_value, nan_value);
+
+ TEST_c_c (catan, plus_infty, nan_value, M_PI_2l, 0, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (catan, minus_infty, nan_value, -M_PI_2l, 0, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (catan, nan_value, 10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (catan, nan_value, -10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (catan, 0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (catan, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (catan, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (catan, 0.7L, 1.2L, 1.0785743834118921877443707996386368L, 0.57705737765343067644394541889341712L);
+
+ TEST_c_c (catan, -2, -3, -1.4099210495965755225306193844604208L, -0.22907268296853876629588180294200276L);
+
+ END (catan, complex);
+}
+
+static void
+catanh_test (void)
+{
+ errno = 0;
+ FUNC(catanh) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (catanh);
+
+ TEST_c_c (catanh, 0, 0, 0.0, 0.0);
+ TEST_c_c (catanh, minus_zero, 0, minus_zero, 0.0);
+ TEST_c_c (catanh, 0, minus_zero, 0.0, minus_zero);
+ TEST_c_c (catanh, minus_zero, minus_zero, minus_zero, minus_zero);
+
+ TEST_c_c (catanh, plus_infty, plus_infty, 0.0, M_PI_2l);
+ TEST_c_c (catanh, plus_infty, minus_infty, 0.0, -M_PI_2l);
+ TEST_c_c (catanh, minus_infty, plus_infty, minus_zero, M_PI_2l);
+ TEST_c_c (catanh, minus_infty, minus_infty, minus_zero, -M_PI_2l);
+
+ TEST_c_c (catanh, -10.0, plus_infty, minus_zero, M_PI_2l);
+ TEST_c_c (catanh, -10.0, minus_infty, minus_zero, -M_PI_2l);
+ TEST_c_c (catanh, minus_zero, plus_infty, minus_zero, M_PI_2l);
+ TEST_c_c (catanh, minus_zero, minus_infty, minus_zero, -M_PI_2l);
+ TEST_c_c (catanh, 0, plus_infty, 0.0, M_PI_2l);
+ TEST_c_c (catanh, 0, minus_infty, 0.0, -M_PI_2l);
+ TEST_c_c (catanh, 0.1L, plus_infty, 0.0, M_PI_2l);
+ TEST_c_c (catanh, 0.1L, minus_infty, 0.0, -M_PI_2l);
+
+ TEST_c_c (catanh, minus_infty, 0, minus_zero, M_PI_2l);
+ TEST_c_c (catanh, minus_infty, minus_zero, minus_zero, -M_PI_2l);
+ TEST_c_c (catanh, minus_infty, 100, minus_zero, M_PI_2l);
+ TEST_c_c (catanh, minus_infty, -100, minus_zero, -M_PI_2l);
+
+ TEST_c_c (catanh, plus_infty, 0, 0.0, M_PI_2l);
+ TEST_c_c (catanh, plus_infty, minus_zero, 0.0, -M_PI_2l);
+ TEST_c_c (catanh, plus_infty, 0.5, 0.0, M_PI_2l);
+ TEST_c_c (catanh, plus_infty, -0.5, 0.0, -M_PI_2l);
+
+ TEST_c_c (catanh, 0, nan_value, 0.0, nan_value);
+ TEST_c_c (catanh, minus_zero, nan_value, minus_zero, nan_value);
+
+ TEST_c_c (catanh, plus_infty, nan_value, 0.0, nan_value);
+ TEST_c_c (catanh, minus_infty, nan_value, minus_zero, nan_value);
+
+ TEST_c_c (catanh, nan_value, 0, nan_value, nan_value);
+ TEST_c_c (catanh, nan_value, minus_zero, nan_value, nan_value);
+
+ TEST_c_c (catanh, nan_value, plus_infty, 0.0, M_PI_2l, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (catanh, nan_value, minus_infty, 0.0, -M_PI_2l, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (catanh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (catanh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (catanh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (catanh, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (catanh, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (catanh, 0.7L, 1.2L, 0.2600749516525135959200648705635915L, 0.97024030779509898497385130162655963L);
+ TEST_c_c (catanh, -2, -3, -0.14694666622552975204743278515471595L, -1.3389725222944935611241935759091443L);
+
+ END (catanh, complex);
+}
+#endif
+
+static void
+cbrt_test (void)
+{
+ errno = 0;
+ FUNC(cbrt) (8);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (cbrt);
+
+ TEST_f_f (cbrt, 0.0, 0.0);
+ TEST_f_f (cbrt, minus_zero, minus_zero);
+
+ TEST_f_f (cbrt, plus_infty, plus_infty);
+ TEST_f_f (cbrt, minus_infty, minus_infty);
+ TEST_f_f (cbrt, nan_value, nan_value);
+
+ TEST_f_f (cbrt, -0.001L, -0.1L);
+ TEST_f_f (cbrt, 8, 2);
+ TEST_f_f (cbrt, -27.0, -3.0);
+ TEST_f_f (cbrt, 0.970299L, 0.99L);
+ TEST_f_f (cbrt, 0.7L, 0.8879040017426007084L);
+
+ END (cbrt);
+}
+
+#if 0
+static void
+ccos_test (void)
+{
+ errno = 0;
+ FUNC(ccos) (BUILD_COMPLEX (0, 0));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (ccos);
+
+ TEST_c_c (ccos, 0.0, 0.0, 1.0, minus_zero);
+ TEST_c_c (ccos, minus_zero, 0.0, 1.0, 0.0);
+ TEST_c_c (ccos, 0.0, minus_zero, 1.0, 0.0);
+ TEST_c_c (ccos, minus_zero, minus_zero, 1.0, minus_zero);
+
+ TEST_c_c (ccos, plus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ccos, plus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ccos, minus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ccos, minus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (ccos, 0.0, plus_infty, plus_infty, minus_zero);
+ TEST_c_c (ccos, 0.0, minus_infty, plus_infty, 0.0);
+ TEST_c_c (ccos, minus_zero, plus_infty, plus_infty, 0.0);
+ TEST_c_c (ccos, minus_zero, minus_infty, plus_infty, minus_zero);
+
+ TEST_c_c (ccos, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccos, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccos, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccos, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (ccos, 4.625, plus_infty, minus_infty, plus_infty);
+ TEST_c_c (ccos, 4.625, minus_infty, minus_infty, minus_infty);
+ TEST_c_c (ccos, -4.625, plus_infty, minus_infty, minus_infty);
+ TEST_c_c (ccos, -4.625, minus_infty, minus_infty, plus_infty);
+
+ TEST_c_c (ccos, plus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccos, plus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccos, minus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccos, minus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (ccos, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ccos, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (ccos, nan_value, plus_infty, plus_infty, nan_value);
+ TEST_c_c (ccos, nan_value, minus_infty, plus_infty, nan_value);
+
+ TEST_c_c (ccos, nan_value, 9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ccos, nan_value, -9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (ccos, 0.0, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ccos, minus_zero, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (ccos, 10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ccos, -10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (ccos, plus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ccos, minus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (ccos, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (ccos, 0.7L, 1.2L, 1.3848657645312111080L, -0.97242170335830028619L);
+
+ TEST_c_c (ccos, -2, -3, -4.1896256909688072301L, -9.1092278937553365979L);
+
+ END (ccos, complex);
+}
+
+
+static void
+ccosh_test (void)
+{
+ errno = 0;
+ FUNC(ccosh) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (ccosh);
+
+ TEST_c_c (ccosh, 0.0, 0.0, 1.0, 0.0);
+ TEST_c_c (ccosh, minus_zero, 0.0, 1.0, minus_zero);
+ TEST_c_c (ccosh, 0.0, minus_zero, 1.0, minus_zero);
+ TEST_c_c (ccosh, minus_zero, minus_zero, 1.0, 0.0);
+
+ TEST_c_c (ccosh, 0.0, plus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ccosh, minus_zero, plus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ccosh, 0.0, minus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ccosh, minus_zero, minus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (ccosh, plus_infty, 0.0, plus_infty, 0.0);
+ TEST_c_c (ccosh, minus_infty, 0.0, plus_infty, minus_zero);
+ TEST_c_c (ccosh, plus_infty, minus_zero, plus_infty, minus_zero);
+ TEST_c_c (ccosh, minus_infty, minus_zero, plus_infty, 0.0);
+
+ TEST_c_c (ccosh, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccosh, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccosh, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccosh, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (ccosh, plus_infty, 4.625, minus_infty, minus_infty);
+ TEST_c_c (ccosh, minus_infty, 4.625, minus_infty, plus_infty);
+ TEST_c_c (ccosh, plus_infty, -4.625, minus_infty, plus_infty);
+ TEST_c_c (ccosh, minus_infty, -4.625, minus_infty, minus_infty);
+
+ TEST_c_c (ccosh, 6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccosh, -6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccosh, 6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ccosh, -6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (ccosh, 0.0, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ccosh, minus_zero, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (ccosh, plus_infty, nan_value, plus_infty, nan_value);
+ TEST_c_c (ccosh, minus_infty, nan_value, plus_infty, nan_value);
+
+ TEST_c_c (ccosh, 9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ccosh, -9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (ccosh, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ccosh, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (ccosh, nan_value, 10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ccosh, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (ccosh, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ccosh, nan_value, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (ccosh, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (ccosh, 0.7L, 1.2L, 0.4548202223691477654L, 0.7070296600921537682L);
+
+ TEST_c_c (ccosh, -2, -3, -3.7245455049153225654L, 0.5118225699873846088L);
+
+ END (ccosh, complex);
+}
+#endif
+
+static void
+ceil_test (void)
+{
+ START (ceil);
+
+ TEST_f_f (ceil, 0.0, 0.0);
+ TEST_f_f (ceil, minus_zero, minus_zero);
+ TEST_f_f (ceil, plus_infty, plus_infty);
+ TEST_f_f (ceil, minus_infty, minus_infty);
+ TEST_f_f (ceil, nan_value, nan_value);
+
+ TEST_f_f (ceil, M_PIl, 4.0);
+ TEST_f_f (ceil, -M_PIl, -3.0);
+
+ END (ceil);
+}
+
+#if 0
+static void
+cexp_test (void)
+{
+ errno = 0;
+ FUNC(cexp) (BUILD_COMPLEX (0, 0));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (cexp);
+
+ TEST_c_c (cexp, plus_zero, plus_zero, 1, 0.0);
+ TEST_c_c (cexp, minus_zero, plus_zero, 1, 0.0);
+ TEST_c_c (cexp, plus_zero, minus_zero, 1, minus_zero);
+ TEST_c_c (cexp, minus_zero, minus_zero, 1, minus_zero);
+
+ TEST_c_c (cexp, plus_infty, plus_zero, plus_infty, 0.0);
+ TEST_c_c (cexp, plus_infty, minus_zero, plus_infty, minus_zero);
+
+ TEST_c_c (cexp, minus_infty, plus_zero, 0.0, 0.0);
+ TEST_c_c (cexp, minus_infty, minus_zero, 0.0, minus_zero);
+
+ TEST_c_c (cexp, 0.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (cexp, minus_zero, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (cexp, 0.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (cexp, minus_zero, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (cexp, 100.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (cexp, -100.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (cexp, 100.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (cexp, -100.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (cexp, minus_infty, 2.0, minus_zero, 0.0);
+ TEST_c_c (cexp, minus_infty, 4.0, minus_zero, minus_zero);
+ TEST_c_c (cexp, plus_infty, 2.0, minus_infty, plus_infty);
+ TEST_c_c (cexp, plus_infty, 4.0, minus_infty, minus_infty);
+
+ TEST_c_c (cexp, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (cexp, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (cexp, minus_infty, plus_infty, 0.0, 0.0, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (cexp, minus_infty, minus_infty, 0.0, minus_zero, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (cexp, minus_infty, nan_value, 0, 0, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (cexp, plus_infty, nan_value, plus_infty, nan_value);
+
+ TEST_c_c (cexp, nan_value, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (cexp, nan_value, 1.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (cexp, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (cexp, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (cexp, 1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (cexp, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (cexp, 0.7L, 1.2L, 0.72969890915032360123451688642930727L, 1.8768962328348102821139467908203072L);
+ TEST_c_c (cexp, -2.0, -3.0, -0.13398091492954261346140525546115575L, -0.019098516261135196432576240858800925L);
+
+ END (cexp, complex);
+}
+
+static void
+cimag_test (void)
+{
+ START (cimag);
+ TEST_c_f (cimag, 1.0, 0.0, 0.0);
+ TEST_c_f (cimag, 1.0, minus_zero, minus_zero);
+ TEST_c_f (cimag, 1.0, nan_value, nan_value);
+ TEST_c_f (cimag, nan_value, nan_value, nan_value);
+ TEST_c_f (cimag, 1.0, plus_infty, plus_infty);
+ TEST_c_f (cimag, 1.0, minus_infty, minus_infty);
+ TEST_c_f (cimag, 2.0, 3.0, 3.0);
+
+ END (cimag);
+}
+
+static void
+clog_test (void)
+{
+ errno = 0;
+ FUNC(clog) (BUILD_COMPLEX (-2, -3));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (clog);
+
+ TEST_c_c (clog, minus_zero, 0, minus_infty, M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_c_c (clog, minus_zero, minus_zero, minus_infty, -M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
+
+ TEST_c_c (clog, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_c_c (clog, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION);
+
+ TEST_c_c (clog, minus_infty, plus_infty, plus_infty, M_PI_34l);
+ TEST_c_c (clog, minus_infty, minus_infty, plus_infty, -M_PI_34l);
+
+ TEST_c_c (clog, plus_infty, plus_infty, plus_infty, M_PI_4l);
+ TEST_c_c (clog, plus_infty, minus_infty, plus_infty, -M_PI_4l);
+
+ TEST_c_c (clog, 0, plus_infty, plus_infty, M_PI_2l);
+ TEST_c_c (clog, 3, plus_infty, plus_infty, M_PI_2l);
+ TEST_c_c (clog, minus_zero, plus_infty, plus_infty, M_PI_2l);
+ TEST_c_c (clog, -3, plus_infty, plus_infty, M_PI_2l);
+ TEST_c_c (clog, 0, minus_infty, plus_infty, -M_PI_2l);
+ TEST_c_c (clog, 3, minus_infty, plus_infty, -M_PI_2l);
+ TEST_c_c (clog, minus_zero, minus_infty, plus_infty, -M_PI_2l);
+ TEST_c_c (clog, -3, minus_infty, plus_infty, -M_PI_2l);
+
+ TEST_c_c (clog, minus_infty, 0, plus_infty, M_PIl);
+ TEST_c_c (clog, minus_infty, 1, plus_infty, M_PIl);
+ TEST_c_c (clog, minus_infty, minus_zero, plus_infty, -M_PIl);
+ TEST_c_c (clog, minus_infty, -1, plus_infty, -M_PIl);
+
+ TEST_c_c (clog, plus_infty, 0, plus_infty, 0.0);
+ TEST_c_c (clog, plus_infty, 1, plus_infty, 0.0);
+ TEST_c_c (clog, plus_infty, minus_zero, plus_infty, minus_zero);
+ TEST_c_c (clog, plus_infty, -1, plus_infty, minus_zero);
+
+ TEST_c_c (clog, plus_infty, nan_value, plus_infty, nan_value);
+ TEST_c_c (clog, minus_infty, nan_value, plus_infty, nan_value);
+
+ TEST_c_c (clog, nan_value, plus_infty, plus_infty, nan_value);
+ TEST_c_c (clog, nan_value, minus_infty, plus_infty, nan_value);
+
+ TEST_c_c (clog, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog, 3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog, -3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (clog, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog, nan_value, -5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (clog, nan_value, nan_value, nan_value, nan_value);
+ TEST_c_c (clog, -2, -3, 1.2824746787307683680267437207826593L, -2.1587989303424641704769327722648368L);
+
+ END (clog, complex);
+}
+
+
+static void
+clog10_test (void)
+{
+ errno = 0;
+ FUNC(clog10) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (clog10);
+
+ TEST_c_c (clog10, minus_zero, 0, minus_infty, M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
+
+ TEST_c_c (clog10, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_c_c (clog10, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION);
+
+ TEST_c_c (clog10, minus_infty, plus_infty, plus_infty, M_PI_34_LOG10El);
+
+ TEST_c_c (clog10, plus_infty, plus_infty, plus_infty, M_PI4_LOG10El);
+ TEST_c_c (clog10, plus_infty, minus_infty, plus_infty, -M_PI4_LOG10El);
+
+ TEST_c_c (clog10, 0, plus_infty, plus_infty, M_PI2_LOG10El);
+ TEST_c_c (clog10, 3, plus_infty, plus_infty, M_PI2_LOG10El);
+ TEST_c_c (clog10, minus_zero, plus_infty, plus_infty, M_PI2_LOG10El);
+ TEST_c_c (clog10, -3, plus_infty, plus_infty, M_PI2_LOG10El);
+ TEST_c_c (clog10, 0, minus_infty, plus_infty, -M_PI2_LOG10El);
+ TEST_c_c (clog10, 3, minus_infty, plus_infty, -M_PI2_LOG10El);
+ TEST_c_c (clog10, minus_zero, minus_infty, plus_infty, -M_PI2_LOG10El);
+ TEST_c_c (clog10, -3, minus_infty, plus_infty, -M_PI2_LOG10El);
+
+ TEST_c_c (clog10, minus_infty, 0, plus_infty, M_PI_LOG10El);
+ TEST_c_c (clog10, minus_infty, 1, plus_infty, M_PI_LOG10El);
+ TEST_c_c (clog10, minus_infty, minus_zero, plus_infty, -M_PI_LOG10El);
+ TEST_c_c (clog10, minus_infty, -1, plus_infty, -M_PI_LOG10El);
+
+ TEST_c_c (clog10, plus_infty, 0, plus_infty, 0.0);
+ TEST_c_c (clog10, plus_infty, 1, plus_infty, 0.0);
+ TEST_c_c (clog10, plus_infty, minus_zero, plus_infty, minus_zero);
+ TEST_c_c (clog10, plus_infty, -1, plus_infty, minus_zero);
+
+ TEST_c_c (clog10, plus_infty, nan_value, plus_infty, nan_value);
+ TEST_c_c (clog10, minus_infty, nan_value, plus_infty, nan_value);
+
+ TEST_c_c (clog10, nan_value, plus_infty, plus_infty, nan_value);
+ TEST_c_c (clog10, nan_value, minus_infty, plus_infty, nan_value);
+
+ TEST_c_c (clog10, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog10, 3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog10, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog10, -3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (clog10, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog10, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog10, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (clog10, nan_value, -5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (clog10, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (clog10, 0.7L, 1.2L, 0.1427786545038868803L, 0.4528483579352493248L);
+ TEST_c_c (clog10, -2, -3, 0.5569716761534183846L, -0.9375544629863747085L);
+
+ END (clog10, complex);
+}
+#endif
+
+static void
+conj_test (void)
+{
+ START (conj);
+ TEST_c_c (conj, 0.0, 0.0, 0.0, minus_zero);
+ TEST_c_c (conj, 0.0, minus_zero, 0.0, 0.0);
+ TEST_c_c (conj, nan_value, nan_value, nan_value, nan_value);
+ TEST_c_c (conj, plus_infty, minus_infty, plus_infty, plus_infty);
+ TEST_c_c (conj, plus_infty, plus_infty, plus_infty, minus_infty);
+ TEST_c_c (conj, 1.0, 2.0, 1.0, -2.0);
+ TEST_c_c (conj, 3.0, -4.0, 3.0, 4.0);
+
+ END (conj, complex);
+}
+
+
+static void
+copysign_test (void)
+{
+ START (copysign);
+
+ TEST_ff_f (copysign, 0, 4, 0);
+ TEST_ff_f (copysign, 0, -4, minus_zero);
+ TEST_ff_f (copysign, minus_zero, 4, 0);
+ TEST_ff_f (copysign, minus_zero, -4, minus_zero);
+
+ TEST_ff_f (copysign, plus_infty, 0, plus_infty);
+ TEST_ff_f (copysign, plus_infty, minus_zero, minus_infty);
+ TEST_ff_f (copysign, minus_infty, 0, plus_infty);
+ TEST_ff_f (copysign, minus_infty, minus_zero, minus_infty);
+
+ TEST_ff_f (copysign, 0, plus_infty, 0);
+ TEST_ff_f (copysign, 0, minus_zero, minus_zero);
+ TEST_ff_f (copysign, minus_zero, plus_infty, 0);
+ TEST_ff_f (copysign, minus_zero, minus_zero, minus_zero);
+
+ /* XXX More correctly we would have to check the sign of the NaN. */
+ TEST_ff_f (copysign, nan_value, 0, nan_value);
+ TEST_ff_f (copysign, nan_value, minus_zero, nan_value);
+ TEST_ff_f (copysign, -nan_value, 0, nan_value);
+ TEST_ff_f (copysign, -nan_value, minus_zero, nan_value);
+
+ END (copysign);
+}
+
+static void
+cos_test (void)
+{
+ errno = 0;
+ FUNC(cos) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (cos);
+
+ TEST_f_f (cos, 0, 1);
+ TEST_f_f (cos, minus_zero, 1);
+ TEST_f_f (cos, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (cos, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (cos, nan_value, nan_value);
+
+ TEST_f_f (cos, M_PI_6l * 2.0, 0.5);
+ TEST_f_f (cos, M_PI_6l * 4.0, -0.5);
+ TEST_f_f (cos, M_PI_2l, 0);
+
+ TEST_f_f (cos, 0.7L, 0.76484218728448842625585999019186495L);
+
+ END (cos);
+}
+
+static void
+cosh_test (void)
+{
+ errno = 0;
+ FUNC(cosh) (0.7L);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (cosh);
+ TEST_f_f (cosh, 0, 1);
+ TEST_f_f (cosh, minus_zero, 1);
+
+#ifndef TEST_INLINE
+ TEST_f_f (cosh, plus_infty, plus_infty);
+ TEST_f_f (cosh, minus_infty, plus_infty);
+#endif
+ TEST_f_f (cosh, nan_value, nan_value);
+
+ TEST_f_f (cosh, 0.7L, 1.255169005630943018L);
+ END (cosh);
+}
+
+#if 0
+static void
+cpow_test (void)
+{
+ errno = 0;
+ FUNC(cpow) (BUILD_COMPLEX (1, 0), BUILD_COMPLEX (0, 0));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (cpow);
+
+ TEST_cc_c (cpow, 1, 0, 0, 0, 1.0, 0.0);
+ TEST_cc_c (cpow, 2, 0, 10, 0, 1024.0, 0.0);
+
+ TEST_cc_c (cpow, M_El, 0, 0, 2 * M_PIl, 1.0, 0.0);
+ TEST_cc_c (cpow, 2, 3, 4, 0, -119.0, -120.0);
+
+ TEST_cc_c (cpow, nan_value, nan_value, nan_value, nan_value, nan_value, nan_value);
+
+ END (cpow, complex);
+}
+
+static void
+cproj_test (void)
+{
+ START (cproj);
+ TEST_c_c (cproj, 0.0, 0.0, 0.0, 0.0);
+ TEST_c_c (cproj, minus_zero, minus_zero, minus_zero, minus_zero);
+ TEST_c_c (cproj, 0.0, minus_zero, 0.0, minus_zero);
+ TEST_c_c (cproj, minus_zero, 0.0, minus_zero, 0.0);
+
+ TEST_c_c (cproj, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (cproj, plus_infty, plus_infty, plus_infty, 0.0);
+ TEST_c_c (cproj, plus_infty, minus_infty, plus_infty, minus_zero);
+ TEST_c_c (cproj, minus_infty, plus_infty, plus_infty, 0.0);
+ TEST_c_c (cproj, minus_infty, minus_infty, plus_infty, minus_zero);
+
+ TEST_c_c (cproj, 1.0, 0.0, 1.0, 0.0);
+ TEST_c_c (cproj, 2.0, 3.0, 0.2857142857142857142857142857142857L, 0.42857142857142857142857142857142855L);
+
+ END (cproj, complex);
+}
+
+static void
+creal_test (void)
+{
+ START (creal);
+ TEST_c_f (creal, 0.0, 1.0, 0.0);
+ TEST_c_f (creal, minus_zero, 1.0, minus_zero);
+ TEST_c_f (creal, nan_value, 1.0, nan_value);
+ TEST_c_f (creal, nan_value, nan_value, nan_value);
+ TEST_c_f (creal, plus_infty, 1.0, plus_infty);
+ TEST_c_f (creal, minus_infty, 1.0, minus_infty);
+ TEST_c_f (creal, 2.0, 3.0, 2.0);
+
+ END (creal);
+}
+
+static void
+csin_test (void)
+{
+ errno = 0;
+ FUNC(csin) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (csin);
+
+ TEST_c_c (csin, 0.0, 0.0, 0.0, 0.0);
+ TEST_c_c (csin, minus_zero, 0.0, minus_zero, 0.0);
+ TEST_c_c (csin, 0.0, minus_zero, 0, minus_zero);
+ TEST_c_c (csin, minus_zero, minus_zero, minus_zero, minus_zero);
+
+ TEST_c_c (csin, 0.0, plus_infty, 0.0, plus_infty);
+ TEST_c_c (csin, minus_zero, plus_infty, minus_zero, plus_infty);
+ TEST_c_c (csin, 0.0, minus_infty, 0.0, minus_infty);
+ TEST_c_c (csin, minus_zero, minus_infty, minus_zero, minus_infty);
+
+ TEST_c_c (csin, plus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csin, minus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csin, plus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csin, minus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (csin, plus_infty, plus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csin, minus_infty, plus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csin, plus_infty, minus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csin, minus_infty, minus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (csin, plus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (csin, plus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (csin, minus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (csin, minus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (csin, 4.625, plus_infty, minus_infty, minus_infty);
+ TEST_c_c (csin, 4.625, minus_infty, minus_infty, plus_infty);
+ TEST_c_c (csin, -4.625, plus_infty, plus_infty, minus_infty);
+ TEST_c_c (csin, -4.625, minus_infty, plus_infty, plus_infty);
+
+ TEST_c_c (csin, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csin, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (csin, nan_value, plus_infty, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csin, nan_value, minus_infty, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (csin, nan_value, 9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csin, nan_value, -9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (csin, 0.0, nan_value, 0.0, nan_value);
+ TEST_c_c (csin, minus_zero, nan_value, minus_zero, nan_value);
+
+ TEST_c_c (csin, 10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csin, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (csin, plus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csin, minus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (csin, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (csin, 0.7L, 1.2L, 1.1664563419657581376L, 1.1544997246948547371L);
+
+ TEST_c_c (csin, -2, -3, -9.1544991469114295734L, 4.1689069599665643507L);
+
+ END (csin, complex);
+}
+
+
+static void
+csinh_test (void)
+{
+ errno = 0;
+ FUNC(csinh) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (csinh);
+
+ TEST_c_c (csinh, 0.0, 0.0, 0.0, 0.0);
+ TEST_c_c (csinh, minus_zero, 0.0, minus_zero, 0.0);
+ TEST_c_c (csinh, 0.0, minus_zero, 0.0, minus_zero);
+ TEST_c_c (csinh, minus_zero, minus_zero, minus_zero, minus_zero);
+
+ TEST_c_c (csinh, 0.0, plus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csinh, minus_zero, plus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csinh, 0.0, minus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csinh, minus_zero, minus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (csinh, plus_infty, 0.0, plus_infty, 0.0);
+ TEST_c_c (csinh, minus_infty, 0.0, minus_infty, 0.0);
+ TEST_c_c (csinh, plus_infty, minus_zero, plus_infty, minus_zero);
+ TEST_c_c (csinh, minus_infty, minus_zero, minus_infty, minus_zero);
+
+ TEST_c_c (csinh, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csinh, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csinh, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csinh, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (csinh, plus_infty, 4.625, minus_infty, minus_infty);
+ TEST_c_c (csinh, minus_infty, 4.625, plus_infty, minus_infty);
+ TEST_c_c (csinh, plus_infty, -4.625, minus_infty, plus_infty);
+ TEST_c_c (csinh, minus_infty, -4.625, plus_infty, plus_infty);
+
+ TEST_c_c (csinh, 6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (csinh, -6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (csinh, 6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (csinh, -6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (csinh, 0.0, nan_value, 0.0, nan_value, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csinh, minus_zero, nan_value, 0.0, nan_value, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (csinh, plus_infty, nan_value, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (csinh, minus_infty, nan_value, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (csinh, 9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csinh, -9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (csinh, nan_value, 0.0, nan_value, 0.0);
+ TEST_c_c (csinh, nan_value, minus_zero, nan_value, minus_zero);
+
+ TEST_c_c (csinh, nan_value, 10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csinh, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (csinh, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csinh, nan_value, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (csinh, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (csinh, 0.7L, 1.2L, 0.27487868678117583582L, 1.1698665727426565139L);
+ TEST_c_c (csinh, -2, -3, 3.5905645899857799520L, -0.5309210862485198052L);
+
+ END (csinh, complex);
+}
+
+static void
+csqrt_test (void)
+{
+ errno = 0;
+ FUNC(csqrt) (BUILD_COMPLEX (-1, 0));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (csqrt);
+
+ TEST_c_c (csqrt, 0, 0, 0.0, 0.0);
+ TEST_c_c (csqrt, 0, minus_zero, 0, minus_zero);
+ TEST_c_c (csqrt, minus_zero, 0, 0.0, 0.0);
+ TEST_c_c (csqrt, minus_zero, minus_zero, 0.0, minus_zero);
+
+ TEST_c_c (csqrt, minus_infty, 0, 0.0, plus_infty);
+ TEST_c_c (csqrt, minus_infty, 6, 0.0, plus_infty);
+ TEST_c_c (csqrt, minus_infty, minus_zero, 0.0, minus_infty);
+ TEST_c_c (csqrt, minus_infty, -6, 0.0, minus_infty);
+
+ TEST_c_c (csqrt, plus_infty, 0, plus_infty, 0.0);
+ TEST_c_c (csqrt, plus_infty, 6, plus_infty, 0.0);
+ TEST_c_c (csqrt, plus_infty, minus_zero, plus_infty, minus_zero);
+ TEST_c_c (csqrt, plus_infty, -6, plus_infty, minus_zero);
+
+ TEST_c_c (csqrt, 0, plus_infty, plus_infty, plus_infty);
+ TEST_c_c (csqrt, 4, plus_infty, plus_infty, plus_infty);
+ TEST_c_c (csqrt, plus_infty, plus_infty, plus_infty, plus_infty);
+ TEST_c_c (csqrt, minus_zero, plus_infty, plus_infty, plus_infty);
+ TEST_c_c (csqrt, -4, plus_infty, plus_infty, plus_infty);
+ TEST_c_c (csqrt, minus_infty, plus_infty, plus_infty, plus_infty);
+ TEST_c_c (csqrt, 0, minus_infty, plus_infty, minus_infty);
+ TEST_c_c (csqrt, 4, minus_infty, plus_infty, minus_infty);
+ TEST_c_c (csqrt, plus_infty, minus_infty, plus_infty, minus_infty);
+ TEST_c_c (csqrt, minus_zero, minus_infty, plus_infty, minus_infty);
+ TEST_c_c (csqrt, -4, minus_infty, plus_infty, minus_infty);
+ TEST_c_c (csqrt, minus_infty, minus_infty, plus_infty, minus_infty);
+
+ TEST_c_c (csqrt, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (csqrt, plus_infty, nan_value, plus_infty, nan_value);
+
+ TEST_c_c (csqrt, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csqrt, 1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csqrt, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csqrt, -1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (csqrt, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csqrt, nan_value, 8, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csqrt, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (csqrt, nan_value, -8, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (csqrt, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (csqrt, 16.0, -30.0, 5.0, -3.0);
+ TEST_c_c (csqrt, -1, 0, 0.0, 1.0);
+ TEST_c_c (csqrt, 0, 2, 1.0, 1.0);
+ TEST_c_c (csqrt, 119, 120, 12.0, 5.0);
+ TEST_c_c (csqrt, 0.7L, 1.2L, 1.022067610030026450706487883081139L, 0.58704531296356521154977678719838035L);
+ TEST_c_c (csqrt, -2, -3, 0.89597747612983812471573375529004348L, -1.6741492280355400404480393008490519L);
+ TEST_c_c (csqrt, -2, 3, 0.89597747612983812471573375529004348L, 1.6741492280355400404480393008490519L);
+
+ END (csqrt, complex);
+}
+
+static void
+ctan_test (void)
+{
+ errno = 0;
+ FUNC(ctan) (BUILD_COMPLEX (0.7L, 1.2L));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (ctan);
+
+ TEST_c_c (ctan, 0, 0, 0.0, 0.0);
+ TEST_c_c (ctan, 0, minus_zero, 0.0, minus_zero);
+ TEST_c_c (ctan, minus_zero, 0, minus_zero, 0.0);
+ TEST_c_c (ctan, minus_zero, minus_zero, minus_zero, minus_zero);
+
+ TEST_c_c (ctan, 0, plus_infty, 0.0, 1.0);
+ TEST_c_c (ctan, 1, plus_infty, 0.0, 1.0);
+ TEST_c_c (ctan, minus_zero, plus_infty, minus_zero, 1.0);
+ TEST_c_c (ctan, -1, plus_infty, minus_zero, 1.0);
+
+ TEST_c_c (ctan, 0, minus_infty, 0.0, -1.0);
+ TEST_c_c (ctan, 1, minus_infty, 0.0, -1.0);
+ TEST_c_c (ctan, minus_zero, minus_infty, minus_zero, -1.0);
+ TEST_c_c (ctan, -1, minus_infty, minus_zero, -1.0);
+
+ TEST_c_c (ctan, plus_infty, 0, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctan, plus_infty, 2, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctan, minus_infty, 0, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctan, minus_infty, 2, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctan, plus_infty, minus_zero, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctan, plus_infty, -2, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctan, minus_infty, minus_zero, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctan, minus_infty, -2, nan_value, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (ctan, nan_value, plus_infty, 0.0, 1.0, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ctan, nan_value, minus_infty, 0.0, -1.0, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (ctan, 0, nan_value, 0.0, nan_value);
+ TEST_c_c (ctan, minus_zero, nan_value, minus_zero, nan_value);
+
+ TEST_c_c (ctan, 0.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ctan, -4.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (ctan, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ctan, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ctan, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ctan, nan_value, -0.25, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (ctan, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (ctan, 0.7L, 1.2L, 0.1720734197630349001L, 0.9544807059989405538L);
+ TEST_c_c (ctan, -2, -3, 0.0037640256415042482L, -1.0032386273536098014L);
+
+ END (ctan, complex);
+}
+
+
+static void
+ctanh_test (void)
+{
+ errno = 0;
+ FUNC(ctanh) (BUILD_COMPLEX (0, 0));
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (ctanh);
+
+ TEST_c_c (ctanh, 0, 0, 0.0, 0.0);
+ TEST_c_c (ctanh, 0, minus_zero, 0.0, minus_zero);
+ TEST_c_c (ctanh, minus_zero, 0, minus_zero, 0.0);
+ TEST_c_c (ctanh, minus_zero, minus_zero, minus_zero, minus_zero);
+
+ TEST_c_c (ctanh, plus_infty, 0, 1.0, 0.0);
+ TEST_c_c (ctanh, plus_infty, 1, 1.0, 0.0);
+ TEST_c_c (ctanh, plus_infty, minus_zero, 1.0, minus_zero);
+ TEST_c_c (ctanh, plus_infty, -1, 1.0, minus_zero);
+ TEST_c_c (ctanh, minus_infty, 0, -1.0, 0.0);
+ TEST_c_c (ctanh, minus_infty, 1, -1.0, 0.0);
+ TEST_c_c (ctanh, minus_infty, minus_zero, -1.0, minus_zero);
+ TEST_c_c (ctanh, minus_infty, -1, -1.0, minus_zero);
+
+ TEST_c_c (ctanh, 0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctanh, 2, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctanh, 0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctanh, 2, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctanh, minus_zero, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctanh, -2, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctanh, minus_zero, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_c_c (ctanh, -2, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+
+ TEST_c_c (ctanh, plus_infty, nan_value, 1.0, 0.0, IGNORE_ZERO_INF_SIGN);
+ TEST_c_c (ctanh, minus_infty, nan_value, -1.0, 0.0, IGNORE_ZERO_INF_SIGN);
+
+ TEST_c_c (ctanh, nan_value, 0, nan_value, 0.0);
+ TEST_c_c (ctanh, nan_value, minus_zero, nan_value, minus_zero);
+
+ TEST_c_c (ctanh, nan_value, 0.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ctanh, nan_value, -4.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (ctanh, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ctanh, 5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ctanh, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_c_c (ctanh, -0.25, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
+
+ TEST_c_c (ctanh, nan_value, nan_value, nan_value, nan_value);
+
+ TEST_c_c (ctanh, 0, M_PI_4l, 0.0, 1.0);
+
+ TEST_c_c (ctanh, 0.7L, 1.2L, 1.3472197399061191630L, 0.4778641038326365540L);
+ TEST_c_c (ctanh, -2, -3, -0.9653858790221331242L, 0.0098843750383224937L);
+
+ END (ctanh, complex);
+}
+#endif
+
+static void
+erf_test (void)
+{
+ errno = 0;
+ FUNC(erf) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (erf);
+
+ TEST_f_f (erf, 0, 0);
+ TEST_f_f (erf, minus_zero, minus_zero);
+ TEST_f_f (erf, plus_infty, 1);
+ TEST_f_f (erf, minus_infty, -1);
+ TEST_f_f (erf, nan_value, nan_value);
+
+ TEST_f_f (erf, 0.7L, 0.67780119383741847297L);
+
+ TEST_f_f (erf, 1.2L, 0.91031397822963538024L);
+ TEST_f_f (erf, 2.0, 0.99532226501895273416L);
+ TEST_f_f (erf, 4.1L, 0.99999999329997234592L);
+ TEST_f_f (erf, 27, 1.0L);
+
+ END (erf);
+}
+
+
+static void
+erfc_test (void)
+{
+ errno = 0;
+ FUNC(erfc) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (erfc);
+
+ TEST_f_f (erfc, plus_infty, 0.0);
+ TEST_f_f (erfc, minus_infty, 2.0);
+ TEST_f_f (erfc, 0.0, 1.0);
+ TEST_f_f (erfc, minus_zero, 1.0);
+ TEST_f_f (erfc, nan_value, nan_value);
+
+ TEST_f_f (erfc, 0.7L, 0.32219880616258152702L);
+
+ TEST_f_f (erfc, 1.2L, 0.089686021770364619762L);
+ TEST_f_f (erfc, 2.0, 0.0046777349810472658379L);
+ TEST_f_f (erfc, 4.1L, 0.67000276540848983727e-8L);
+ TEST_f_f (erfc, 9, 0.41370317465138102381e-36L);
+
+ END (erfc);
+}
+
+static void
+exp_test (void)
+{
+ errno = 0;
+ FUNC(exp) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (exp);
+
+ TEST_f_f (exp, 0, 1);
+ TEST_f_f (exp, minus_zero, 1);
+
+#ifndef TEST_INLINE
+ TEST_f_f (exp, plus_infty, plus_infty);
+ TEST_f_f (exp, minus_infty, 0);
+#endif
+ TEST_f_f (exp, nan_value, nan_value);
+ TEST_f_f (exp, 1, M_El);
+
+ TEST_f_f (exp, 2, M_E2l);
+ TEST_f_f (exp, 3, M_E3l);
+ TEST_f_f (exp, 0.7L, 2.0137527074704765216L);
+ TEST_f_f (exp, 50.0L, 5184705528587072464087.45332293348538L);
+#ifdef TEST_LDOUBLE
+ /* The result can only be represented in long double. */
+ TEST_f_f (exp, 1000.0L, 0.197007111401704699388887935224332313e435L);
+#endif
+ END (exp);
+}
+
+
+#if 0
+static void
+exp10_test (void)
+{
+ errno = 0;
+ FUNC(exp10) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (exp10);
+
+ TEST_f_f (exp10, 0, 1);
+ TEST_f_f (exp10, minus_zero, 1);
+
+ TEST_f_f (exp10, plus_infty, plus_infty);
+ TEST_f_f (exp10, minus_infty, 0);
+ TEST_f_f (exp10, nan_value, nan_value);
+ TEST_f_f (exp10, 3, 1000);
+ TEST_f_f (exp10, -1, 0.1L);
+ TEST_f_f (exp10, 1e6, plus_infty);
+ TEST_f_f (exp10, -1e6, 0);
+ TEST_f_f (exp10, 0.7L, 5.0118723362727228500155418688494574L);
+
+ END (exp10);
+}
+
+static void
+exp2_test (void)
+{
+ errno = 0;
+ FUNC(exp2) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (exp2);
+
+ TEST_f_f (exp2, 0, 1);
+ TEST_f_f (exp2, minus_zero, 1);
+ TEST_f_f (exp2, plus_infty, plus_infty);
+ TEST_f_f (exp2, minus_infty, 0);
+ TEST_f_f (exp2, nan_value, nan_value);
+
+ TEST_f_f (exp2, 10, 1024);
+ TEST_f_f (exp2, -1, 0.5);
+ TEST_f_f (exp2, 1e6, plus_infty);
+ TEST_f_f (exp2, -1e6, 0);
+ TEST_f_f (exp2, 0.7L, 1.6245047927124710452L);
+
+ END (exp2);
+}
+#endif
+
+static void
+expm1_test (void)
+{
+ errno = 0;
+ FUNC(expm1) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (expm1);
+
+ TEST_f_f (expm1, 0, 0);
+ TEST_f_f (expm1, minus_zero, minus_zero);
+
+#ifndef TEST_INLINE
+ TEST_f_f (expm1, plus_infty, plus_infty);
+ TEST_f_f (expm1, minus_infty, -1);
+#endif
+ TEST_f_f (expm1, nan_value, nan_value);
+
+ TEST_f_f (expm1, 1, M_El - 1.0);
+ TEST_f_f (expm1, 0.7L, 1.0137527074704765216L);
+
+ END (expm1);
+}
+
+static void
+fabs_test (void)
+{
+ START (fabs);
+
+ TEST_f_f (fabs, 0, 0);
+ TEST_f_f (fabs, minus_zero, 0);
+
+ TEST_f_f (fabs, plus_infty, plus_infty);
+ TEST_f_f (fabs, minus_infty, plus_infty);
+ TEST_f_f (fabs, nan_value, nan_value);
+
+ TEST_f_f (fabs, 38.0, 38.0);
+ TEST_f_f (fabs, -M_El, M_El);
+
+ END (fabs);
+}
+
+#if 0
+static void
+fdim_test (void)
+{
+ START (fdim);
+
+ TEST_ff_f (fdim, 0, 0, 0);
+ TEST_ff_f (fdim, 9, 0, 9);
+ TEST_ff_f (fdim, 0, 9, 0);
+ TEST_ff_f (fdim, -9, 0, 0);
+ TEST_ff_f (fdim, 0, -9, 9);
+
+ TEST_ff_f (fdim, plus_infty, 9, plus_infty);
+ TEST_ff_f (fdim, plus_infty, -9, plus_infty);
+ TEST_ff_f (fdim, minus_infty, 9, 0);
+ TEST_ff_f (fdim, minus_infty, -9, 0);
+ TEST_ff_f (fdim, 9, minus_infty, plus_infty);
+ TEST_ff_f (fdim, -9, minus_infty, plus_infty);
+ TEST_ff_f (fdim, 9, plus_infty, 0);
+ TEST_ff_f (fdim, -9, plus_infty, 0);
+
+ TEST_ff_f (fdim, 0, nan_value, nan_value);
+ TEST_ff_f (fdim, 9, nan_value, nan_value);
+ TEST_ff_f (fdim, -9, nan_value, nan_value);
+ TEST_ff_f (fdim, nan_value, 9, nan_value);
+ TEST_ff_f (fdim, nan_value, -9, nan_value);
+ TEST_ff_f (fdim, plus_infty, nan_value, nan_value);
+ TEST_ff_f (fdim, minus_infty, nan_value, nan_value);
+ TEST_ff_f (fdim, nan_value, plus_infty, nan_value);
+ TEST_ff_f (fdim, nan_value, minus_infty, nan_value);
+ TEST_ff_f (fdim, nan_value, nan_value, nan_value);
+
+ END (fdim);
+}
+#endif
+
+static void
+floor_test (void)
+{
+ START (floor);
+
+ TEST_f_f (floor, 0.0, 0.0);
+ TEST_f_f (floor, minus_zero, minus_zero);
+ TEST_f_f (floor, plus_infty, plus_infty);
+ TEST_f_f (floor, minus_infty, minus_infty);
+ TEST_f_f (floor, nan_value, nan_value);
+
+ TEST_f_f (floor, M_PIl, 3.0);
+ TEST_f_f (floor, -M_PIl, -4.0);
+
+ END (floor);
+}
+
+#if 0
+static void
+fma_test (void)
+{
+ START (fma);
+
+ TEST_fff_f (fma, 1.0, 2.0, 3.0, 5.0);
+ TEST_fff_f (fma, nan_value, 2.0, 3.0, nan_value);
+ TEST_fff_f (fma, 1.0, nan_value, 3.0, nan_value);
+ TEST_fff_f (fma, 1.0, 2.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_fff_f (fma, plus_infty, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_fff_f (fma, minus_infty, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_fff_f (fma, 0.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_fff_f (fma, 0.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
+ TEST_fff_f (fma, plus_infty, 0.0, 1.0, nan_value, INVALID_EXCEPTION);
+ TEST_fff_f (fma, minus_infty, 0.0, 1.0, nan_value, INVALID_EXCEPTION);
+ TEST_fff_f (fma, 0.0, plus_infty, 1.0, nan_value, INVALID_EXCEPTION);
+ TEST_fff_f (fma, 0.0, minus_infty, 1.0, nan_value, INVALID_EXCEPTION);
+
+ TEST_fff_f (fma, plus_infty, plus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_fff_f (fma, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_fff_f (fma, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_fff_f (fma, minus_infty, minus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
+
+ END (fma);
+}
+
+
+static void
+fmax_test (void)
+{
+ START (fmax);
+
+ TEST_ff_f (fmax, 0, 0, 0);
+ TEST_ff_f (fmax, minus_zero, minus_zero, minus_zero);
+ TEST_ff_f (fmax, 9, 0, 9);
+ TEST_ff_f (fmax, 0, 9, 9);
+ TEST_ff_f (fmax, -9, 0, 0);
+ TEST_ff_f (fmax, 0, -9, 0);
+
+ TEST_ff_f (fmax, plus_infty, 9, plus_infty);
+ TEST_ff_f (fmax, 0, plus_infty, plus_infty);
+ TEST_ff_f (fmax, -9, plus_infty, plus_infty);
+ TEST_ff_f (fmax, plus_infty, -9, plus_infty);
+
+ TEST_ff_f (fmax, minus_infty, 9, 9);
+ TEST_ff_f (fmax, minus_infty, -9, -9);
+ TEST_ff_f (fmax, 9, minus_infty, 9);
+ TEST_ff_f (fmax, -9, minus_infty, -9);
+
+ TEST_ff_f (fmax, 0, nan_value, 0);
+ TEST_ff_f (fmax, 9, nan_value, 9);
+ TEST_ff_f (fmax, -9, nan_value, -9);
+ TEST_ff_f (fmax, nan_value, 0, 0);
+ TEST_ff_f (fmax, nan_value, 9, 9);
+ TEST_ff_f (fmax, nan_value, -9, -9);
+ TEST_ff_f (fmax, plus_infty, nan_value, plus_infty);
+ TEST_ff_f (fmax, minus_infty, nan_value, minus_infty);
+ TEST_ff_f (fmax, nan_value, plus_infty, plus_infty);
+ TEST_ff_f (fmax, nan_value, minus_infty, minus_infty);
+ TEST_ff_f (fmax, nan_value, nan_value, nan_value);
+
+ END (fmax);
+}
+
+
+static void
+fmin_test (void)
+{
+ START (fmin);
+
+ TEST_ff_f (fmin, 0, 0, 0);
+ TEST_ff_f (fmin, minus_zero, minus_zero, minus_zero);
+ TEST_ff_f (fmin, 9, 0, 0);
+ TEST_ff_f (fmin, 0, 9, 0);
+ TEST_ff_f (fmin, -9, 0, -9);
+ TEST_ff_f (fmin, 0, -9, -9);
+
+ TEST_ff_f (fmin, plus_infty, 9, 9);
+ TEST_ff_f (fmin, 9, plus_infty, 9);
+ TEST_ff_f (fmin, plus_infty, -9, -9);
+ TEST_ff_f (fmin, -9, plus_infty, -9);
+ TEST_ff_f (fmin, minus_infty, 9, minus_infty);
+ TEST_ff_f (fmin, minus_infty, -9, minus_infty);
+ TEST_ff_f (fmin, 9, minus_infty, minus_infty);
+ TEST_ff_f (fmin, -9, minus_infty, minus_infty);
+
+ TEST_ff_f (fmin, 0, nan_value, 0);
+ TEST_ff_f (fmin, 9, nan_value, 9);
+ TEST_ff_f (fmin, -9, nan_value, -9);
+ TEST_ff_f (fmin, nan_value, 0, 0);
+ TEST_ff_f (fmin, nan_value, 9, 9);
+ TEST_ff_f (fmin, nan_value, -9, -9);
+ TEST_ff_f (fmin, plus_infty, nan_value, plus_infty);
+ TEST_ff_f (fmin, minus_infty, nan_value, minus_infty);
+ TEST_ff_f (fmin, nan_value, plus_infty, plus_infty);
+ TEST_ff_f (fmin, nan_value, minus_infty, minus_infty);
+ TEST_ff_f (fmin, nan_value, nan_value, nan_value);
+
+ END (fmin);
+}
+#endif
+
+static void
+fmod_test (void)
+{
+ errno = 0;
+ FUNC(fmod) (6.5, 2.3L);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (fmod);
+
+ /* fmod (+0, y) == +0 for y != 0. */
+ TEST_ff_f (fmod, 0, 3, 0);
+
+ /* fmod (-0, y) == -0 for y != 0. */
+ TEST_ff_f (fmod, minus_zero, 3, minus_zero);
+
+ /* fmod (+inf, y) == NaN plus invalid exception. */
+ TEST_ff_f (fmod, plus_infty, 3, nan_value, INVALID_EXCEPTION);
+ /* fmod (-inf, y) == NaN plus invalid exception. */
+ TEST_ff_f (fmod, minus_infty, 3, nan_value, INVALID_EXCEPTION);
+ /* fmod (x, +0) == NaN plus invalid exception. */
+ TEST_ff_f (fmod, 3, 0, nan_value, INVALID_EXCEPTION);
+ /* fmod (x, -0) == NaN plus invalid exception. */
+ TEST_ff_f (fmod, 3, minus_zero, nan_value, INVALID_EXCEPTION);
+
+ /* fmod (x, +inf) == x for x not infinite. */
+ TEST_ff_f (fmod, 3.0, plus_infty, 3.0);
+ /* fmod (x, -inf) == x for x not infinite. */
+ TEST_ff_f (fmod, 3.0, minus_infty, 3.0);
+
+ TEST_ff_f (fmod, nan_value, nan_value, nan_value);
+
+ TEST_ff_f (fmod, 6.5, 2.3L, 1.9L);
+ TEST_ff_f (fmod, -6.5, 2.3L, -1.9L);
+ TEST_ff_f (fmod, 6.5, -2.3L, 1.9L);
+ TEST_ff_f (fmod, -6.5, -2.3L, -1.9L);
+
+ END (fmod);
+}
+
+static void
+fpclassify_test (void)
+{
+ START (fpclassify);
+
+ TEST_f_i (fpclassify, nan_value, FP_NAN);
+ TEST_f_i (fpclassify, plus_infty, FP_INFINITE);
+ TEST_f_i (fpclassify, minus_infty, FP_INFINITE);
+ TEST_f_i (fpclassify, plus_zero, FP_ZERO);
+ TEST_f_i (fpclassify, minus_zero, FP_ZERO);
+ TEST_f_i (fpclassify, 1000, FP_NORMAL);
+
+ END (fpclassify);
+}
+
+
+static void
+frexp_test (void)
+{
+ int x;
+
+ START (frexp);
+
+ TEST_fI_f1 (frexp, plus_infty, plus_infty, IGNORE);
+ TEST_fI_f1 (frexp, minus_infty, minus_infty, IGNORE);
+ TEST_fI_f1 (frexp, nan_value, nan_value, IGNORE);
+
+ TEST_fI_f1 (frexp, 0.0, 0.0, 0.0);
+ TEST_fI_f1 (frexp, minus_zero, minus_zero, 0.0);
+
+ TEST_fI_f1 (frexp, 12.8L, 0.8L, 4);
+ TEST_fI_f1 (frexp, -27.34L, -0.854375L, 5);
+
+ END (frexp);
+}
+
+
+static void
+gamma_test (void)
+{
+ errno = 0;
+ FUNC(gamma) (1);
+
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+ feclearexcept (FE_ALL_EXCEPT);
+
+ START (gamma);
+
+ TEST_f_f (gamma, plus_infty, plus_infty);
+ TEST_f_f (gamma, 0, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (gamma, -3, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (gamma, minus_infty, plus_infty);
+ TEST_f_f (gamma, nan_value, nan_value);
+
+ TEST_f_f1 (gamma, 1, 0, 1);
+ TEST_f_f1 (gamma, 3, M_LN2l, 1);
+
+ TEST_f_f1 (gamma, 0.5, M_LOG_SQRT_PIl, 1);
+ TEST_f_f1 (gamma, -0.5, M_LOG_2_SQRT_PIl, -1);
+
+ END (gamma);
+}
+
+static void
+hypot_test (void)
+{
+ errno = 0;
+ FUNC(hypot) (0.7L, 12.4L);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (hypot);
+
+ TEST_ff_f (hypot, plus_infty, 1, plus_infty, IGNORE_ZERO_INF_SIGN);
+ TEST_ff_f (hypot, minus_infty, 1, plus_infty, IGNORE_ZERO_INF_SIGN);
+
+#ifndef TEST_INLINE
+ TEST_ff_f (hypot, plus_infty, nan_value, plus_infty);
+ TEST_ff_f (hypot, minus_infty, nan_value, plus_infty);
+ TEST_ff_f (hypot, nan_value, plus_infty, plus_infty);
+ TEST_ff_f (hypot, nan_value, minus_infty, plus_infty);
+#endif
+
+ TEST_ff_f (hypot, nan_value, nan_value, nan_value);
+
+ /* hypot (x,y) == hypot (+-x, +-y) */
+ TEST_ff_f (hypot, 0.7L, 12.4L, 12.419742348374220601176836866763271L);
+ TEST_ff_f (hypot, -0.7L, 12.4L, 12.419742348374220601176836866763271L);
+ TEST_ff_f (hypot, 0.7L, -12.4L, 12.419742348374220601176836866763271L);
+ TEST_ff_f (hypot, -0.7L, -12.4L, 12.419742348374220601176836866763271L);
+ TEST_ff_f (hypot, 12.4L, 0.7L, 12.419742348374220601176836866763271L);
+ TEST_ff_f (hypot, -12.4L, 0.7L, 12.419742348374220601176836866763271L);
+ TEST_ff_f (hypot, 12.4L, -0.7L, 12.419742348374220601176836866763271L);
+ TEST_ff_f (hypot, -12.4L, -0.7L, 12.419742348374220601176836866763271L);
+
+ /* hypot (x,0) == fabs (x) */
+ TEST_ff_f (hypot, 0.7L, 0, 0.7L);
+ TEST_ff_f (hypot, -0.7L, 0, 0.7L);
+ TEST_ff_f (hypot, -5.7e7, 0, 5.7e7L);
+
+ TEST_ff_f (hypot, 0.7L, 1.2L, 1.3892443989449804508432547041028554L);
+
+ END (hypot);
+}
+
+
+static void
+ilogb_test (void)
+{
+ START (ilogb);
+
+ TEST_f_i (ilogb, 1, 0);
+ TEST_f_i (ilogb, M_El, 1);
+ TEST_f_i (ilogb, 1024, 10);
+ TEST_f_i (ilogb, -2000, 10);
+
+ /* XXX We have a problem here: the standard does not tell us whether
+ exceptions are allowed/required. ignore them for now. */
+
+ TEST_f_i (ilogb, 0.0, FP_ILOGB0, EXCEPTIONS_OK);
+ TEST_f_i (ilogb, nan_value, FP_ILOGBNAN, EXCEPTIONS_OK);
+ TEST_f_i (ilogb, plus_infty, INT_MAX, EXCEPTIONS_OK);
+ TEST_f_i (ilogb, minus_infty, INT_MAX, EXCEPTIONS_OK);
+
+ END (ilogb);
+}
+
+static void
+isfinite_test (void)
+{
+ START (isfinite);
+
+ TEST_f_b (isfinite, 0, 1);
+ TEST_f_b (isfinite, minus_zero, 1);
+ TEST_f_b (isfinite, 10, 1);
+ TEST_f_b (isfinite, plus_infty, 0);
+ TEST_f_b (isfinite, minus_infty, 0);
+ TEST_f_b (isfinite, nan_value, 0);
+
+ END (isfinite);
+}
+
+static void
+isnormal_test (void)
+{
+ START (isnormal);
+
+ TEST_f_b (isnormal, 0, 0);
+ TEST_f_b (isnormal, minus_zero, 0);
+ TEST_f_b (isnormal, 10, 1);
+ TEST_f_b (isnormal, plus_infty, 0);
+ TEST_f_b (isnormal, minus_infty, 0);
+ TEST_f_b (isnormal, nan_value, 0);
+
+ END (isnormal);
+}
+
+static void
+j0_test (void)
+{
+ errno = 0;
+#if 0
+ FLOAT s, c;
+ FUNC (sincos) (0, &s, &c);
+ if (errno == ENOSYS)
+ /* Required function not implemented. */
+ return;
+#endif
+ FUNC(j0) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (j0);
+
+ /* j0 is the Bessel function of the first kind of order 0 */
+ TEST_f_f (j0, nan_value, nan_value);
+ TEST_f_f (j0, plus_infty, 0);
+ TEST_f_f (j0, -1.0, 0.76519768655796655145L);
+ TEST_f_f (j0, 0.0, 1.0);
+ TEST_f_f (j0, 0.1L, 0.99750156206604003228L);
+ TEST_f_f (j0, 0.7L, 0.88120088860740528084L);
+ TEST_f_f (j0, 1.0, 0.76519768655796655145L);
+ TEST_f_f (j0, 1.5, 0.51182767173591812875L);
+ TEST_f_f (j0, 2.0, 0.22389077914123566805L);
+ TEST_f_f (j0, 8.0, 0.17165080713755390609L);
+ TEST_f_f (j0, 10.0, -0.24593576445134833520L);
+ TEST_f_f (j0, 4.0, -3.9714980986384737228659076845169804197562E-1L);
+ TEST_f_f (j0, -4.0, -3.9714980986384737228659076845169804197562E-1L);
+
+ END (j0);
+}
+
+
+static void
+j1_test (void)
+{
+ errno = 0;
+#if 0
+ FLOAT s, c;
+ FUNC (sincos) (0, &s, &c);
+ if (errno == ENOSYS)
+ /* Required function not implemented. */
+ return;
+#endif
+ FUNC(j1) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ /* j1 is the Bessel function of the first kind of order 1 */
+
+ START (j1);
+
+ TEST_f_f (j1, nan_value, nan_value);
+ TEST_f_f (j1, plus_infty, 0);
+
+ TEST_f_f (j1, -1.0, -0.44005058574493351596L);
+ TEST_f_f (j1, 0.0, 0.0);
+ TEST_f_f (j1, 0.1L, 0.049937526036241997556L);
+ TEST_f_f (j1, 0.7L, 0.32899574154005894785L);
+ TEST_f_f (j1, 1.0, 0.44005058574493351596L);
+ TEST_f_f (j1, 1.5, 0.55793650791009964199L);
+ TEST_f_f (j1, 2.0, 0.57672480775687338720L);
+ TEST_f_f (j1, 8.0, 0.23463634685391462438L);
+ TEST_f_f (j1, 10.0, 0.043472746168861436670L);
+
+ END (j1);
+}
+
+static void
+jn_test (void)
+{
+ errno = 0;
+#if 0
+ FLOAT s, c;
+ FUNC (sincos) (0, &s, &c);
+ if (errno == ENOSYS)
+ /* Required function not implemented. */
+ return;
+#endif
+ FUNC(jn) (1, 1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ /* jn is the Bessel function of the first kind of order n. */
+ START (jn);
+
+ /* jn (0, x) == j0 (x) */
+ TEST_ff_f (jn, 0, nan_value, nan_value);
+ TEST_ff_f (jn, 0, plus_infty, 0);
+ TEST_ff_f (jn, 0, -1.0, 0.76519768655796655145L);
+ TEST_ff_f (jn, 0, 0.0, 1.0);
+ TEST_ff_f (jn, 0, 0.1L, 0.99750156206604003228L);
+ TEST_ff_f (jn, 0, 0.7L, 0.88120088860740528084L);
+ TEST_ff_f (jn, 0, 1.0, 0.76519768655796655145L);
+ TEST_ff_f (jn, 0, 1.5, 0.51182767173591812875L);
+ TEST_ff_f (jn, 0, 2.0, 0.22389077914123566805L);
+ TEST_ff_f (jn, 0, 8.0, 0.17165080713755390609L);
+ TEST_ff_f (jn, 0, 10.0, -0.24593576445134833520L);
+
+ /* jn (1, x) == j1 (x) */
+ TEST_ff_f (jn, 1, nan_value, nan_value);
+ TEST_ff_f (jn, 1, plus_infty, 0);
+
+ TEST_ff_f (jn, 1, -1.0, -0.44005058574493351596L);
+ TEST_ff_f (jn, 1, 0.0, 0.0);
+ TEST_ff_f (jn, 1, 0.1L, 0.049937526036241997556L);
+ TEST_ff_f (jn, 1, 0.7L, 0.32899574154005894785L);
+ TEST_ff_f (jn, 1, 1.0, 0.44005058574493351596L);
+ TEST_ff_f (jn, 1, 1.5, 0.55793650791009964199L);
+ TEST_ff_f (jn, 1, 2.0, 0.57672480775687338720L);
+ TEST_ff_f (jn, 1, 8.0, 0.23463634685391462438L);
+ TEST_ff_f (jn, 1, 10.0, 0.043472746168861436670L);
+
+ /* jn (3, x) */
+ TEST_ff_f (jn, 3, nan_value, nan_value);
+ TEST_ff_f (jn, 3, plus_infty, 0);
+
+ TEST_ff_f (jn, 3, -1.0, -0.019563353982668405919L);
+ TEST_ff_f (jn, 3, 0.0, 0.0);
+ TEST_ff_f (jn, 3, 0.1L, 0.000020820315754756261429L);
+ TEST_ff_f (jn, 3, 0.7L, 0.0069296548267508408077L);
+ TEST_ff_f (jn, 3, 1.0, 0.019563353982668405919L);
+ TEST_ff_f (jn, 3, 2.0, 0.12894324947440205110L);
+ TEST_ff_f (jn, 3, 10.0, 0.058379379305186812343L);
+
+ /* jn (10, x) */
+ TEST_ff_f (jn, 10, nan_value, nan_value);
+ TEST_ff_f (jn, 10, plus_infty, 0);
+
+ TEST_ff_f (jn, 10, -1.0, 0.26306151236874532070e-9L);
+ TEST_ff_f (jn, 10, 0.0, 0.0);
+ TEST_ff_f (jn, 10, 0.1L, 0.26905328954342155795e-19L);
+ TEST_ff_f (jn, 10, 0.7L, 0.75175911502153953928e-11L);
+ TEST_ff_f (jn, 10, 1.0, 0.26306151236874532070e-9L);
+ TEST_ff_f (jn, 10, 2.0, 0.25153862827167367096e-6L);
+ TEST_ff_f (jn, 10, 10.0, 0.20748610663335885770L);
+
+ END (jn);
+}
+
+
+static void
+ldexp_test (void)
+{
+ TEST_ff_f (ldexp, 0, 0, 0);
+ TEST_ff_f (ldexp, minus_zero, 0, minus_zero);
+
+ TEST_ff_f (ldexp, plus_infty, 1, plus_infty);
+ TEST_ff_f (ldexp, minus_infty, 1, minus_infty);
+ TEST_ff_f (ldexp, nan_value, 1, nan_value);
+
+ TEST_ff_f (ldexp, 0.8L, 4, 12.8L);
+ TEST_ff_f (ldexp, -0.854375L, 5, -27.34L);
+
+ /* ldexp (x, 0) == x. */
+ TEST_ff_f (ldexp, 1.0L, 0L, 1.0L);
+}
+
+static void
+lgamma_test (void)
+{
+ errno = 0;
+ FUNC(lgamma) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+ feclearexcept (FE_ALL_EXCEPT);
+
+ START (lgamma);
+
+ TEST_f_f (lgamma, plus_infty, plus_infty);
+ TEST_f_f (lgamma, 0, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (lgamma, nan_value, nan_value);
+
+ /* lgamma (x) == +inf plus divide by zero exception for integer x <= 0. */
+ TEST_f_f (lgamma, -3, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (lgamma, minus_infty, plus_infty);
+
+ TEST_f_f1 (lgamma, 1, 0, 1);
+
+ TEST_f_f1 (lgamma, 3, M_LN2l, 1);
+
+ TEST_f_f1 (lgamma, 0.5, M_LOG_SQRT_PIl, 1);
+ TEST_f_f1 (lgamma, -0.5, M_LOG_2_SQRT_PIl, -1);
+ TEST_f_f1 (lgamma, 0.7L, 0.26086724653166651439L, 1);
+ TEST_f_f1 (lgamma, 1.2L, -0.853740900033158497197e-1L, 1);
+
+ END (lgamma);
+}
+
+#if 0
+static void
+lrint_test (void)
+{
+ /* XXX this test is incomplete. We need to have a way to specifiy
+ the rounding method and test the critical cases. So far, only
+ unproblematic numbers are tested. */
+
+ START (lrint);
+
+ TEST_f_l (lrint, 0.0, 0);
+ TEST_f_l (lrint, minus_zero, 0);
+ TEST_f_l (lrint, 0.2L, 0);
+ TEST_f_l (lrint, -0.2L, 0);
+
+ TEST_f_l (lrint, 1.4L, 1);
+ TEST_f_l (lrint, -1.4L, -1);
+
+ TEST_f_l (lrint, 8388600.3L, 8388600);
+ TEST_f_l (lrint, -8388600.3L, -8388600);
+
+ END (lrint);
+}
+
+static void
+llrint_test (void)
+{
+ /* XXX this test is incomplete. We need to have a way to specifiy
+ the rounding method and test the critical cases. So far, only
+ unproblematic numbers are tested. */
+
+ START (llrint);
+
+ TEST_f_L (llrint, 0.0, 0);
+ TEST_f_L (llrint, minus_zero, 0);
+ TEST_f_L (llrint, 0.2L, 0);
+ TEST_f_L (llrint, -0.2L, 0);
+
+ TEST_f_L (llrint, 1.4L, 1);
+ TEST_f_L (llrint, -1.4L, -1);
+
+ TEST_f_L (llrint, 8388600.3L, 8388600);
+ TEST_f_L (llrint, -8388600.3L, -8388600);
+
+ /* Test boundary conditions. */
+ /* 0x1FFFFF */
+ TEST_f_L (llrint, 2097151.0,2097151LL);
+ /* 0x800000 */
+ TEST_f_L (llrint, 8388608.0, 8388608LL);
+ /* 0x1000000 */
+ TEST_f_L (llrint, 16777216.0, 16777216LL);
+ /* 0x20000000000 */
+ TEST_f_L (llrint, 2199023255552.0, 2199023255552LL);
+ /* 0x40000000000 */
+ TEST_f_L (llrint, 4398046511104.0, 4398046511104LL);
+ /* 0x10000000000000 */
+ TEST_f_L (llrint, 4503599627370496.0, 4503599627370496LL);
+ /* 0x10000080000000 */
+ TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL);
+ /* 0x20000000000000 */
+ TEST_f_L (llrint, 9007199254740992.0, 9007199254740992LL);
+ /* 0x80000000000000 */
+ TEST_f_L (llrint, 36028797018963968.0, 36028797018963968LL);
+ /* 0x100000000000000 */
+ TEST_f_L (llrint, 72057594037927936.0, 72057594037927936LL);
+
+ END (llrint);
+}
+#endif
+
+static void
+log_test (void)
+{
+ errno = 0;
+ FUNC(log) (1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+ START (log);
+
+ TEST_f_f (log, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (log, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+ TEST_f_f (log, 1, 0);
+
+ TEST_f_f (log, -1, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (log, plus_infty, plus_infty);
+
+ TEST_f_f (log, M_El, 1);
+ TEST_f_f (log, 1.0 / M_El, -1);
+ TEST_f_f (log, 2, M_LN2l);
+ TEST_f_f (log, 10, M_LN10l);
+ TEST_f_f (log, 0.7L, -0.35667494393873237891263871124118447L);
+
+ END (log);
+}
+
+
+static void
+log10_test (void)
+{
+ errno = 0;
+ FUNC(log10) (1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (log10);
+
+ TEST_f_f (log10, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (log10, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+ TEST_f_f (log10, 1, 0);
+
+ /* log10 (x) == NaN plus invalid exception if x < 0. */
+ TEST_f_f (log10, -1, nan_value, INVALID_EXCEPTION);
+
+ TEST_f_f (log10, plus_infty, plus_infty);
+ TEST_f_f (log10, nan_value, nan_value);
+
+ TEST_f_f (log10, 0.1L, -1);
+ TEST_f_f (log10, 10.0, 1);
+ TEST_f_f (log10, 100.0, 2);
+ TEST_f_f (log10, 10000.0, 4);
+ TEST_f_f (log10, M_El, M_LOG10El);
+ TEST_f_f (log10, 0.7L, -0.15490195998574316929L);
+
+ END (log10);
+}
+
+
+static void
+log1p_test (void)
+{
+ errno = 0;
+ FUNC(log1p) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (log1p);
+
+ TEST_f_f (log1p, 0, 0);
+ TEST_f_f (log1p, minus_zero, minus_zero);
+
+ TEST_f_f (log1p, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (log1p, -2, nan_value, INVALID_EXCEPTION);
+
+ TEST_f_f (log1p, plus_infty, plus_infty);
+ TEST_f_f (log1p, nan_value, nan_value);
+
+ TEST_f_f (log1p, M_El - 1.0, 1);
+
+ TEST_f_f (log1p, -0.3L, -0.35667494393873237891263871124118447L);
+
+ END (log1p);
+}
+
+#if 0
+static void
+log2_test (void)
+{
+ errno = 0;
+ FUNC(log2) (1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (log2);
+
+ TEST_f_f (log2, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (log2, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+ TEST_f_f (log2, 1, 0);
+
+ TEST_f_f (log2, -1, nan_value, INVALID_EXCEPTION);
+
+ TEST_f_f (log2, plus_infty, plus_infty);
+ TEST_f_f (log2, nan_value, nan_value);
+
+ TEST_f_f (log2, M_El, M_LOG2El);
+ TEST_f_f (log2, 2.0, 1);
+ TEST_f_f (log2, 16.0, 4);
+ TEST_f_f (log2, 256.0, 8);
+ TEST_f_f (log2, 0.7L, -0.51457317282975824043L);
+
+ END (log2);
+}
+#endif
+
+
+static void
+logb_test (void)
+{
+ START (logb);
+
+ TEST_f_f (logb, plus_infty, plus_infty);
+ TEST_f_f (logb, minus_infty, plus_infty);
+
+ TEST_f_f (logb, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+ TEST_f_f (logb, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_f_f (logb, nan_value, nan_value);
+
+ TEST_f_f (logb, 1, 0);
+ TEST_f_f (logb, M_El, 1);
+ TEST_f_f (logb, 1024, 10);
+ TEST_f_f (logb, -2000, 10);
+
+ END (logb);
+}
+
+#if 0
+static void
+lround_test (void)
+{
+ START (lround);
+
+ TEST_f_l (lround, 0, 0);
+ TEST_f_l (lround, minus_zero, 0);
+ TEST_f_l (lround, 0.2L, 0.0);
+ TEST_f_l (lround, -0.2L, 0);
+ TEST_f_l (lround, 0.5, 1);
+ TEST_f_l (lround, -0.5, -1);
+ TEST_f_l (lround, 0.8L, 1);
+ TEST_f_l (lround, -0.8L, -1);
+ TEST_f_l (lround, 1.5, 2);
+ TEST_f_l (lround, -1.5, -2);
+ TEST_f_l (lround, 22514.5, 22515);
+ TEST_f_l (lround, -22514.5, -22515);
+#ifndef TEST_FLOAT
+ TEST_f_l (lround, 2097152.5, 2097153);
+ TEST_f_l (lround, -2097152.5, -2097153);
+#endif
+ END (lround);
+}
+
+
+static void
+llround_test (void)
+{
+ START (llround);
+
+ TEST_f_L (llround, 0, 0);
+ TEST_f_L (llround, minus_zero, 0);
+ TEST_f_L (llround, 0.2L, 0.0);
+ TEST_f_L (llround, -0.2L, 0);
+ TEST_f_L (llround, 0.5, 1);
+ TEST_f_L (llround, -0.5, -1);
+ TEST_f_L (llround, 0.8L, 1);
+ TEST_f_L (llround, -0.8L, -1);
+ TEST_f_L (llround, 1.5, 2);
+ TEST_f_L (llround, -1.5, -2);
+ TEST_f_L (llround, 22514.5, 22515);
+ TEST_f_L (llround, -22514.5, -22515);
+#ifndef TEST_FLOAT
+ TEST_f_L (llround, 2097152.5, 2097153);
+ TEST_f_L (llround, -2097152.5, -2097153);
+ TEST_f_L (llround, 34359738368.5, 34359738369ll);
+ TEST_f_L (llround, -34359738368.5, -34359738369ll);
+#endif
+
+ /* Test boundary conditions. */
+ /* 0x1FFFFF */
+ TEST_f_L (llround, 2097151.0, 2097151LL);
+ /* 0x800000 */
+ TEST_f_L (llround, 8388608.0, 8388608LL);
+ /* 0x1000000 */
+ TEST_f_L (llround, 16777216.0, 16777216LL);
+ /* 0x20000000000 */
+ TEST_f_L (llround, 2199023255552.0, 2199023255552LL);
+ /* 0x40000000000 */
+ TEST_f_L (llround, 4398046511104.0, 4398046511104LL);
+ /* 0x10000000000000 */
+ TEST_f_L (llround, 4503599627370496.0, 4503599627370496LL);
+ /* 0x10000080000000 */
+ TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL);
+ /* 0x20000000000000 */
+ TEST_f_L (llround, 9007199254740992.0, 9007199254740992LL);
+ /* 0x80000000000000 */
+ TEST_f_L (llround, 36028797018963968.0, 36028797018963968LL);
+ /* 0x100000000000000 */
+ TEST_f_L (llround, 72057594037927936.0, 72057594037927936LL);
+
+#ifndef TEST_FLOAT
+ /* 0x100000000 */
+ TEST_f_L (llround, 4294967295.5, 4294967296LL);
+ /* 0x200000000 */
+ TEST_f_L (llround, 8589934591.5, 8589934592LL);
+#endif
+
+ END (llround);
+}
+#endif
+
+static void
+modf_test (void)
+{
+ FLOAT x;
+
+ START (modf);
+
+ TEST_fF_f1 (modf, plus_infty, 0, plus_infty);
+ TEST_fF_f1 (modf, minus_infty, minus_zero, minus_infty);
+ TEST_fF_f1 (modf, nan_value, nan_value, nan_value);
+ TEST_fF_f1 (modf, 0, 0, 0);
+ TEST_fF_f1 (modf, 1.5, 0.5, 1);
+ TEST_fF_f1 (modf, 2.5, 0.5, 2);
+ TEST_fF_f1 (modf, -2.5, -0.5, -2);
+ TEST_fF_f1 (modf, 20, 0, 20);
+ TEST_fF_f1 (modf, 21, 0, 21);
+ TEST_fF_f1 (modf, 89.5, 0.5, 89);
+
+ END (modf);
+}
+
+
+#if 0
+static void
+nearbyint_test (void)
+{
+ START (nearbyint);
+
+ TEST_f_f (nearbyint, 0.0, 0.0);
+ TEST_f_f (nearbyint, minus_zero, minus_zero);
+ TEST_f_f (nearbyint, plus_infty, plus_infty);
+ TEST_f_f (nearbyint, minus_infty, minus_infty);
+ TEST_f_f (nearbyint, nan_value, nan_value);
+
+ /* Default rounding mode is round to nearest. */
+ TEST_f_f (nearbyint, 0.5, 0.0);
+ TEST_f_f (nearbyint, 1.5, 2.0);
+ TEST_f_f (nearbyint, -0.5, minus_zero);
+ TEST_f_f (nearbyint, -1.5, -2.0);
+
+ END (nearbyint);
+}
+
+static void
+nextafter_test (void)
+{
+
+ START (nextafter);
+
+ TEST_ff_f (nextafter, 0, 0, 0);
+ TEST_ff_f (nextafter, minus_zero, 0, 0);
+ TEST_ff_f (nextafter, 0, minus_zero, minus_zero);
+ TEST_ff_f (nextafter, minus_zero, minus_zero, minus_zero);
+
+ TEST_ff_f (nextafter, 9, 9, 9);
+ TEST_ff_f (nextafter, -9, -9, -9);
+ TEST_ff_f (nextafter, plus_infty, plus_infty, plus_infty);
+ TEST_ff_f (nextafter, minus_infty, minus_infty, minus_infty);
+
+ TEST_ff_f (nextafter, nan_value, 1.1L, nan_value);
+ TEST_ff_f (nextafter, 1.1L, nan_value, nan_value);
+ TEST_ff_f (nextafter, nan_value, nan_value, nan_value);
+
+ /* XXX We need the hexadecimal FP number representation here for further
+ tests. */
+
+ END (nextafter);
+}
+
+
+static void
+nexttoward_test (void)
+{
+ START (nexttoward);
+ TEST_ff_f (nexttoward, 0, 0, 0);
+ TEST_ff_f (nexttoward, minus_zero, 0, 0);
+ TEST_ff_f (nexttoward, 0, minus_zero, minus_zero);
+ TEST_ff_f (nexttoward, minus_zero, minus_zero, minus_zero);
+
+ TEST_ff_f (nexttoward, 9, 9, 9);
+ TEST_ff_f (nexttoward, -9, -9, -9);
+ TEST_ff_f (nexttoward, plus_infty, plus_infty, plus_infty);
+ TEST_ff_f (nexttoward, minus_infty, minus_infty, minus_infty);
+
+ TEST_ff_f (nexttoward, nan_value, 1.1L, nan_value);
+ TEST_ff_f (nexttoward, 1.1L, nan_value, nan_value);
+ TEST_ff_f (nexttoward, nan_value, nan_value, nan_value);
+
+ /* XXX We need the hexadecimal FP number representation here for further
+ tests. */
+
+ END (nexttoward);
+}
+#endif
+
+static void
+pow_test (void)
+{
+
+ errno = 0;
+ FUNC(pow) (0, 0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (pow);
+
+ TEST_ff_f (pow, 0, 0, 1);
+ TEST_ff_f (pow, 0, minus_zero, 1);
+ TEST_ff_f (pow, minus_zero, 0, 1);
+ TEST_ff_f (pow, minus_zero, minus_zero, 1);
+
+ TEST_ff_f (pow, 10, 0, 1);
+ TEST_ff_f (pow, 10, minus_zero, 1);
+ TEST_ff_f (pow, -10, 0, 1);
+ TEST_ff_f (pow, -10, minus_zero, 1);
+
+ TEST_ff_f (pow, nan_value, 0, 1);
+ TEST_ff_f (pow, nan_value, minus_zero, 1);
+
+
+#ifndef TEST_INLINE
+ TEST_ff_f (pow, 1.1L, plus_infty, plus_infty);
+ TEST_ff_f (pow, plus_infty, plus_infty, plus_infty);
+ TEST_ff_f (pow, -1.1L, plus_infty, plus_infty);
+ TEST_ff_f (pow, minus_infty, plus_infty, plus_infty);
+
+ TEST_ff_f (pow, 0.9L, plus_infty, 0);
+ TEST_ff_f (pow, 1e-7L, plus_infty, 0);
+ TEST_ff_f (pow, -0.9L, plus_infty, 0);
+ TEST_ff_f (pow, -1e-7L, plus_infty, 0);
+
+ TEST_ff_f (pow, 1.1L, minus_infty, 0);
+ TEST_ff_f (pow, plus_infty, minus_infty, 0);
+ TEST_ff_f (pow, -1.1L, minus_infty, 0);
+ TEST_ff_f (pow, minus_infty, minus_infty, 0);
+
+ TEST_ff_f (pow, 0.9L, minus_infty, plus_infty);
+ TEST_ff_f (pow, 1e-7L, minus_infty, plus_infty);
+ TEST_ff_f (pow, -0.9L, minus_infty, plus_infty);
+ TEST_ff_f (pow, -1e-7L, minus_infty, plus_infty);
+
+ TEST_ff_f (pow, plus_infty, 1e-7L, plus_infty);
+ TEST_ff_f (pow, plus_infty, 1, plus_infty);
+ TEST_ff_f (pow, plus_infty, 1e7L, plus_infty);
+
+ TEST_ff_f (pow, plus_infty, -1e-7L, 0);
+ TEST_ff_f (pow, plus_infty, -1, 0);
+ TEST_ff_f (pow, plus_infty, -1e7L, 0);
+
+ TEST_ff_f (pow, minus_infty, 1, minus_infty);
+ TEST_ff_f (pow, minus_infty, 11, minus_infty);
+ TEST_ff_f (pow, minus_infty, 1001, minus_infty);
+
+ TEST_ff_f (pow, minus_infty, 2, plus_infty);
+ TEST_ff_f (pow, minus_infty, 12, plus_infty);
+ TEST_ff_f (pow, minus_infty, 1002, plus_infty);
+ TEST_ff_f (pow, minus_infty, 0.1L, plus_infty);
+ TEST_ff_f (pow, minus_infty, 1.1L, plus_infty);
+ TEST_ff_f (pow, minus_infty, 11.1L, plus_infty);
+ TEST_ff_f (pow, minus_infty, 1001.1L, plus_infty);
+
+ TEST_ff_f (pow, minus_infty, -1, minus_zero);
+ TEST_ff_f (pow, minus_infty, -11, minus_zero);
+ TEST_ff_f (pow, minus_infty, -1001, minus_zero);
+
+ TEST_ff_f (pow, minus_infty, -2, 0);
+ TEST_ff_f (pow, minus_infty, -12, 0);
+ TEST_ff_f (pow, minus_infty, -1002, 0);
+ TEST_ff_f (pow, minus_infty, -0.1L, 0);
+ TEST_ff_f (pow, minus_infty, -1.1L, 0);
+ TEST_ff_f (pow, minus_infty, -11.1L, 0);
+ TEST_ff_f (pow, minus_infty, -1001.1L, 0);
+#endif
+
+ TEST_ff_f (pow, nan_value, nan_value, nan_value);
+ TEST_ff_f (pow, 0, nan_value, nan_value);
+ TEST_ff_f (pow, 1, nan_value, 1);
+ TEST_ff_f (pow, -1, nan_value, nan_value);
+ TEST_ff_f (pow, nan_value, 1, nan_value);
+ TEST_ff_f (pow, nan_value, -1, nan_value);
+
+ /* pow (x, NaN) == NaN. */
+ TEST_ff_f (pow, 3.0, nan_value, nan_value);
+
+ TEST_ff_f (pow, 1, plus_infty, 1);
+ TEST_ff_f (pow, -1, plus_infty, 1);
+ TEST_ff_f (pow, 1, minus_infty, 1);
+ TEST_ff_f (pow, -1, minus_infty, 1);
+
+ TEST_ff_f (pow, -0.1L, 1.1L, nan_value, INVALID_EXCEPTION);
+ TEST_ff_f (pow, -0.1L, -1.1L, nan_value, INVALID_EXCEPTION);
+ TEST_ff_f (pow, -10.1L, 1.1L, nan_value, INVALID_EXCEPTION);
+ TEST_ff_f (pow, -10.1L, -1.1L, nan_value, INVALID_EXCEPTION);
+
+ TEST_ff_f (pow, 0, -1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_ff_f (pow, 0, -11, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_ff_f (pow, minus_zero, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_ff_f (pow, minus_zero, -11, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+ TEST_ff_f (pow, 0, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_ff_f (pow, 0, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_ff_f (pow, minus_zero, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ TEST_ff_f (pow, minus_zero, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+
+
+ TEST_ff_f (pow, 0, 1, 0);
+ TEST_ff_f (pow, 0, 11, 0);
+
+ TEST_ff_f (pow, minus_zero, 1, minus_zero);
+ TEST_ff_f (pow, minus_zero, 11, minus_zero);
+
+
+ TEST_ff_f (pow, 0, 2, 0);
+ TEST_ff_f (pow, 0, 11.1L, 0);
+
+
+ TEST_ff_f (pow, minus_zero, 2, 0);
+ TEST_ff_f (pow, minus_zero, 11.1L, 0);
+
+#ifndef TEST_INLINE
+ /* pow (x, +inf) == +inf for |x| > 1. */
+ TEST_ff_f (pow, 1.5, plus_infty, plus_infty);
+
+ /* pow (x, +inf) == +0 for |x| < 1. */
+ TEST_ff_f (pow, 0.5, plus_infty, 0.0);
+
+ /* pow (x, -inf) == +0 for |x| > 1. */
+ TEST_ff_f (pow, 1.5, minus_infty, 0.0);
+
+ /* pow (x, -inf) == +inf for |x| < 1. */
+ TEST_ff_f (pow, 0.5, minus_infty, plus_infty);
+#endif
+
+ /* pow (+inf, y) == +inf for y > 0. */
+ TEST_ff_f (pow, plus_infty, 2, plus_infty);
+
+ /* pow (+inf, y) == +0 for y < 0. */
+ TEST_ff_f (pow, plus_infty, -1, 0.0);
+
+ /* pow (-inf, y) == -inf for y an odd integer > 0. */
+ TEST_ff_f (pow, minus_infty, 27, minus_infty);
+
+ /* pow (-inf, y) == +inf for y > 0 and not an odd integer. */
+ TEST_ff_f (pow, minus_infty, 28, plus_infty);
+
+ /* pow (-inf, y) == -0 for y an odd integer < 0. */
+ TEST_ff_f (pow, minus_infty, -3, minus_zero);
+ /* pow (-inf, y) == +0 for y < 0 and not an odd integer. */
+ TEST_ff_f (pow, minus_infty, -2.0, 0.0);
+
+ /* pow (+0, y) == +0 for y an odd integer > 0. */
+ TEST_ff_f (pow, 0.0, 27, 0.0);
+
+ /* pow (-0, y) == -0 for y an odd integer > 0. */
+ TEST_ff_f (pow, minus_zero, 27, minus_zero);
+
+ /* pow (+0, y) == +0 for y > 0 and not an odd integer. */
+ TEST_ff_f (pow, 0.0, 4, 0.0);
+
+ /* pow (-0, y) == +0 for y > 0 and not an odd integer. */
+ TEST_ff_f (pow, minus_zero, 4, 0.0);
+
+ TEST_ff_f (pow, 0.7L, 1.2L, 0.65180494056638638188L);
+
+#if defined TEST_DOUBLE || defined TEST_LDOUBLE
+ TEST_ff_f (pow, -7.49321e+133, -9.80818e+16, 0);
+#endif
+
+ END (pow);
+}
+
+static void
+remainder_test (void)
+{
+ errno = 0;
+ FUNC(remainder) (1.625, 1.0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (remainder);
+
+ TEST_ff_f (remainder, 1, 0, nan_value, INVALID_EXCEPTION);
+ TEST_ff_f (remainder, 1, minus_zero, nan_value, INVALID_EXCEPTION);
+ TEST_ff_f (remainder, plus_infty, 1, nan_value, INVALID_EXCEPTION);
+ TEST_ff_f (remainder, minus_infty, 1, nan_value, INVALID_EXCEPTION);
+ TEST_ff_f (remainder, nan_value, nan_value, nan_value);
+
+ TEST_ff_f (remainder, 1.625, 1.0, -0.375);
+ TEST_ff_f (remainder, -1.625, 1.0, 0.375);
+ TEST_ff_f (remainder, 1.625, -1.0, -0.375);
+ TEST_ff_f (remainder, -1.625, -1.0, 0.375);
+ TEST_ff_f (remainder, 5.0, 2.0, 1.0);
+ TEST_ff_f (remainder, 3.0, 2.0, -1.0);
+
+ END (remainder);
+}
+
+#if 0
+static void
+remquo_test (void)
+{
+ /* x is needed. */
+ int x;
+
+ errno = 0;
+ FUNC(remquo) (1.625, 1.0, &x);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (remquo);
+
+ TEST_ffI_f1 (remquo, 1, 0, nan_value, IGNORE, INVALID_EXCEPTION);
+ TEST_ffI_f1 (remquo, 1, minus_zero, nan_value, IGNORE, INVALID_EXCEPTION);
+ TEST_ffI_f1 (remquo, plus_infty, 1, nan_value, IGNORE, INVALID_EXCEPTION);
+ TEST_ffI_f1 (remquo, minus_infty, 1, nan_value, IGNORE, INVALID_EXCEPTION);
+ TEST_ffI_f1 (remquo, nan_value, nan_value, nan_value, IGNORE);
+
+ TEST_ffI_f1 (remquo, 1.625, 1.0, -0.375, 2);
+ TEST_ffI_f1 (remquo, -1.625, 1.0, 0.375, -2);
+ TEST_ffI_f1 (remquo, 1.625, -1.0, -0.375, -2);
+ TEST_ffI_f1 (remquo, -1.625, -1.0, 0.375, 2);
+
+ TEST_ffI_f1 (remquo, 5, 2, 1, 2);
+ TEST_ffI_f1 (remquo, 3, 2, -1, 2);
+
+ END (remquo);
+}
+#endif
+
+static void
+rint_test (void)
+{
+ START (rint);
+
+ TEST_f_f (rint, 0.0, 0.0);
+ TEST_f_f (rint, minus_zero, minus_zero);
+ TEST_f_f (rint, plus_infty, plus_infty);
+ TEST_f_f (rint, minus_infty, minus_infty);
+
+ /* Default rounding mode is round to even. */
+ TEST_f_f (rint, 0.5, 0.0);
+ TEST_f_f (rint, 1.5, 2.0);
+ TEST_f_f (rint, 2.5, 2.0);
+ TEST_f_f (rint, 3.5, 4.0);
+ TEST_f_f (rint, 4.5, 4.0);
+ TEST_f_f (rint, -0.5, -0.0);
+ TEST_f_f (rint, -1.5, -2.0);
+ TEST_f_f (rint, -2.5, -2.0);
+ TEST_f_f (rint, -3.5, -4.0);
+ TEST_f_f (rint, -4.5, -4.0);
+
+ END (rint);
+}
+
+#if 0
+static void
+round_test (void)
+{
+ START (round);
+
+ TEST_f_f (round, 0, 0);
+ TEST_f_f (round, minus_zero, minus_zero);
+ TEST_f_f (round, 0.2L, 0.0);
+ TEST_f_f (round, -0.2L, minus_zero);
+ TEST_f_f (round, 0.5, 1.0);
+ TEST_f_f (round, -0.5, -1.0);
+ TEST_f_f (round, 0.8L, 1.0);
+ TEST_f_f (round, -0.8L, -1.0);
+ TEST_f_f (round, 1.5, 2.0);
+ TEST_f_f (round, -1.5, -2.0);
+ TEST_f_f (round, 2097152.5, 2097153);
+ TEST_f_f (round, -2097152.5, -2097153);
+
+ END (round);
+}
+#endif
+
+
+static void
+scalb_test (void)
+{
+
+ START (scalb);
+
+ TEST_ff_f (scalb, 2.0, 0.5, nan_value, INVALID_EXCEPTION);
+ TEST_ff_f (scalb, 3.0, -2.5, nan_value, INVALID_EXCEPTION);
+
+ TEST_ff_f (scalb, 0, nan_value, nan_value);
+ TEST_ff_f (scalb, 1, nan_value, nan_value);
+
+ TEST_ff_f (scalb, 1, 0, 1);
+ TEST_ff_f (scalb, -1, 0, -1);
+
+ TEST_ff_f (scalb, 0, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_ff_f (scalb, minus_zero, plus_infty, nan_value, INVALID_EXCEPTION);
+
+ TEST_ff_f (scalb, 0, 2, 0);
+ TEST_ff_f (scalb, minus_zero, -4, minus_zero);
+ TEST_ff_f (scalb, 0, 0, 0);
+ TEST_ff_f (scalb, minus_zero, 0, minus_zero);
+ TEST_ff_f (scalb, 0, -1, 0);
+ TEST_ff_f (scalb, minus_zero, -10, minus_zero);
+ TEST_ff_f (scalb, 0, minus_infty, 0);
+ TEST_ff_f (scalb, minus_zero, minus_infty, minus_zero);
+
+ TEST_ff_f (scalb, plus_infty, -1, plus_infty);
+ TEST_ff_f (scalb, minus_infty, -10, minus_infty);
+ TEST_ff_f (scalb, plus_infty, 0, plus_infty);
+ TEST_ff_f (scalb, minus_infty, 0, minus_infty);
+ TEST_ff_f (scalb, plus_infty, 2, plus_infty);
+ TEST_ff_f (scalb, minus_infty, 100, minus_infty);
+
+ TEST_ff_f (scalb, 0.1L, minus_infty, 0.0);
+ TEST_ff_f (scalb, -0.1L, minus_infty, minus_zero);
+
+ TEST_ff_f (scalb, 1, plus_infty, plus_infty);
+ TEST_ff_f (scalb, -1, plus_infty, minus_infty);
+ TEST_ff_f (scalb, plus_infty, plus_infty, plus_infty);
+ TEST_ff_f (scalb, minus_infty, plus_infty, minus_infty);
+
+ TEST_ff_f (scalb, plus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_ff_f (scalb, minus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
+
+ TEST_ff_f (scalb, nan_value, 1, nan_value);
+ TEST_ff_f (scalb, 1, nan_value, nan_value);
+ TEST_ff_f (scalb, nan_value, 0, nan_value);
+ TEST_ff_f (scalb, 0, nan_value, nan_value);
+ TEST_ff_f (scalb, nan_value, plus_infty, nan_value);
+ TEST_ff_f (scalb, plus_infty, nan_value, nan_value);
+ TEST_ff_f (scalb, nan_value, nan_value, nan_value);
+
+ TEST_ff_f (scalb, 0.8L, 4, 12.8L);
+ TEST_ff_f (scalb, -0.854375L, 5, -27.34L);
+
+ END (scalb);
+}
+
+
+static void
+scalbn_test (void)
+{
+
+ START (scalbn);
+
+ TEST_fi_f (scalbn, 0, 0, 0);
+ TEST_fi_f (scalbn, minus_zero, 0, minus_zero);
+
+ TEST_fi_f (scalbn, plus_infty, 1, plus_infty);
+ TEST_fi_f (scalbn, minus_infty, 1, minus_infty);
+ TEST_fi_f (scalbn, nan_value, 1, nan_value);
+
+ TEST_fi_f (scalbn, 0.8L, 4, 12.8L);
+ TEST_fi_f (scalbn, -0.854375L, 5, -27.34L);
+
+ TEST_fi_f (scalbn, 1, 0L, 1);
+
+ END (scalbn);
+}
+
+#if 0
+static void
+scalbln_test (void)
+{
+
+ START (scalbln);
+
+ TEST_fl_f (scalbln, 0, 0, 0);
+ TEST_fl_f (scalbln, minus_zero, 0, minus_zero);
+
+ TEST_fl_f (scalbln, plus_infty, 1, plus_infty);
+ TEST_fl_f (scalbln, minus_infty, 1, minus_infty);
+ TEST_fl_f (scalbln, nan_value, 1, nan_value);
+
+ TEST_fl_f (scalbln, 0.8L, 4, 12.8L);
+ TEST_fl_f (scalbln, -0.854375L, 5, -27.34L);
+
+ TEST_fl_f (scalbln, 1, 0L, 1);
+
+ END (scalbn);
+}
+#endif
+
+static void
+signbit_test (void)
+{
+
+ START (signbit);
+
+ TEST_f_b (signbit, 0, 0);
+ TEST_f_b (signbit, minus_zero, 1);
+ TEST_f_b (signbit, plus_infty, 0);
+ TEST_f_b (signbit, minus_infty, 1);
+
+ /* signbit (x) != 0 for x < 0. */
+ TEST_f_b (signbit, -1, 1);
+ /* signbit (x) == 0 for x >= 0. */
+ TEST_f_b (signbit, 1, 0);
+
+ END (signbit);
+}
+
+static void
+sin_test (void)
+{
+ errno = 0;
+ FUNC(sin) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (sin);
+
+ TEST_f_f (sin, 0, 0);
+ TEST_f_f (sin, minus_zero, minus_zero);
+ TEST_f_f (sin, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (sin, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (sin, nan_value, nan_value);
+
+ TEST_f_f (sin, M_PI_6l, 0.5);
+ TEST_f_f (sin, -M_PI_6l, -0.5);
+ TEST_f_f (sin, M_PI_2l, 1);
+ TEST_f_f (sin, -M_PI_2l, -1);
+ TEST_f_f (sin, 0.7L, 0.64421768723769105367261435139872014L);
+
+ END (sin);
+
+}
+
+#if 0
+static void
+sincos_test (void)
+{
+ FLOAT sin_res, cos_res;
+
+ errno = 0;
+ FUNC(sincos) (0, &sin_res, &cos_res);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (sincos);
+
+ /* sincos is treated differently because it returns void. */
+ TEST_extra (sincos, 0, 0, 1);
+
+ TEST_extra (sincos, minus_zero, minus_zero, 1);
+ TEST_extra (sincos, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_extra (sincos, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
+ TEST_extra (sincos, nan_value, nan_value, nan_value);
+
+ TEST_extra (sincos, M_PI_2l, 1, 0);
+ TEST_extra (sincos, M_PI_6l, 0.5, 0.86602540378443864676372317075293616L);
+ TEST_extra (sincos, M_PI_6l*2.0, 0.86602540378443864676372317075293616L, 0.5);
+ TEST_extra (sincos, 0.7L, 0.64421768723769105367261435139872014L, 0.76484218728448842625585999019186495L);
+
+ END (sincos);
+}
+#endif
+
+static void
+sinh_test (void)
+{
+ errno = 0;
+ FUNC(sinh) (0.7L);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (sinh);
+ TEST_f_f (sinh, 0, 0);
+ TEST_f_f (sinh, minus_zero, minus_zero);
+
+#ifndef TEST_INLINE
+ TEST_f_f (sinh, plus_infty, plus_infty);
+ TEST_f_f (sinh, minus_infty, minus_infty);
+#endif
+ TEST_f_f (sinh, nan_value, nan_value);
+
+ TEST_f_f (sinh, 0.7L, 0.75858370183953350346L);
+ TEST_f_f (sinh, 0x8p-32L, 1.86264514923095703232705808926175479e-9L);
+
+ END (sinh);
+}
+
+static void
+sqrt_test (void)
+{
+ errno = 0;
+ FUNC(sqrt) (1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (sqrt);
+
+ TEST_f_f (sqrt, 0, 0);
+ TEST_f_f (sqrt, nan_value, nan_value);
+ TEST_f_f (sqrt, plus_infty, plus_infty);
+
+ TEST_f_f (sqrt, minus_zero, minus_zero);
+
+ /* sqrt (x) == NaN plus invalid exception for x < 0. */
+ TEST_f_f (sqrt, -1, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (sqrt, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (sqrt, nan_value, nan_value);
+
+ TEST_f_f (sqrt, 2209, 47);
+ TEST_f_f (sqrt, 4, 2);
+ TEST_f_f (sqrt, 2, M_SQRT2l);
+ TEST_f_f (sqrt, 0.25, 0.5);
+ TEST_f_f (sqrt, 6642.25, 81.5);
+ TEST_f_f (sqrt, 15239.9025L, 123.45L);
+ TEST_f_f (sqrt, 0.7L, 0.83666002653407554797817202578518747L);
+
+ END (sqrt);
+}
+
+static void
+tan_test (void)
+{
+ errno = 0;
+ FUNC(tan) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (tan);
+
+ TEST_f_f (tan, 0, 0);
+ TEST_f_f (tan, minus_zero, minus_zero);
+ TEST_f_f (tan, plus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (tan, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (tan, nan_value, nan_value);
+
+ TEST_f_f (tan, M_PI_4l, 1);
+ TEST_f_f (tan, 0.7L, 0.84228838046307944812813500221293775L);
+
+ END (tan);
+}
+
+static void
+tanh_test (void)
+{
+ errno = 0;
+ FUNC(tanh) (0.7L);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (tanh);
+
+ TEST_f_f (tanh, 0, 0);
+ TEST_f_f (tanh, minus_zero, minus_zero);
+
+#ifndef TEST_INLINE
+ TEST_f_f (tanh, plus_infty, 1);
+ TEST_f_f (tanh, minus_infty, -1);
+#endif
+ TEST_f_f (tanh, nan_value, nan_value);
+
+ TEST_f_f (tanh, 0.7L, 0.60436777711716349631L);
+ TEST_f_f (tanh, -0.7L, -0.60436777711716349631L);
+
+ TEST_f_f (tanh, 1.0L, 0.7615941559557648881194582826047935904L);
+ TEST_f_f (tanh, -1.0L, -0.7615941559557648881194582826047935904L);
+
+ /* 2^-57 */
+ TEST_f_f (tanh, 6.938893903907228377647697925567626953125e-18L,6.938893903907228377647697925567626953125e-18L);
+
+ END (tanh);
+}
+
+#if 0
+static void
+tgamma_test (void)
+{
+ errno = 0;
+ FUNC(tgamma) (1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+ feclearexcept (FE_ALL_EXCEPT);
+
+ START (tgamma);
+
+ TEST_f_f (tgamma, plus_infty, plus_infty);
+ TEST_f_f (tgamma, 0, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (tgamma, minus_zero, nan_value, INVALID_EXCEPTION);
+ /* tgamma (x) == NaN plus invalid exception for integer x <= 0. */
+ TEST_f_f (tgamma, -2, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (tgamma, minus_infty, nan_value, INVALID_EXCEPTION);
+ TEST_f_f (tgamma, nan_value, nan_value);
+
+ TEST_f_f (tgamma, 0.5, M_SQRT_PIl);
+ TEST_f_f (tgamma, -0.5, -M_2_SQRT_PIl);
+
+ TEST_f_f (tgamma, 1, 1);
+ TEST_f_f (tgamma, 4, 6);
+
+ TEST_f_f (tgamma, 0.7L, 1.29805533264755778568L);
+ TEST_f_f (tgamma, 1.2L, 0.91816874239976061064L);
+
+ END (tgamma);
+}
+#endif
+
+#if 0
+static void
+trunc_test (void)
+{
+ START (trunc);
+
+ TEST_f_f (trunc, plus_infty, plus_infty);
+ TEST_f_f (trunc, minus_infty, minus_infty);
+ TEST_f_f (trunc, nan_value, nan_value);
+
+ TEST_f_f (trunc, 0, 0);
+ TEST_f_f (trunc, minus_zero, minus_zero);
+ TEST_f_f (trunc, 0.625, 0);
+ TEST_f_f (trunc, -0.625, minus_zero);
+ TEST_f_f (trunc, 1, 1);
+ TEST_f_f (trunc, -1, -1);
+ TEST_f_f (trunc, 1.625, 1);
+ TEST_f_f (trunc, -1.625, -1);
+
+ TEST_f_f (trunc, 1048580.625L, 1048580L);
+ TEST_f_f (trunc, -1048580.625L, -1048580L);
+
+ TEST_f_f (trunc, 8388610.125L, 8388610.0L);
+ TEST_f_f (trunc, -8388610.125L, -8388610.0L);
+
+ TEST_f_f (trunc, 4294967296.625L, 4294967296.0L);
+ TEST_f_f (trunc, -4294967296.625L, -4294967296.0L);
+
+
+ END (trunc);
+}
+#endif
+
+static void
+y0_test (void)
+{
+ errno = 0;
+#if 0
+ FLOAT s, c;
+ FUNC (sincos) (0, &s, &c);
+ if (errno == ENOSYS)
+ /* Required function not implemented. */
+ return;
+#endif
+ FUNC(y0) (1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ /* y0 is the Bessel function of the second kind of order 0 */
+ START (y0);
+
+ TEST_f_f (y0, -1.0, minus_infty);
+ TEST_f_f (y0, 0.0, minus_infty);
+ TEST_f_f (y0, nan_value, nan_value);
+ TEST_f_f (y0, plus_infty, 0);
+
+ TEST_f_f (y0, 0.1L, -1.5342386513503668441L);
+ TEST_f_f (y0, 0.7L, -0.19066492933739506743L);
+ TEST_f_f (y0, 1.0, 0.088256964215676957983L);
+ TEST_f_f (y0, 1.5, 0.38244892379775884396L);
+ TEST_f_f (y0, 2.0, 0.51037567264974511960L);
+ TEST_f_f (y0, 8.0, 0.22352148938756622053L);
+ TEST_f_f (y0, 10.0, 0.055671167283599391424L);
+
+ END (y0);
+}
+
+
+static void
+y1_test (void)
+{
+ errno = 0;
+#if 0
+ FLOAT s, c;
+ FUNC (sincos) (0, &s, &c);
+ if (errno == ENOSYS)
+ /* Required function not implemented. */
+ return;
+#endif
+ FUNC(y1) (1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ /* y1 is the Bessel function of the second kind of order 1 */
+ START (y1);
+
+ TEST_f_f (y1, -1.0, minus_infty);
+ TEST_f_f (y1, 0.0, minus_infty);
+ TEST_f_f (y1, plus_infty, 0);
+ TEST_f_f (y1, nan_value, nan_value);
+
+ TEST_f_f (y1, 0.1L, -6.4589510947020269877L);
+ TEST_f_f (y1, 0.7L, -1.1032498719076333697L);
+ TEST_f_f (y1, 1.0, -0.78121282130028871655L);
+ TEST_f_f (y1, 1.5, -0.41230862697391129595L);
+ TEST_f_f (y1, 2.0, -0.10703243154093754689L);
+ TEST_f_f (y1, 8.0, -0.15806046173124749426L);
+ TEST_f_f (y1, 10.0, 0.24901542420695388392L);
+
+ END (y1);
+}
+
+static void
+yn_test (void)
+{
+ errno = 0;
+#if 0
+ FLOAT s, c;
+ FUNC (sincos) (0, &s, &c);
+ if (errno == ENOSYS)
+ /* Required function not implemented. */
+ return;
+#endif
+ FUNC(yn) (1, 1);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ /* yn is the Bessel function of the second kind of order n */
+ START (yn);
+
+ /* yn (0, x) == y0 (x) */
+ TEST_ff_f (yn, 0, -1.0, minus_infty);
+ TEST_ff_f (yn, 0, 0.0, minus_infty);
+ TEST_ff_f (yn, 0, nan_value, nan_value);
+ TEST_ff_f (yn, 0, plus_infty, 0);
+
+ TEST_ff_f (yn, 0, 0.1L, -1.5342386513503668441L);
+ TEST_ff_f (yn, 0, 0.7L, -0.19066492933739506743L);
+ TEST_ff_f (yn, 0, 1.0, 0.088256964215676957983L);
+ TEST_ff_f (yn, 0, 1.5, 0.38244892379775884396L);
+ TEST_ff_f (yn, 0, 2.0, 0.51037567264974511960L);
+ TEST_ff_f (yn, 0, 8.0, 0.22352148938756622053L);
+ TEST_ff_f (yn, 0, 10.0, 0.055671167283599391424L);
+
+ /* yn (1, x) == y1 (x) */
+ TEST_ff_f (yn, 1, -1.0, minus_infty);
+ TEST_ff_f (yn, 1, 0.0, minus_infty);
+ TEST_ff_f (yn, 1, plus_infty, 0);
+ TEST_ff_f (yn, 1, nan_value, nan_value);
+
+ TEST_ff_f (yn, 1, 0.1L, -6.4589510947020269877L);
+ TEST_ff_f (yn, 1, 0.7L, -1.1032498719076333697L);
+ TEST_ff_f (yn, 1, 1.0, -0.78121282130028871655L);
+ TEST_ff_f (yn, 1, 1.5, -0.41230862697391129595L);
+ TEST_ff_f (yn, 1, 2.0, -0.10703243154093754689L);
+ TEST_ff_f (yn, 1, 8.0, -0.15806046173124749426L);
+ TEST_ff_f (yn, 1, 10.0, 0.24901542420695388392L);
+
+ /* yn (3, x) */
+ TEST_ff_f (yn, 3, plus_infty, 0);
+ TEST_ff_f (yn, 3, nan_value, nan_value);
+
+ TEST_ff_f (yn, 3, 0.1L, -5099.3323786129048894L);
+ TEST_ff_f (yn, 3, 0.7L, -15.819479052819633505L);
+ TEST_ff_f (yn, 3, 1.0, -5.8215176059647288478L);
+ TEST_ff_f (yn, 3, 2.0, -1.1277837768404277861L);
+ TEST_ff_f (yn, 3, 10.0, -0.25136265718383732978L);
+
+ /* yn (10, x) */
+ TEST_ff_f (yn, 10, plus_infty, 0);
+ TEST_ff_f (yn, 10, nan_value, nan_value);
+
+ TEST_ff_f (yn, 10, 0.1L, -0.11831335132045197885e19L);
+ TEST_ff_f (yn, 10, 0.7L, -0.42447194260703866924e10L);
+ TEST_ff_f (yn, 10, 1.0, -0.12161801427868918929e9L);
+ TEST_ff_f (yn, 10, 2.0, -129184.54220803928264L);
+ TEST_ff_f (yn, 10, 10.0, -0.35981415218340272205L);
+
+ END (yn);
+
+}
+
+
+
+static void
+initialize (void)
+{
+ fpstack_test ("start *init*");
+ plus_zero = 0.0;
+ nan_value = plus_zero / plus_zero; /* Suppress GCC warning */
+
+ minus_zero = FUNC(copysign) (0.0, -1.0);
+ plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF,
+ HUGE_VALL, HUGE_VAL, HUGE_VALF);
+ minus_infty = CHOOSE (-HUGE_VALL, -HUGE_VAL, -HUGE_VALF,
+ -HUGE_VALL, -HUGE_VAL, -HUGE_VALF);
+
+ (void) &plus_zero;
+ (void) &nan_value;
+ (void) &minus_zero;
+ (void) &plus_infty;
+ (void) &minus_infty;
+
+ /* Clear all exceptions. From now on we must not get random exceptions. */
+ feclearexcept (FE_ALL_EXCEPT);
+
+ /* Test to make sure we start correctly. */
+ fpstack_test ("end *init*");
+}
+
+#if 0
+/* function to check our ulp calculation. */
+void
+check_ulp (void)
+{
+ int i;
+
+ FLOAT u, diff, ulp;
+ /* This gives one ulp. */
+ u = FUNC(nextafter) (10, 20);
+ check_equal (10.0, u, 1, &diff, &ulp);
+ printf ("One ulp: % .4" PRINTF_NEXPR "\n", ulp);
+
+ /* This gives one more ulp. */
+ u = FUNC(nextafter) (u, 20);
+ check_equal (10.0, u, 2, &diff, &ulp);
+ printf ("two ulp: % .4" PRINTF_NEXPR "\n", ulp);
+
+ /* And now calculate 100 ulp. */
+ for (i = 2; i < 100; i++)
+ u = FUNC(nextafter) (u, 20);
+ check_equal (10.0, u, 100, &diff, &ulp);
+ printf ("100 ulp: % .4" PRINTF_NEXPR "\n", ulp);
+}
+#endif
+
+int
+main (int argc, char **argv)
+{
+
+ int key, remaining;
+
+ verbose = 1;
+ output_ulps = 0;
+ output_max_error = 1;
+ output_points = 1;
+ /* XXX set to 0 for releases. */
+ ignore_max_ulp = 0;
+
+ /* Parse and process arguments. */
+ while ((key = getopt(argc, argv, "fi:puv")) > 0) {
+ switch (key)
+ {
+ case 'f':
+ output_max_error = 0;
+ break;
+ case 'i':
+ if (strcmp (optarg, "yes") == 0)
+ ignore_max_ulp = 1;
+ else if (strcmp (optarg, "no") == 0)
+ ignore_max_ulp = 0;
+ break;
+ case 'p':
+ output_points = 0;
+ break;
+ case 'u':
+ output_ulps = 1;
+ break;
+ case 'v':
+ verbose = 3;
+ break;
+ default:
+ fprintf (stderr, "Unknown argument: %c", key);
+ exit (EXIT_FAILURE);
+ }
+ }
+
+ if (optind != argc)
+ {
+ fprintf (stderr, "wrong number of arguments");
+ exit (EXIT_FAILURE);
+ }
+
+ if (output_ulps)
+ {
+ ulps_file = fopen ("ULPs", "a");
+ if (ulps_file == NULL)
+ {
+ perror ("can't open file `ULPs' for writing: ");
+ exit (1);
+ }
+ }
+
+
+ initialize ();
+ printf (TEST_MSG);
+
+#if 0
+ check_ulp ();
+#endif
+
+ /* Keep the tests a wee bit ordered (according to ISO C99). */
+ /* Classification macros: */
+ fpclassify_test ();
+ isfinite_test ();
+ isnormal_test ();
+ signbit_test ();
+
+ /* Trigonometric functions: */
+ acos_test ();
+ asin_test ();
+ atan_test ();
+ atan2_test ();
+ cos_test ();
+ sin_test ();
+#if 0
+ sincos_test ();
+#endif
+ tan_test ();
+
+ /* Hyperbolic functions: */
+ acosh_test ();
+ asinh_test ();
+ atanh_test ();
+ cosh_test ();
+ sinh_test ();
+ tanh_test ();
+
+ /* Exponential and logarithmic functions: */
+ exp_test ();
+#if 0
+ exp10_test ();
+ exp2_test ();
+#endif
+ expm1_test ();
+ frexp_test ();
+ ldexp_test ();
+ log_test ();
+ log10_test ();
+ log1p_test ();
+#if 0
+ log2_test ();
+#endif
+ logb_test ();
+ modf_test ();
+ ilogb_test ();
+ scalb_test ();
+ scalbn_test ();
+#if 0
+ scalbln_test ();
+#endif
+
+ /* Power and absolute value functions: */
+ cbrt_test ();
+ fabs_test ();
+ hypot_test ();
+ pow_test ();
+ sqrt_test ();
+
+ /* Error and gamma functions: */
+ erf_test ();
+ erfc_test ();
+ gamma_test ();
+ lgamma_test ();
+#if 0
+ tgamma_test ();
+#endif
+
+ /* Nearest integer functions: */
+ ceil_test ();
+ floor_test ();
+#if 0
+ nearbyint_test ();
+#endif
+ rint_test ();
+#if 0
+ lrint_test ();
+ llrint_test ();
+ round_test ();
+ lround_test ();
+ llround_test ();
+ trunc_test ();
+#endif
+
+ /* Remainder functions: */
+ fmod_test ();
+ remainder_test ();
+#if 0
+ remquo_test ();
+#endif
+
+ /* Manipulation functions: */
+ copysign_test ();
+#if 0
+ nextafter_test ();
+ nexttoward_test ();
+
+ /* maximum, minimum and positive difference functions */
+ fdim_test ();
+ fmax_test ();
+ fmin_test ();
+
+ /* Multiply and add: */
+ fma_test ();
+
+ /* Complex functions: */
+ cabs_test ();
+ cacos_test ();
+ cacosh_test ();
+ carg_test ();
+ casin_test ();
+ casinh_test ();
+ catan_test ();
+ catanh_test ();
+ ccos_test ();
+ ccosh_test ();
+ cexp_test ();
+ cimag_test ();
+ clog10_test ();
+ clog_test ();
+ conj_test ();
+ cpow_test ();
+ cproj_test ();
+ creal_test ();
+ csin_test ();
+ csinh_test ();
+ csqrt_test ();
+ ctan_test ();
+ ctanh_test ();
+#endif
+
+ /* Bessel functions: */
+#if 0
+ j0_test ();
+ j1_test ();
+ jn_test ();
+ y0_test ();
+ y1_test ();
+ yn_test ();
+#endif
+
+ if (output_ulps)
+ fclose (ulps_file);
+
+ printf ("\nTest suite completed:\n");
+ printf (" %d test cases plus %d tests for exception flags executed.\n",
+ noTests, noExcTests);
+ if (noXFails)
+ printf (" %d expected failures occurred.\n", noXFails);
+ if (noXPasses)
+ printf (" %d unexpected passes occurred.\n", noXPasses);
+ if (noErrors)
+ {
+ printf (" %d errors occurred.\n", noErrors);
+ return 1;
+ }
+ printf (" All tests passed successfully.\n");
+
+ return 0;
+}
+
+/*
+ * Local Variables:
+ * mode:c
+ * End:
+ */
Index: math/test-ifloat.c
===================================================================
--- math/test-ifloat.c (nonexistent)
+++ math/test-ifloat.c (revision 1765)
@@ -0,0 +1,35 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger , 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define FUNC(function) function ## f
+#define FLOAT float
+#define TEST_MSG "testing float (inline functions)\n"
+#define MATHCONST(x) x
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinefloat
+#define PRINTF_EXPR "e"
+#define PRINTF_XEXPR "a"
+#define PRINTF_NEXPR "f"
+#define TEST_FLOAT 1
+#define TEST_INLINE 1
+
+#ifdef __NO_MATH_INLINES
+# undef __NO_MATH_INLINES
+#endif
+
+#include "libm-test.c"
Index: math/Makefile
===================================================================
--- math/Makefile (nonexistent)
+++ math/Makefile (revision 1765)
@@ -0,0 +1,105 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+CFLAGS+=-D_GNU_SOURCE -DNO_LONG_DOUBLE
+EXTRA_LIBS=-lm
+PERL=/usr/bin/perl
+
+TARGETS:=
+libm-tests=libm-test.c
+libm-tests+= test-double test-idouble
+libm-tests+= diff
+#libm-tests+= test-float test-ifloat
+#libm-tests+= test-ldouble test-ildouble
+libm-tests.o = $(addsuffix .o,$(libm-tests))
+
+libm-tests-generated = libm-test-ulps.h libm-test.c
+generated += $(libm-tests-generated) libm-test.stmp
+TARGETS += $(libm-tests) #$(libm-tests-generated)
+
+all: $(TARGETS)
+
+test-double: test-double.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ -./$@
+test-idouble: test-idouble.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ -./$@
+test-float: test-float.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ -./$@
+test-ifloat: test-ifloat.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ -./$@
+test-ldouble: test-ldouble.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ -./$@
+test-ildouble: test-ildoubl.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ -./$@
+
+rint: rint.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ > $@.out 2>&1
+ -@ echo " "
+
+rint_glibc: rint.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs glibc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ > $@.out 2>&1
+ -@ echo " "
+
+diff: rint_glibc rint
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u rint_glibc.out rint.out
+ -@ echo " "
+
+test-float.o: libm-test.c
+test-ifloat.o: libm-test.c
+test-double.o: libm-test.c
+test-idouble.o: libm-test.c
+test-ldouble.o: libm-test.c
+test-ildoubl.o: libm-test.c
+
+ulps-file = $(firstword $(wildcard $(config-sysdirs:%=$(..)%/libm-test-ulps)))
+
+libm-test.c: $(ulps-file) libm-test.inc gen-libm-test.pl
+ $(PERL) ./gen-libm-test.pl -u $< ./libm-test.inc -o "." 2>&1 > /dev/null
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS) $(generated) rint_glibc.out rint.out
+
+
Index: math/rint.c
===================================================================
--- math/rint.c (nonexistent)
+++ math/rint.c (revision 1765)
@@ -0,0 +1,11 @@
+#include
+#include
+#include
+
+int main(void) {
+ double d1, d2;
+ d1 = 0.6; d2 = rint(d1);
+ printf("d1 = %f, d2 = %f\n", d1, d2);
+ return 0;
+}
+
Index: math
===================================================================
--- math (nonexistent)
+++ math (revision 1765)
math
Property changes :
Added: svn:ignore
## -0,0 +1,12 ##
+libm-test-ulps.h
+libm-test.c
+test-double
+test-idouble
+test-float
+test-ifloat
+test-ldouble
+test-ildouble
+rint
+rint.out
+rint_glibc
+rint_glibc.out
Index: mmap/mmap.c
===================================================================
--- mmap/mmap.c (nonexistent)
+++ mmap/mmap.c (revision 1765)
@@ -0,0 +1,27 @@
+
+/* The mmap test is useful, since syscalls with 6 arguments
+ * (as mmap) are done differently on various architectures.
+ */
+
+#include
+#include
+#include
+#include
+
+
+int main(int argc, char **argv)
+{
+ void *ptr;
+
+
+ ptr = mmap(NULL, 4096, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+
+ if(ptr==MAP_FAILED){
+ perror("mmap");
+ exit(1);
+ }
+ printf("mmap returned %p\n",ptr);
+ exit(0);
+}
+
Index: mmap/Makefile
===================================================================
--- mmap/Makefile (nonexistent)
+++ mmap/Makefile (revision 1765)
@@ -0,0 +1,40 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+TARGETS=mmap
+all: $(TARGETS)
+
+mmap: mmap.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
+
Index: mmap
===================================================================
--- mmap (nonexistent)
+++ mmap (revision 1765)
mmap
Property changes :
Added: svn:ignore
## -0,0 +1,2 ##
+mmap
+mmap.o
Index: misc/sem.c
===================================================================
--- misc/sem.c (nonexistent)
+++ misc/sem.c (revision 1765)
@@ -0,0 +1,43 @@
+#include
+#include
+#include
+#include
+
+int main(void)
+{
+ int k, r;
+ union semun {
+ int val;
+ struct semid_ds *buf;
+ unsigned short int *array;
+ struct seminfo *__buf;
+ } sd;
+ struct semid_ds sd_buf;
+
+ k = semget(IPC_PRIVATE, 10, IPC_CREAT | 0666 );
+ printf("%d\n", k);
+
+ if (k < 0) {
+ printf("semget failed: %m\n");
+ return 1;
+ }
+
+ sd.buf = &sd_buf;
+ r = semctl(k, 0, IPC_STAT, sd);
+ printf("%d\n", r);
+
+ if (r < 0) {
+ printf("semctl IPC_STAT failed: %m\n");
+ return 1;
+ }
+
+ printf("sem_nsems = %lu\n", sd_buf.sem_nsems);
+ if (sd_buf.sem_nsems != 10) {
+ printf("failed: incorrect sem_nsems!\n");
+ return 1;
+ }
+
+ printf("succeeded\n");
+
+ return 0;
+}
Index: misc/dirent.c
===================================================================
--- misc/dirent.c (nonexistent)
+++ misc/dirent.c (revision 1765)
@@ -0,0 +1,25 @@
+#include
+#include
+#include
+#include
+
+int main(int argc, char **argv)
+{
+
+ DIR *dirh;
+ struct dirent *dirp;
+ static char mydir[20] = "/tmp";
+
+ if ((dirh = opendir(mydir)) == NULL) {
+ perror("opendir");
+ return 1;
+ }
+
+ for (dirp = readdir(dirh); dirp != NULL; dirp = readdir(dirh)) {
+ printf("Got dir entry: %s\n",dirp->d_name);
+ }
+
+ closedir(dirh);
+ return 0;
+}
+
Index: misc/outb.c
===================================================================
--- misc/outb.c (nonexistent)
+++ misc/outb.c (revision 1765)
@@ -0,0 +1,9 @@
+#include
+
+int main(void)
+{
+ ioperm(0x340,0x342,1);
+ outb(0x340,0x0);
+ exit(0);
+}
+
Index: misc/fdopen.c
===================================================================
--- misc/fdopen.c (nonexistent)
+++ misc/fdopen.c (revision 1765)
@@ -0,0 +1,46 @@
+/* Test for fdopen bugs. */
+
+#include
+#include
+#include
+
+#define assert(x) \
+ if (!(x)) \
+ { \
+ fputs ("test failed: " #x "\n", stderr); \
+ retval = 1; \
+ goto the_end; \
+ }
+
+char buffer[256];
+
+int
+main (int argc, char *argv[])
+{
+ char *name;
+ FILE *fp = NULL;
+ int retval = 0;
+ int fd;
+
+ name = tmpnam (NULL);
+ fp = fopen (name, "w");
+ assert (fp != NULL)
+ fputs ("foobar and baz", fp);
+ fclose (fp);
+ fp = NULL;
+
+ fd = open (name, O_RDWR|O_CREAT);
+ assert (fd != -1);
+ assert (lseek (fd, 5, SEEK_SET) == 5);
+
+ fp = fdopen (fd, "a");
+ assert (fp != NULL);
+ assert (ftell (fp) == 14);
+
+the_end:
+ if (fp != NULL)
+ fclose (fp);
+ unlink (name);
+
+ return retval;
+}
Index: misc/Makefile
===================================================================
--- misc/Makefile (nonexistent)
+++ misc/Makefile (revision 1765)
@@ -0,0 +1,134 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+CFLAGS64=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+
+TARGETS=sem fdopen dirent_diff dirent64_diff #outb
+all: $(TARGETS)
+
+outb: outb.c ../testsuite.h Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ ./$@
+ -@ echo " "
+
+sem: sem.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+fdopen: fdopen.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+dirent_source:
+ -@ $(RM) $(TARGETS)
+ -@ echo "-------"
+ -@ echo "dirent.c source: "
+ -@ echo " "
+ -@ cat dirent.c
+ -@ echo " "
+
+dirent: dirent.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ dirent.c > $@.out
+ -@ echo " "
+
+dirent_glibc: dirent.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ dirent.c > $@.out
+ -@ echo " "
+
+dirent_diff: dirent dirent_glibc
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing dirent output: "
+ -@ echo " "
+ -diff -u dirent_glibc.out dirent.out
+ -@ echo " "
+
+dirent64: dirent.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) $(CFLAGS64) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ dirent.c > $@.out
+ -@ echo " "
+
+dirent64_glibc: dirent.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) $(CFLAGS64) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ dirent.c > $@.out
+ -@ echo " "
+
+dirent64_diff: dirent64 dirent64_glibc
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing dirent64 output: "
+ -@ echo " "
+ -diff -u dirent64_glibc.out dirent64.out
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core dirent dirent_glibc dirent_glibc.out dirent.out \
+ dirent64 dirent64_glibc dirent64_glibc.out dirent64.out \
+ outb sem fdopen
+
+
+
Index: misc
===================================================================
--- misc (nonexistent)
+++ misc (revision 1765)
misc
Property changes :
Added: svn:ignore
## -0,0 +1,11 ##
+outb
+sem
+fdopen
+dirent
+dirent.out
+dirent_glibc
+dirent_glibc.out
+dirent64
+dirent64.out
+dirent64_glibc
+dirent64_glibc.out
Index: args/arg_test.c
===================================================================
--- args/arg_test.c (nonexistent)
+++ args/arg_test.c (revision 1765)
@@ -0,0 +1,55 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Test application for argc and argv handling
+ *
+ * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 2000,2001 by Erik Andersen
+ * Written by Erik Andersen
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include
+#include
+
+int main( int argc, char **argv)
+{
+ int i=0;
+ char** index=__environ;
+
+#ifdef __powerpc__
+ {
+ unsigned long sp;
+ sp = (unsigned long) __builtin_frame_address(0);
+ if(sp&0xf){
+ fprintf(stderr, "stack pointer is unaligned! (%08lx)\n", sp);
+ }
+ }
+#endif
+
+ fprintf(stderr, "argc=%d\n", argc);
+
+ for(i=0;i
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+TARGETS=arg_test
+all: $(TARGETS)
+
+arg_test: arg_test.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ a b c d e f g h
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
+
Index: args
===================================================================
--- args (nonexistent)
+++ args (revision 1765)
args
Property changes :
Added: svn:ignore
## -0,0 +1 ##
+arg_test
Index: silly/hello.c
===================================================================
--- silly/hello.c (nonexistent)
+++ silly/hello.c (revision 1765)
@@ -0,0 +1,8 @@
+#include
+#include
+
+int main(void)
+{
+ printf("hello world\n");
+ exit(42);
+}
Index: silly/tiny.c
===================================================================
--- silly/tiny.c (nonexistent)
+++ silly/tiny.c (revision 1765)
@@ -0,0 +1,6 @@
+#include
+
+int main(void)
+{
+ _exit(42);
+}
Index: silly/Makefile
===================================================================
--- silly/Makefile (nonexistent)
+++ silly/Makefile (revision 1765)
@@ -0,0 +1,80 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+
+TARGETS=hello_source hello hello_glibc tiny
+
+all: $(TARGETS)
+
+hello_source:
+ -@ $(RM) $(TARGETS)
+ -@ echo "-------"
+ -@ echo "hello.c source: "
+ -@ echo " "
+ -@ cat hello.c
+ -@ echo " "
+
+hello: hello.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+hello_glibc: hello.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+
+tiny: tiny.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
+
Index: silly
===================================================================
--- silly (nonexistent)
+++ silly (revision 1765)
silly
Property changes :
Added: svn:ignore
## -0,0 +1,6 ##
+hello
+hello.o
+hello_glibc
+hello_glibc.o
+tiny
+tiny.o
Index: assert/assert.c
===================================================================
--- assert/assert.c (nonexistent)
+++ assert/assert.c (revision 1765)
@@ -0,0 +1,61 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Test application for functions defined in ctype.h
+ *
+ * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 2000,2001 by Erik Andersen
+ * Written by Erik Andersen
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include "../testsuite.h"
+
+int got_abort;
+
+void aborthandler(int junk)
+{
+ got_abort=1;
+}
+
+int main( int argc, char **argv)
+{
+ signal(SIGABRT, aborthandler);
+
+ init_testsuite("Testing functions defined in assert.h:\n\t");
+
+ got_abort=0;
+ assert(0==0);
+ TEST_NUMERIC(got_abort, 0);
+
+#define NDEBUG
+ got_abort=0;
+ printf("Don't worry -- This next test is supposed to print an assert message:\n");
+ fprintf(stderr, "\t");
+ assert(0==1);
+ TEST_NUMERIC(got_abort, 0);
+
+#undef NDEBUG
+ got_abort=0;
+ assert(0==1);
+ TEST_NUMERIC(got_abort, 1);
+
+ exit(0);
+}
Index: assert/Makefile
===================================================================
--- assert/Makefile (nonexistent)
+++ assert/Makefile (revision 1765)
@@ -0,0 +1,40 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+TARGETS=assert
+all: $(TARGETS)
+
+assert: assert.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
+
Index: assert
===================================================================
--- assert (nonexistent)
+++ assert (revision 1765)
assert
Property changes :
Added: svn:ignore
## -0,0 +1,4 ##
+assert
+assert.o
+assert_glibc.o
+assert_glibc
Index: crypt/crypt.input
===================================================================
--- crypt/crypt.input (nonexistent)
+++ crypt/crypt.input (revision 1765)
@@ -0,0 +1,171 @@
+0101010101010101 95f8a5e5dd31d900 8000000000000000
+0101010101010101 dd7f121ca5015619 4000000000000000
+0101010101010101 2e8653104f3834ea 2000000000000000
+0101010101010101 4bd388ff6cd81d4f 1000000000000000
+0101010101010101 20b9e767b2fb1456 0800000000000000
+0101010101010101 55579380d77138ef 0400000000000000
+0101010101010101 6cc5defaaf04512f 0200000000000000
+0101010101010101 0d9f279ba5d87260 0100000000000000
+0101010101010101 d9031b0271bd5a0a 0080000000000000
+0101010101010101 424250b37c3dd951 0040000000000000
+0101010101010101 b8061b7ecd9a21e5 0020000000000000
+0101010101010101 f15d0f286b65bd28 0010000000000000
+0101010101010101 add0cc8d6e5deba1 0008000000000000
+0101010101010101 e6d5f82752ad63d1 0004000000000000
+0101010101010101 ecbfe3bd3f591a5e 0002000000000000
+0101010101010101 f356834379d165cd 0001000000000000
+0101010101010101 2b9f982f20037fa9 0000800000000000
+0101010101010101 889de068a16f0be6 0000400000000000
+0101010101010101 e19e275d846a1298 0000200000000000
+0101010101010101 329a8ed523d71aec 0000100000000000
+0101010101010101 e7fce22557d23c97 0000080000000000
+0101010101010101 12a9f5817ff2d65d 0000040000000000
+0101010101010101 a484c3ad38dc9c19 0000020000000000
+0101010101010101 fbe00a8a1ef8ad72 0000010000000000
+0101010101010101 750d079407521363 0000008000000000
+0101010101010101 64feed9c724c2faf 0000004000000000
+0101010101010101 f02b263b328e2b60 0000002000000000
+0101010101010101 9d64555a9a10b852 0000001000000000
+0101010101010101 d106ff0bed5255d7 0000000800000000
+0101010101010101 e1652c6b138c64a5 0000000400000000
+0101010101010101 e428581186ec8f46 0000000200000000
+0101010101010101 aeb5f5ede22d1a36 0000000100000000
+0101010101010101 e943d7568aec0c5c 0000000080000000
+0101010101010101 df98c8276f54b04b 0000000040000000
+0101010101010101 b160e4680f6c696f 0000000020000000
+0101010101010101 fa0752b07d9c4ab8 0000000010000000
+0101010101010101 ca3a2b036dbc8502 0000000008000000
+0101010101010101 5e0905517bb59bcf 0000000004000000
+0101010101010101 814eeb3b91d90726 0000000002000000
+0101010101010101 4d49db1532919c9f 0000000001000000
+0101010101010101 25eb5fc3f8cf0621 0000000000800000
+0101010101010101 ab6a20c0620d1c6f 0000000000400000
+0101010101010101 79e90dbc98f92cca 0000000000200000
+0101010101010101 866ecedd8072bb0e 0000000000100000
+0101010101010101 8b54536f2f3e64a8 0000000000080000
+0101010101010101 ea51d3975595b86b 0000000000040000
+0101010101010101 caffc6ac4542de31 0000000000020000
+0101010101010101 8dd45a2ddf90796c 0000000000010000
+0101010101010101 1029d55e880ec2d0 0000000000008000
+0101010101010101 5d86cb23639dbea9 0000000000004000
+0101010101010101 1d1ca853ae7c0c5f 0000000000002000
+0101010101010101 ce332329248f3228 0000000000001000
+0101010101010101 8405d1abe24fb942 0000000000000800
+0101010101010101 e643d78090ca4207 0000000000000400
+0101010101010101 48221b9937748a23 0000000000000200
+0101010101010101 dd7c0bbd61fafd54 0000000000000100
+0101010101010101 2fbc291a570db5c4 0000000000000080
+0101010101010101 e07c30d7e4e26e12 0000000000000040
+0101010101010101 0953e2258e8e90a1 0000000000000020
+0101010101010101 5b711bc4ceebf2ee 0000000000000010
+0101010101010101 cc083f1e6d9e85f6 0000000000000008
+0101010101010101 d2fd8867d50d2dfe 0000000000000004
+0101010101010101 06e7ea22ce92708f 0000000000000002
+0101010101010101 166b40b44aba4bd6 0000000000000001
+8001010101010101 0000000000000000 95a8d72813daa94d
+4001010101010101 0000000000000000 0eec1487dd8c26d5
+2001010101010101 0000000000000000 7ad16ffb79c45926
+1001010101010101 0000000000000000 d3746294ca6a6cf3
+0801010101010101 0000000000000000 809f5f873c1fd761
+0401010101010101 0000000000000000 c02faffec989d1fc
+0201010101010101 0000000000000000 4615aa1d33e72f10
+0180010101010101 0000000000000000 2055123350c00858
+0140010101010101 0000000000000000 df3b99d6577397c8
+0120010101010101 0000000000000000 31fe17369b5288c9
+0110010101010101 0000000000000000 dfdd3cc64dae1642
+0108010101010101 0000000000000000 178c83ce2b399d94
+0104010101010101 0000000000000000 50f636324a9b7f80
+0102010101010101 0000000000000000 a8468ee3bc18f06d
+0101800101010101 0000000000000000 a2dc9e92fd3cde92
+0101400101010101 0000000000000000 cac09f797d031287
+0101200101010101 0000000000000000 90ba680b22aeb525
+0101100101010101 0000000000000000 ce7a24f350e280b6
+0101080101010101 0000000000000000 882bff0aa01a0b87
+0101040101010101 0000000000000000 25610288924511c2
+0101020101010101 0000000000000000 c71516c29c75d170
+0101018001010101 0000000000000000 5199c29a52c9f059
+0101014001010101 0000000000000000 c22f0a294a71f29f
+0101012001010101 0000000000000000 ee371483714c02ea
+0101011001010101 0000000000000000 a81fbd448f9e522f
+0101010801010101 0000000000000000 4f644c92e192dfed
+0101010401010101 0000000000000000 1afa9a66a6df92ae
+0101010201010101 0000000000000000 b3c1cc715cb879d8
+0101010180010101 0000000000000000 19d032e64ab0bd8b
+0101010140010101 0000000000000000 3cfaa7a7dc8720dc
+0101010120010101 0000000000000000 b7265f7f447ac6f3
+0101010110010101 0000000000000000 9db73b3c0d163f54
+0101010108010101 0000000000000000 8181b65babf4a975
+0101010104010101 0000000000000000 93c9b64042eaa240
+0101010102010101 0000000000000000 5570530829705592
+0101010101800101 0000000000000000 8638809e878787a0
+0101010101400101 0000000000000000 41b9a79af79ac208
+0101010101200101 0000000000000000 7a9be42f2009a892
+0101010101100101 0000000000000000 29038d56ba6d2745
+0101010101080101 0000000000000000 5495c6abf1e5df51
+0101010101040101 0000000000000000 ae13dbd561488933
+0101010101020101 0000000000000000 024d1ffa8904e389
+0101010101018001 0000000000000000 d1399712f99bf02e
+0101010101014001 0000000000000000 14c1d7c1cffec79e
+0101010101012001 0000000000000000 1de5279dae3bed6f
+0101010101011001 0000000000000000 e941a33f85501303
+0101010101010801 0000000000000000 da99dbbc9a03f379
+0101010101010401 0000000000000000 b7fc92f91d8e92e9
+0101010101010201 0000000000000000 ae8e5caa3ca04e85
+0101010101010180 0000000000000000 9cc62df43b6eed74
+0101010101010140 0000000000000000 d863dbb5c59a91a0
+0101010101010120 0000000000000000 a1ab2190545b91d7
+0101010101010110 0000000000000000 0875041e64c570f7
+0101010101010108 0000000000000000 5a594528bebef1cc
+0101010101010104 0000000000000000 fcdb3291de21f0c0
+0101010101010102 0000000000000000 869efd7f9f265a09
+1046913489980131 0000000000000000 88d55e54f54c97b4
+1007103489988020 0000000000000000 0c0cc00c83ea48fd
+10071034c8980120 0000000000000000 83bc8ef3a6570183
+1046103489988020 0000000000000000 df725dcad94ea2e9
+1086911519190101 0000000000000000 e652b53b550be8b0
+1086911519580101 0000000000000000 af527120c485cbb0
+5107b01519580101 0000000000000000 0f04ce393db926d5
+1007b01519190101 0000000000000000 c9f00ffc74079067
+3107915498080101 0000000000000000 7cfd82a593252b4e
+3107919498080101 0000000000000000 cb49a2f9e91363e3
+10079115b9080140 0000000000000000 00b588be70d23f56
+3107911598080140 0000000000000000 406a9a6ab43399ae
+1007d01589980101 0000000000000000 6cb773611dca9ada
+9107911589980101 0000000000000000 67fd21c17dbb5d70
+9107d01589190101 0000000000000000 9592cb4110430787
+1007d01598980120 0000000000000000 a6b7ff68a318ddd3
+1007940498190101 0000000000000000 4d102196c914ca16
+0107910491190401 0000000000000000 2dfa9f4573594965
+0107910491190101 0000000000000000 b46604816c0e0774
+0107940491190401 0000000000000000 6e7e6221a4f34e87
+19079210981a0101 0000000000000000 aa85e74643233199
+1007911998190801 0000000000000000 2e5a19db4d1962d6
+10079119981a0801 0000000000000000 23a866a809d30894
+1007921098190101 0000000000000000 d812d961f017d320
+100791159819010b 0000000000000000 055605816e58608f
+1004801598190101 0000000000000000 abd88e8b1b7716f1
+1004801598190102 0000000000000000 537ac95be69da1e1
+1004801598190108 0000000000000000 aed0f6ae3c25cdd8
+1002911598100104 0000000000000000 b3e35a5ee53e7b8d
+1002911598190104 0000000000000000 61c79c71921a2ef8
+1002911598100201 0000000000000000 e2f5728f0995013c
+1002911698100101 0000000000000000 1aeac39a61f0a464
+7ca110454a1a6e57 01a1d6d039776742 690f5b0d9a26939b
+0131d9619dc1376e 5cd54ca83def57da 7a389d10354bd271
+07a1133e4a0b2686 0248d43806f67172 868ebb51cab4599a
+3849674c2602319e 51454b582ddf440a 7178876e01f19b2a
+04b915ba43feb5b6 42fd443059577fa2 af37fb421f8c4095
+0113b970fd34f2ce 059b5e0851cf143a 86a560f10ec6d85b
+0170f175468fb5e6 0756d8e0774761d2 0cd3da020021dc09
+43297fad38e373fe 762514b829bf486a ea676b2cb7db2b7a
+07a7137045da2a16 3bdd119049372802 dfd64a815caf1a0f
+04689104c2fd3b2f 26955f6835af609a 5c513c9c4886c088
+37d06bb516cb7546 164d5e404f275232 0a2aeeae3ff4ab77
+1f08260d1ac2465e 6b056e18759f5cca ef1bf03e5dfa575a
+584023641aba6176 004bd6ef09176062 88bf0db6d70dee56
+025816164629b007 480d39006ee762f2 a1f9915541020b56
+49793ebc79b3258f 437540c8698f3cfa 6fbf1cafcffd0556
+4fb05e1515ab73a7 072d43a077075292 2f22e49bab7ca1ac
+49e95d6d4ca229bf 02fe55778117f12a 5a6b612cc26cce4a
+018310dc409b26d6 1d9d5c5018f728c2 5f4c038ed12b2e41
+1c587f1c13924fef 305532286d6f295a 63fac0d034d9f793
Index: crypt/crypt.c
===================================================================
--- crypt/crypt.c (nonexistent)
+++ crypt/crypt.c (revision 1765)
@@ -0,0 +1,113 @@
+
+/*
+ * This crypt(3) validation program shipped with UFC-crypt
+ * is derived from one distributed with Phil Karns PD DES package.
+ *
+ * @(#)cert.c 1.8 11 Aug 1996
+ */
+
+#include
+#include
+#include "crypt.h"
+
+int totfails = 0;
+
+#if __STDC__ - 0
+int main (int argc, char *argv[]);
+void get8 (char *cp);
+void put8 (char *cp);
+void good_bye (void) __attribute__ ((noreturn));
+#else
+void get8(), put8();
+#endif
+
+void good_bye ()
+{
+ if(totfails == 0) {
+ printf("Passed DES validation suite\n");
+ exit(0);
+ } else {
+ printf("%d failures during DES validation suite!!!\n", totfails);
+ exit(1);
+ }
+}
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ char key[64],plain[64],cipher[64],answer[64];
+ int i;
+ int test;
+ int fail;
+
+ for(test=0;!feof(stdin);test++){
+
+ get8(key);
+ printf(" K: "); put8(key);
+ setkey(key);
+
+ get8(plain);
+ printf(" P: "); put8(plain);
+
+ get8(answer);
+ printf(" C: "); put8(answer);
+
+ for(i=0;i<64;i++)
+ cipher[i] = plain[i];
+ encrypt(cipher, 0);
+
+ for(i=0;i<64;i++)
+ if(cipher[i] != answer[i])
+ break;
+ fail = 0;
+ if(i != 64){
+ printf(" Encrypt FAIL");
+ fail++; totfails++;
+ }
+
+ encrypt(cipher, 1);
+
+ for(i=0;i<64;i++)
+ if(cipher[i] != plain[i])
+ break;
+ if(i != 64){
+ printf(" Decrypt FAIL");
+ fail++; totfails++;
+ }
+
+ if(fail == 0)
+ printf(" OK");
+ printf("\n");
+ }
+ good_bye();
+}
+void
+get8(cp)
+char *cp;
+{
+ int i,j,t;
+
+ for(i=0;i<8;i++){
+ scanf("%2x",&t);
+ if(feof(stdin))
+ good_bye();
+ for(j=0; j<8 ; j++) {
+ *cp++ = (t & (0x01 << (7-j))) != 0;
+ }
+ }
+}
+void
+put8(cp)
+char *cp;
+{
+ int i,j,t;
+
+ for(i=0;i<8;i++){
+ t = 0;
+ for(j = 0; j<8; j++)
+ t = (t<<1) | *cp++;
+ printf("%02x", t);
+ }
+}
Index: crypt/md5c-test.c
===================================================================
--- crypt/md5c-test.c (nonexistent)
+++ crypt/md5c-test.c (revision 1765)
@@ -0,0 +1,19 @@
+#include
+#include
+#include
+#include
+
+int
+main (int argc, char *argv[])
+{
+ const char salt[] = "$1$saltstring";
+ char *cp;
+
+ cp = crypt ("Hello world!", salt);
+ if (strcmp ("$1$saltstri$YMyguxXMBpd2TEZ.vS/3q1", cp)) {
+ fprintf(stderr, "Failed md5 crypt test!\n");
+ return EXIT_FAILURE;
+ }
+ fprintf(stderr, "Passed md5 crypt test!\n");
+ return EXIT_SUCCESS;
+}
Index: crypt/Makefile
===================================================================
--- crypt/Makefile (nonexistent)
+++ crypt/Makefile (revision 1765)
@@ -0,0 +1,73 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2002 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+TARGETS=crypt md5c-test
+EXTRA_LIBS=-lcrypt
+
+all: $(TARGETS)
+
+crypt: crypt.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ < crypt.input #> $@.out 2>&1
+ -@ echo " "
+
+crypt_glibc: crypt.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs glibc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ < crypt.input > $@.out 2>&1
+ -@ echo " "
+
+diff: crypt_glibc crypt
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u crypt_glibc.out crypt.out
+ -@ echo " "
+
+md5c-test: md5c-test.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core crypt_glibc crypt crypt_glibc.out crypt.out md5c-test
+
+
Index: crypt
===================================================================
--- crypt (nonexistent)
+++ crypt (revision 1765)
crypt
Property changes :
Added: svn:ignore
## -0,0 +1,5 ##
+crypt
+crypt.out
+crypt_glibc
+crypt_glibc.out
+md5c-test
Index: Rules.mak
===================================================================
--- Rules.mak (nonexistent)
+++ Rules.mak (revision 1765)
@@ -0,0 +1,92 @@
+# Rules.make for uClibc test apps.
+#
+# Copyright (C) 2001 by Lineo, inc.
+#
+#
+#Note: This does not read the top level Rules.mak file
+#
+
+-include $(TESTDIR)../.config
+include $(TESTDIR)Config
+
+#--------------------------------------------------------
+# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
+LC_ALL:= C
+export LC_ALL
+
+ifeq ($(strip $(TARGET_ARCH)),)
+TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
+ -e 's/i.86/i386/' \
+ -e 's/sparc.*/sparc/' \
+ -e 's/arm.*/arm/g' \
+ -e 's/m68k.*/m68k/' \
+ -e 's/ppc/powerpc/g' \
+ -e 's/v850.*/v850/g' \
+ -e 's/sh[234]/sh/' \
+ -e 's/mips-.*/mips/' \
+ -e 's/mipsel-.*/mipsel/' \
+ -e 's/cris.*/cris/' \
+ )
+endif
+export TARGET_ARCH
+
+
+#--------------------------------------------------------
+# If you are running a cross compiler, you will want to set 'CROSS'
+# to something more interesting... Target architecture is determined
+# by asking the CC compiler what arch it compiles things for, so unless
+# your compiler is broken, you should not need to specify TARGET_ARCH
+#
+# Most people will set this stuff on the command line, i.e.
+# make CROSS=mipsel-linux-
+# will build uClibc for 'mipsel'.
+
+CROSS=
+CC= $(CROSS)gcc
+STRIPTOOL=strip
+LDD=../$(TESTDIR)ldso/util/ldd
+
+RM= rm -f
+
+# Select the compiler needed to build binaries for your development system
+HOSTCC=gcc
+HOSTCFLAGS=-O2 -Wall
+
+
+#--------------------------------------------------------
+# Check if 'ls -sh' works or not
+LSFLAGS = -l
+
+# A nifty macro to make testing gcc features easier
+check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
+ then echo "$(1)"; else echo "$(2)"; fi)
+
+# use '-Os' optimization if available, else use -O2, allow Config to override
+OPTIMIZATION+=$(call check_gcc,-Os,-O2)
+# Override optimization settings when debugging
+ifeq ($(DODEBUG),true)
+OPTIMIZATION=-O0
+endif
+
+XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
+XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
+CFLAGS=$(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS)
+GLIBC_CFLAGS+=$(XWARNINGS) $(OPTIMIZATION)
+LDFLAGS=
+
+ifeq ($(DODEBUG),true)
+ CFLAGS+=-g
+ GLIBC_CFLAGS+=-g
+ LDFLAGS += -g -Wl,-warn-common
+ GLIBC_LDFLAGS =-g -Wl,-warn-common
+ STRIPTOOL =true -Since_we_are_debugging
+else
+ LDFLAGS +=-s -Wl,-warn-common
+ GLIBC_LDFLAGS =-s -Wl,-warn-common
+ STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
+endif
+
+ifneq ($(DODYNAMIC),true)
+ LDFLAGS +=-static
+ GLIBC_LDFLAGS +=-static
+endif
Index: setjmp/setjmp_test.c
===================================================================
--- setjmp/setjmp_test.c (nonexistent)
+++ setjmp/setjmp_test.c (revision 1765)
@@ -0,0 +1,118 @@
+/* Copyright (C) 1991, 1992, 1997, 1998, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include
+#include
+#include
+
+static jmp_buf env;
+static int last_value = -1, lose = 0;
+
+static void
+jump (int val)
+{
+ longjmp (env, val);
+}
+
+int
+main (void)
+{
+ int value;
+
+ value = setjmp (env);
+ if (value != last_value + 1)
+ {
+ fputs("Shouldn't have ", stdout);
+ lose = 1;
+ }
+ last_value = value;
+ switch (value)
+ {
+ case 0:
+ puts("Saved environment.");
+ jump (0);
+ default:
+ printf ("Jumped to %d.\n", value);
+ if (value < 10)
+ jump (value + 1);
+ }
+
+ if (!lose && value == 10)
+ {
+ /* Do a second test, this time without `setjmp' being a macro.
+ This is not required by ISO C but we have this for compatibility. */
+#undef setjmp
+ extern int setjmp (jmp_buf);
+
+ last_value = -1;
+ lose = 0;
+
+ value = setjmp (env);
+ if (value != last_value + 1)
+ {
+ fputs("Shouldn't have ", stdout);
+ lose = 1;
+ }
+ last_value = value;
+ switch (value)
+ {
+ case 0:
+ puts("Saved environment.");
+ jump (0);
+ default:
+ printf ("Jumped to %d.\n", value);
+ if (value < 10)
+ jump (value + 1);
+ }
+ }
+
+ if (!lose && value == 10)
+ {
+ /* And again for the `_setjmp' function. */
+#ifndef _setjmp
+ extern int _setjmp (jmp_buf);
+#endif
+ last_value = -1;
+ lose = 0;
+
+ value = _setjmp (env);
+ if (value != last_value + 1)
+ {
+ fputs("Shouldn't have ", stdout);
+ lose = 1;
+ }
+ last_value = value;
+ switch (value)
+ {
+ case 0:
+ puts("Saved environment.");
+ jump (0);
+ default:
+ printf ("Jumped to %d.\n", value);
+ if (value < 10)
+ jump (value + 1);
+ }
+ }
+
+ if (lose || value != 10)
+ puts ("Test FAILED!");
+ else
+ puts ("Test succeeded!");
+
+ return lose ? EXIT_FAILURE : EXIT_SUCCESS;
+}
Index: setjmp/Makefile
===================================================================
--- setjmp/Makefile (nonexistent)
+++ setjmp/Makefile (revision 1765)
@@ -0,0 +1,40 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+TARGETS=setjmp_test
+all: $(TARGETS)
+
+setjmp_test: setjmp_test.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
+
Index: setjmp
===================================================================
--- setjmp (nonexistent)
+++ setjmp (revision 1765)
setjmp
Property changes :
Added: svn:ignore
## -0,0 +1 ##
+setjmp_test
Index: pwd_grp/pwcat.c
===================================================================
--- pwd_grp/pwcat.c (nonexistent)
+++ pwd_grp/pwcat.c (revision 1765)
@@ -0,0 +1,26 @@
+/*
+ * pwcat.c
+ *
+ * Generate a printable version of the password database
+ */
+/*
+ * Arnold Robbins, arnold@gnu.org, May 1993
+ * Public Domain
+ */
+
+#include
+#include
+#include
+
+int main(int argc, char **argv)
+{
+ struct passwd *p;
+
+ while ((p = getpwent()) != NULL)
+ printf("%s:%s:%ld:%ld:%s:%s:%s\n",
+ p->pw_name, p->pw_passwd, (long) p->pw_uid,
+ (long) p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell);
+
+ endpwent();
+ return 0;
+}
Index: pwd_grp/getgroups.c
===================================================================
--- pwd_grp/getgroups.c (nonexistent)
+++ pwd_grp/getgroups.c (revision 1765)
@@ -0,0 +1,108 @@
+/* This test was ripped out of GNU 'id' from coreutils-5.0
+ * by Erik Andersen.
+ *
+ *
+ * id is Copyright (C) 1989-2003 Free Software Foundation, Inc.
+ * and licensed under the GPL v2 or later, and was written by
+ * Arnold Robbins, with a major rewrite by David MacKenzie,
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/* The number of errors encountered so far. */
+static int problems = 0;
+
+/* Print the name or value of group ID GID. */
+static void
+print_group (gid_t gid)
+{
+ struct group *grp = NULL;
+
+ grp = getgrgid (gid);
+ if (grp == NULL)
+ {
+ warn("cannot find name for group ID %u", gid);
+ problems++;
+ }
+
+ if (grp == NULL)
+ printf ("%u", (unsigned) gid);
+ else
+ printf ("%s", grp->gr_name);
+}
+
+static int
+xgetgroups (gid_t gid, int *n_groups, gid_t **groups)
+{
+ int max_n_groups;
+ int ng;
+ gid_t *g;
+ int fail = 0;
+
+ max_n_groups = getgroups (0, NULL);
+
+ /* Add 1 just in case max_n_groups is zero. */
+ g = (gid_t *) malloc (max_n_groups * sizeof (gid_t) + 1);
+ if (g==NULL)
+ err(EXIT_FAILURE, "out of memory");
+ ng = getgroups (max_n_groups, g);
+
+ if (ng < 0)
+ {
+ warn("cannot get supplemental group list");
+ ++fail;
+ free (groups);
+ }
+ if (!fail)
+ {
+ *n_groups = ng;
+ *groups = g;
+ }
+ return fail;
+}
+
+/* Print all of the distinct groups the user is in. */
+int main (int argc, char **argv)
+{
+ struct passwd *pwd;
+
+ pwd = getpwuid (getuid());
+ if (pwd == NULL)
+ problems++;
+
+ print_group (getgid());
+ if (getegid() != getgid())
+ {
+ putchar (' ');
+ print_group (getegid());
+ }
+
+ {
+ int n_groups;
+ gid_t *groups;
+ register int i;
+
+ if (xgetgroups ((pwd ? pwd->pw_gid : (gid_t) -1),
+ &n_groups, &groups))
+ {
+ return ++problems;
+ }
+
+ for (i = 0; i < n_groups; i++)
+ if (groups[i] != getgid() && groups[i] != getegid())
+ {
+ putchar (' ');
+ print_group (groups[i]);
+ }
+ free (groups);
+ }
+ putchar('\n');
+ return (problems != 0);
+}
+
Index: pwd_grp/grcat.c
===================================================================
--- pwd_grp/grcat.c (nonexistent)
+++ pwd_grp/grcat.c (revision 1765)
@@ -0,0 +1,32 @@
+/*
+ * grcat.c
+ *
+ * Generate a printable version of the group database
+ */
+/*
+ * Arnold Robbins, arnold@gnu.org, May 1993
+ * Public Domain
+ */
+
+#include
+#include
+#include
+
+int main(int argc, char **argv)
+{
+ struct group *g;
+ int i;
+
+ while ((g = getgrent()) != NULL) {
+ printf("%s:%s:%ld:", g->gr_name, g->gr_passwd,
+ (long) g->gr_gid);
+ for (i = 0; g->gr_mem[i] != NULL; i++) {
+ printf("%s", g->gr_mem[i]);
+ if (g->gr_mem[i+1] != NULL)
+ putchar(',');
+ }
+ putchar('\n');
+ }
+ endgrent();
+ return 0;
+}
Index: pwd_grp/test_grp.c
===================================================================
--- pwd_grp/test_grp.c (nonexistent)
+++ pwd_grp/test_grp.c (revision 1765)
@@ -0,0 +1,100 @@
+/*
+ * test_grp.c - This file is part of the libc-8086/grp package for ELKS,
+ * Copyright (C) 1995, 1996 Nat Friedman .
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include
+#include
+#include
+#include
+
+int main(int argc, char **argv)
+{
+ struct group *group;
+ char **tmp_mem;
+ int test_gid;
+
+ fprintf(stdout, "Beginning test of libc/grp...\n");
+
+ fprintf(stdout, "=> Testing setgrent(), getgrent(), endgrent()...\n");
+ fprintf(stdout, "-> setgrent()...\n");
+ setgrent();
+ fprintf(stdout, "-> getgrent()...\n");
+ printf
+ ("********************************************************************************\n");
+ while ((group = getgrent()) != NULL) {
+ printf("gr_name\t\t: %s\n", group->gr_name);
+ printf("gr_passwd\t: %s\n", group->gr_passwd);
+ printf("gr_gid\t\t: %d\n", (int) group->gr_gid);
+ printf("gr_mem\t\t: ");
+ fflush(stdout);
+ tmp_mem = group->gr_mem;
+ while (*tmp_mem != NULL) {
+ printf("%s, ", *tmp_mem);
+ tmp_mem++;
+ }
+ printf
+ ("\n********************************************************************************\n");
+ }
+ fprintf(stdout, "-> endgrent()...\n");
+ endgrent();
+ fprintf(stdout,
+ "=> Test of setgrent(), getgrent(), endgrent() complete.\n");
+ fprintf(stdout, "=> Testing getgrid(), getgrnam()...\n");
+ fprintf(stdout, "-> getgrgid()...\n");
+ printf
+ ("********************************************************************************\n");
+ for (test_gid = 0; test_gid < 100; test_gid++) {
+ fprintf(stdout, "-> getgrgid(%d)...\n", test_gid);
+ group = getgrgid((gid_t) test_gid);
+ if (group != NULL) {
+ printf("gr_name\t: %s\n", group->gr_name);
+ printf("gr_passwd\t: %s\n", group->gr_passwd);
+ printf("gr_gid\t: %d\n", (int) group->gr_gid);
+ printf("gr_mem\t\t: ");
+ fflush(stdout);
+ tmp_mem = group->gr_mem;
+ while (*tmp_mem != NULL) {
+ printf("%s, ", *tmp_mem);
+ tmp_mem++;
+ }
+ }
+ printf
+ ("\n********************************************************************************\n");
+ }
+ fprintf(stdout, "-> getgrnam()...\n");
+ group = getgrnam("root");
+ if (group == NULL) {
+ printf(">NULL<\n");
+ } else {
+ printf("gr_name\t: %s\n", group->gr_name);
+ printf("gr_passwd\t: %s\n", group->gr_passwd);
+ printf("gr_gid\t: %d\n", (int) group->gr_gid);
+ printf("gr_mem\t\t: ");
+ fflush(stdout);
+ tmp_mem = group->gr_mem;
+ while (*tmp_mem != NULL) {
+ printf("%s, ", *tmp_mem);
+ tmp_mem++;
+ }
+ printf("\n");
+ }
+
+
+ return 0;
+}
Index: pwd_grp/test_pwd.c
===================================================================
--- pwd_grp/test_pwd.c (nonexistent)
+++ pwd_grp/test_pwd.c (revision 1765)
@@ -0,0 +1,87 @@
+/*
+ * test_pwd.c - This file is part of the libc-8086/pwd package for ELKS,
+ * Copyright (C) 1995, 1996 Nat Friedman .
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include
+#include
+#include
+#include
+
+int main(int argc, char **argv)
+{
+ struct passwd *passwd;
+ int test_uid;
+
+ fprintf(stdout, "Beginning test of libc/pwd...\n");
+
+ fprintf(stdout, "=> Testing setpwent(), getpwent(), endpwent()...\n");
+ fprintf(stdout, "-> setpwent()...\n");
+ setpwent();
+ fprintf(stdout, "-> getpwent()...\n");
+ printf
+ ("********************************************************************************\n");
+ while ((passwd = getpwent()) != NULL) {
+ printf("pw_name\t\t: %s\n", passwd->pw_name);
+ printf("pw_passwd\t: %s\n", passwd->pw_passwd);
+ printf("pw_uid\t\t: %d\n", (int) passwd->pw_uid);
+ printf("pw_gid\t\t: %d\n", (int) passwd->pw_gid);
+ printf("pw_gecos\t: %s\n", passwd->pw_gecos);
+ printf("pw_dir\t\t: %s\n", passwd->pw_dir);
+ printf("pw_shell\t: %s\n", passwd->pw_shell);
+ printf
+ ("********************************************************************************\n");
+ }
+ fprintf(stdout, "-> endpwent()...\n");
+ endpwent();
+ fprintf(stdout,
+ "=> Test of setpwent(), getpwent(), endpwent() complete.\n");
+ fprintf(stdout, "=> Testing getpwuid(), getpwnam()...\n");
+ fprintf(stdout, "-> getpwuid()...\n");
+ printf
+ ("********************************************************************************\n");
+ for (test_uid = 0; test_uid < 1000; test_uid++) {
+ fprintf(stdout, "-> getpwuid(%d)...\n", test_uid);
+ passwd = getpwuid((uid_t) test_uid);
+ if (passwd != NULL) {
+ printf("pw_name\t\t: %s\n", passwd->pw_name);
+ printf("pw_passwd\t: %s\n", passwd->pw_passwd);
+ printf("pw_uid\t\t: %d\n", (int) passwd->pw_uid);
+ printf("pw_gid\t\t: %d\n", (int) passwd->pw_gid);
+ printf("pw_gecos\t: %s\n", passwd->pw_gecos);
+ printf("pw_dir\t\t: %s\n", passwd->pw_dir);
+ printf("pw_shell\t: %s\n", passwd->pw_shell);
+ printf
+ ("********************************************************************************\n");
+ }
+ }
+ fprintf(stdout, "-> getpwnam()...\n");
+ passwd = getpwnam("root");
+ if (passwd == NULL) {
+ printf(">NULL<\n");
+ } else {
+ printf("pw_name\t\t: %s\n", passwd->pw_name);
+ printf("pw_passwd\t: %s\n", passwd->pw_passwd);
+ printf("pw_uid\t\t: %d\n", (int) passwd->pw_uid);
+ printf("pw_gid\t\t: %d\n", (int) passwd->pw_gid);
+ printf("pw_gecos\t: %s\n", passwd->pw_gecos);
+ printf("pw_dir\t\t: %s\n", passwd->pw_dir);
+ printf("pw_shell\t: %s\n", passwd->pw_shell);
+ }
+ return 0;
+}
Index: pwd_grp/Makefile
===================================================================
--- pwd_grp/Makefile (nonexistent)
+++ pwd_grp/Makefile (revision 1765)
@@ -0,0 +1,185 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+TARGETS=test_pwd test_pwd_glibc
+TARGETS+=test_grp test_grp_glibc
+TARGETS+=pwcat pwcat_glibc
+TARGETS+=grcat grcat_glibc
+TARGETS+=getgroups getgroups_glibc
+TARGETS+=test_pwd_diff test_grp_diff pwcat_diff grcat_diff getgroups_diff
+
+all: $(TARGETS)
+
+test_pwd: test_pwd.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ 2>&1 >test_pwd.out
+ -@ echo " "
+
+test_pwd_glibc: test_pwd.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ 2>&1 >test_pwd_glibc.out
+ -@ echo " "
+
+test_grp: test_grp.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ 2>&1 >test_grp.out
+ -@ echo " "
+
+test_grp_glibc: test_grp.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ 2>&1 >test_grp_glibc.out
+ -@ echo " "
+
+pwcat: pwcat.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ 2>&1 >pwcat.out
+ -@ echo " "
+
+pwcat_glibc: pwcat.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ 2>&1 >pwcat_glibc.out
+ -@ echo " "
+
+grcat: grcat.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ 2>&1 >grcat.out
+ -@ echo " "
+
+grcat_glibc: grcat.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ 2>&1 >grcat_glibc.out
+ -@ echo " "
+
+getgroups: getgroups.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ 2>&1 >getgroups.out
+ -@ echo " "
+
+getgroups_glibc: getgroups.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ 2>&1 >getgroups_glibc.out
+ -@ echo " "
+
+test_pwd_diff: test_pwd_glibc test_pwd
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u test_pwd_glibc.out test_pwd.out
+ -@ echo " "
+
+test_grp_diff: test_grp_glibc test_grp
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u test_grp_glibc.out test_grp.out
+ -@ echo " "
+
+pwcat_diff: pwcat_glibc pwcat
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u pwcat_glibc.out pwcat.out
+ -@ echo " "
+
+grcat_diff: grcat_glibc grcat
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u grcat_glibc.out grcat.out
+ -@ echo " "
+
+getgroups_diff: getgroups_glibc getgroups
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u getgroups_glibc.out getgroups.out
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS) *.out
+
+
Index: pwd_grp/.indent.pro
===================================================================
--- pwd_grp/.indent.pro (nonexistent)
+++ pwd_grp/.indent.pro (revision 1765)
@@ -0,0 +1,33 @@
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--break-before-boolean-operator
+--no-blank-lines-after-commas
+--braces-on-if-line
+--braces-on-struct-decl-line
+--comment-indentation25
+--declaration-comment-column25
+--no-comment-delimiters-on-blank-lines
+--cuddle-else
+--continuation-indentation4
+--case-indentation0
+--else-endif-column33
+--space-after-cast
+--line-comments-indentation0
+--declaration-indentation1
+--dont-format-first-column-comments
+--dont-format-comments
+--honour-newlines
+--indent-level4
+/* changed from 0 to 4 */
+--parameter-indentation4
+--line-length78 /* changed from 75 */
+--continue-at-parentheses
+--no-space-after-function-call-names
+--dont-break-procedure-type
+--dont-star-comments
+--leave-optional-blank-lines
+--dont-space-special-semicolon
+--tab-size4
+/* additions by Mark */
+--case-brace-indentation0
+--leave-preprocessor-space
Index: pwd_grp
===================================================================
--- pwd_grp (nonexistent)
+++ pwd_grp (revision 1765)
pwd_grp
Property changes :
Added: svn:ignore
## -0,0 +1,20 ##
+test_grp
+test_grp.out
+test_grp_glibc
+test_grp_glibc.out
+test_pwd
+test_pwd.out
+test_pwd_glibc
+test_pwd_glibc.out
+pwcat
+pwcat.out
+pwcat_glibc
+pwcat_glibc.out
+grcat
+grcat.out
+grcat_glibc
+grcat_glibc.out
+getgroups
+getgroups.out
+getgroups_glibc
+getgroups_glibc.out
Index: Config
===================================================================
--- Config (nonexistent)
+++ Config (revision 1765)
@@ -0,0 +1,9 @@
+# Configuration for uClibc test apps.
+
+# Set the following to `true' to make a debuggable build.
+DODEBUG = true
+
+# If you want to compile using uClibc as a shared library, turn this on.
+DODYNAMIC = true
+
+
Index: unistd/getopt_long.c
===================================================================
--- unistd/getopt_long.c (nonexistent)
+++ unistd/getopt_long.c (revision 1765)
@@ -0,0 +1,93 @@
+/* Getopt tests */
+
+#include
+#include
+#include
+#include
+
+
+int main (int argc, char **argv)
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+ int option_index = 0;
+ static struct option long_options[] =
+ {
+ {"add", 1, 0, 0},
+ {"append", 0, 0, 0},
+ {"delete", 1, 0, 0},
+ {"verbose", 0, 0, 0},
+ {"create", 0, 0, 0},
+ {"file", 1, 0, 0},
+ {0, 0, 0, 0}
+ };
+
+ c = getopt_long (argc, argv, "abc:d:0123456789",
+ long_options, &option_index);
+ if (c == EOF)
+ break;
+
+ switch (c)
+ {
+ case 0:
+ printf ("option %s", long_options[option_index].name);
+ if (optarg)
+ printf (" with arg %s", optarg);
+ printf ("\n");
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case 'd':
+ printf ("option d with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
Index: unistd/fork.c
===================================================================
--- unistd/fork.c (nonexistent)
+++ unistd/fork.c (revision 1765)
@@ -0,0 +1,95 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * fork test for uClibc
+ *
+ * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 2000,2001 by Erik Andersen
+ * Written by Erik Andersen
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#define GOT1 (1 << 1)
+#define GOT2 (1 << 2)
+#define GOT3 (1 << 3)
+
+void child_handler(int sig)
+{
+ fprintf(stderr, "I got a SIGCHLD\n");
+}
+
+int main(void)
+{
+ pid_t pid1, pid2, pid3;
+ int status, result, wpid;
+
+ signal(SIGCHLD, child_handler);
+
+ if ((pid1 = fork()) == 0) {
+ fprintf(stderr, "The child process sleeps 2 seconds...\n");
+ sleep(4);
+ fprintf(stderr, "Child exiting.\n");
+ exit(-1);
+ }
+ if ((pid2 = fork()) == 0) {
+ fprintf(stderr, "The child process sleeps 3 seconds...\n");
+ sleep(3);
+ fprintf(stderr, "Child exiting.\n");
+ exit(-1);
+ }
+ if ((pid3 = fork()) == 0) {
+ fprintf(stderr, "The child process sleeps 4 seconds...\n");
+ sleep(2);
+ fprintf(stderr, "Child exiting.\n");
+ exit(-1);
+ }
+
+ fprintf(stderr, "Parent: waiting for the child to die.\n");
+ status = 0;
+ while (1) {
+ wpid = waitpid(pid1, &result, WNOHANG);
+ if (wpid == pid1)
+ status |= GOT1;
+
+ wpid = waitpid(pid2, &result, WNOHANG);
+ if (wpid == pid2)
+ status |= GOT2;
+
+ wpid = waitpid(pid3, &result, WNOHANG);
+ if (wpid == pid3)
+ status |= GOT3;
+
+ if (status == (GOT1 | GOT2 | GOT3))
+ break;
+ }
+
+ fprintf(stderr, "Child process exited.\nGoodbye.\n");
+ return EXIT_SUCCESS;
+}
+
+/*
+Local Variables:
+c-file-style: "linux"
+c-basic-offset: 4
+tab-width: 4
+End:
+*/
Index: unistd/getopt.c
===================================================================
--- unistd/getopt.c (nonexistent)
+++ unistd/getopt.c (revision 1765)
@@ -0,0 +1,69 @@
+/* Getopt tests */
+
+#include
+#include
+#include
+#include
+
+
+int main (int argc, char **argv)
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+
+ c = getopt (argc, argv, "abc:d:0123456789");
+ if (c == EOF)
+ break;
+
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+ exit (0);
+}
+
Index: unistd/preadwrite.c
===================================================================
--- unistd/preadwrite.c (nonexistent)
+++ unistd/preadwrite.c (revision 1765)
@@ -0,0 +1,150 @@
+/* Tests for pread and pwrite.
+ Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper , 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define _GNU_SOURCE
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define TESTFILE_NAME "CRAP.XXXXXX"
+#define STRINGIFY(s) STRINGIFY2 (s)
+#define STRINGIFY2(s) #s
+
+/* These are for the temporary file we generate. */
+char *name;
+int fd;
+
+
+/* Test the 32-bit versions first. */
+#define PREAD pread
+#define PWRITE pwrite
+
+int test(int argc, char *argv[])
+{
+ char buf[1000];
+ char res[1000];
+ int i;
+
+ memset (buf, '\0', sizeof (buf));
+ memset (res, '\xff', sizeof (res));
+
+ if (write (fd, buf, sizeof (buf)) != sizeof (buf))
+ error (EXIT_FAILURE, errno, "during write");
+
+ for (i = 100; i < 200; ++i)
+ buf[i] = i;
+ if (PWRITE (fd, buf + 100, 100, 100) != 100)
+ error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PWRITE));
+
+ for (i = 450; i < 600; ++i)
+ buf[i] = i;
+ if (PWRITE (fd, buf + 450, 150, 450) != 150)
+ error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PWRITE));
+
+ if (PREAD (fd, res, sizeof (buf) - 50, 50) != sizeof (buf) - 50)
+ error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PREAD));
+
+ close (fd);
+ unlink (name);
+ return memcmp (buf + 50, res, sizeof (buf) - 50);
+}
+
+/* Test the 64-bit versions as well. */
+#if defined __UCLIBC_HAS_LFS__
+
+#undef PREAD
+#undef PWRITE
+#define PREAD pread64
+#define PWRITE pwrite64
+
+
+int test64(int argc, char *argv[])
+{
+ char buf[1000];
+ char res[1000];
+ int i;
+
+ memset (buf, '\0', sizeof (buf));
+ memset (res, '\xff', sizeof (res));
+
+ if (write (fd, buf, sizeof (buf)) != sizeof (buf))
+ error (EXIT_FAILURE, errno, "during write");
+
+ for (i = 100; i < 200; ++i)
+ buf[i] = i;
+ if (PWRITE (fd, buf + 100, 100, 100) != 100)
+ error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PWRITE));
+
+ for (i = 450; i < 600; ++i)
+ buf[i] = i;
+ if (PWRITE (fd, buf + 450, 150, 450) != 150)
+ error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PWRITE));
+
+ if (PREAD (fd, res, sizeof (buf) - 50, 50) != sizeof (buf) - 50)
+ error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PREAD));
+
+ close (fd);
+ unlink (name);
+ return memcmp (buf + 50, res, sizeof (buf) - 50);
+}
+#endif
+
+void prepare(void)
+{
+ if (!name) {
+ name = malloc (BUFSIZ);
+ if (name == NULL)
+ error (EXIT_FAILURE, errno, "cannot allocate file name");
+ }
+ strncpy(name, TESTFILE_NAME, BUFSIZ);
+
+ /* Open our test file. */
+ fd = mkstemp (name);
+ if (fd == -1)
+ error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+}
+
+int main (int argc, char **argv)
+{
+ int result = 0;
+
+ prepare();
+ result+=test(argc, argv);
+ if (result) {
+ fprintf(stderr, "pread/pwrite test failed.\n");
+ return(EXIT_FAILURE);
+ }
+ fprintf(stderr, "pread/pwrite test successful.\n");
+
+#if defined __UCLIBC_HAS_LFS__
+ prepare();
+ result+=test64(argc, argv);
+ if (result) {
+ fprintf(stderr, "pread64/pwrite64 test failed.\n");
+ return(EXIT_FAILURE);
+ }
+ fprintf(stderr, "pread64/pwrite64 test successful.\n");
+#endif
+ return(EXIT_SUCCESS);
+}
Index: unistd/vfork.c
===================================================================
--- unistd/vfork.c (nonexistent)
+++ unistd/vfork.c (revision 1765)
@@ -0,0 +1,68 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * vfork test for uClibc
+ *
+ * Copyright (C) 2000,2001 by Erik Andersen
+ * Written by Erik Andersen
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+
+int main(void)
+{
+ pid_t pid;
+ int status, wpid;
+ char *argv[] = {
+ "/bin/ls",
+ "-laF",
+ NULL,
+ };
+
+ clearenv();
+ if ((pid = vfork()) == 0) {
+ printf("Hi. I'm the child process...\n");
+ execvp(argv[0], argv);
+ _exit(0);
+ }
+
+ printf("Hello. I'm the parent process.\n");
+ while (1) {
+ wpid = wait(&status);
+ if (wpid > 0 && wpid != pid) {
+ continue;
+ }
+ if (wpid == pid)
+ break;
+ }
+
+ printf("Child process exited.\nGoodbye.\n");
+ return EXIT_SUCCESS;
+}
+
+/*
+Local Variables:
+c-file-style: "linux"
+c-basic-offset: 4
+tab-width: 4
+End:
+*/
Index: unistd/Makefile
===================================================================
--- unistd/Makefile (nonexistent)
+++ unistd/Makefile (revision 1765)
@@ -0,0 +1,106 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+
+TARGETS=fork fork_glibc vfork vfork_glibc getcwd getopt getopt_long preadwrite
+all: $(TARGETS)
+
+getcwd: getcwd.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ ./$@
+ -@ echo " "
+
+fork: fork.c ../testsuite.h Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ ./$@
+ -@ echo " "
+
+fork_glibc: fork.c ../testsuite.h Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+vfork: vfork.c ../testsuite.h Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ ./$@
+ -@ echo " "
+
+vfork_glibc: vfork.c ../testsuite.h Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+getopt: getopt.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ ./$@ -abcXXX -9
+ -@ echo " "
+
+getopt_long: getopt_long.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ ./$@ --add XXX --delete YYY --verbose
+ -@ echo " "
+
+preadwrite: preadwrite.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ ./$@
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
+
Index: unistd/getcwd.c
===================================================================
--- unistd/getcwd.c (nonexistent)
+++ unistd/getcwd.c (revision 1765)
@@ -0,0 +1,55 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * fork test for uClibc
+ *
+ * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 2000,2001 by Erik Andersen
+ * Written by Erik Andersen
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include
+#include
+#include
+
+int main(void)
+{
+ char *foo;
+ char junk[12];
+ char crap[100];
+ foo = getcwd(NULL, 0);
+ printf("getcwd(NULL, 0)='%s'\n", foo);
+ if (foo) { free(foo); }
+ foo = getcwd(NULL, 100);
+ printf("\ngetcwd(NULL, 100)='%s'\n", foo);
+ if (foo) { free(foo); }
+ foo = getcwd(junk, sizeof(junk));
+ printf("\nchar junk[12];\n");
+ printf("getcwd(junk, sizeof(junk))='%s'\n", foo);
+ foo = getcwd(crap, sizeof(crap));
+ printf("\nchar crap[100];\n");
+ printf("getcwd(crap, sizeof(crap))='%s'\n", foo);
+ return EXIT_SUCCESS;
+}
+
+/*
+Local Variables:
+c-file-style: "linux"
+c-basic-offset: 4
+tab-width: 4
+End:
+*/
Index: unistd
===================================================================
--- unistd (nonexistent)
+++ unistd (revision 1765)
unistd
Property changes :
Added: svn:ignore
## -0,0 +1,8 ##
+fork
+fork_glibc
+vfork
+vfork_glibc
+getopt
+getopt_long
+getcwd
+preadwrite
Index: string/string.c
===================================================================
--- string/string.c (nonexistent)
+++ string/string.c (revision 1765)
@@ -0,0 +1,1423 @@
+/* Tester for string functions.
+ Copyright (C) 1995-2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+/* Make sure we don't test the optimized inline functions if we want to
+ test the real implementation. */
+#if !defined DO_STRING_INLINES
+#undef __USE_STRING_INLINES
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define STREQ(a, b) (strcmp((a), (b)) == 0)
+
+const char *it = ""; /* Routine name for message routines. */
+size_t errors = 0;
+
+/* Complain if condition is not true. */
+static void
+check (int thing, int number)
+{
+ if (!thing)
+ {
+ printf("%s flunked test %d\n", it, number);
+ ++errors;
+ }
+}
+
+/* Complain if first two args don't strcmp as equal. */
+static void
+equal (const char *a, const char *b, int number)
+{
+ check(a != NULL && b != NULL && STREQ (a, b), number);
+}
+
+char one[50];
+char two[50];
+char *cp;
+
+static void
+test_strcmp (void)
+{
+ it = "strcmp";
+ check (strcmp ("", "") == 0, 1); /* Trivial case. */
+ check (strcmp ("a", "a") == 0, 2); /* Identity. */
+ check (strcmp ("abc", "abc") == 0, 3); /* Multicharacter. */
+ check (strcmp ("abc", "abcd") < 0, 4); /* Length mismatches. */
+ check (strcmp ("abcd", "abc") > 0, 5);
+ check (strcmp ("abcd", "abce") < 0, 6); /* Honest miscompares. */
+ check (strcmp ("abce", "abcd") > 0, 7);
+ check (strcmp ("a\203", "a") > 0, 8); /* Tricky if char signed. */
+ check (strcmp ("a\203", "a\003") > 0, 9);
+
+ {
+ char buf1[0x40], buf2[0x40];
+ int i, j;
+ for (i=0; i < 0x10; i++)
+ for (j = 0; j < 0x10; j++)
+ {
+ int k;
+ for (k = 0; k < 0x3f; k++)
+ {
+ buf1[j] = '0' ^ (k & 4);
+ buf2[j] = '4' ^ (k & 4);
+ }
+ buf1[i] = buf1[0x3f] = 0;
+ buf2[j] = buf2[0x3f] = 0;
+ for (k = 0; k < 0xf; k++)
+ {
+ int cnum = 0x10+0x10*k+0x100*j+0x1000*i;
+ check (strcmp (buf1+i,buf2+j) == 0, cnum);
+ buf1[i+k] = 'A' + i + k;
+ buf1[i+k+1] = 0;
+ check (strcmp (buf1+i,buf2+j) > 0, cnum+1);
+ check (strcmp (buf2+j,buf1+i) < 0, cnum+2);
+ buf2[j+k] = 'B' + i + k;
+ buf2[j+k+1] = 0;
+ check (strcmp (buf1+i,buf2+j) < 0, cnum+3);
+ check (strcmp (buf2+j,buf1+i) > 0, cnum+4);
+ buf2[j+k] = 'A' + i + k;
+ buf1[i] = 'A' + i + 0x80;
+ check (strcmp (buf1+i,buf2+j) > 0, cnum+5);
+ check (strcmp (buf2+j,buf1+i) < 0, cnum+6);
+ buf1[i] = 'A' + i;
+ }
+ }
+ }
+}
+
+#define SIMPLE_COPY(fn, n, str, ntest) \
+ do { \
+ int __n; \
+ char *cp; \
+ for (__n = 0; __n < (int) sizeof (one); ++__n) \
+ one[__n] = 'Z'; \
+ fn (one, str); \
+ for (cp = one, __n = 0; __n < n; ++__n, ++cp) \
+ check (*cp == '0' + (n % 10), ntest); \
+ check (*cp == '\0', ntest); \
+ } while (0)
+
+static void
+test_strcpy (void)
+{
+ int i;
+ it = "strcpy";
+ check (strcpy (one, "abcd") == one, 1); /* Returned value. */
+ equal (one, "abcd", 2); /* Basic test. */
+
+ (void) strcpy (one, "x");
+ equal (one, "x", 3); /* Writeover. */
+ equal (one+2, "cd", 4); /* Wrote too much? */
+
+ (void) strcpy (two, "hi there");
+ (void) strcpy (one, two);
+ equal (one, "hi there", 5); /* Basic test encore. */
+ equal (two, "hi there", 6); /* Stomped on source? */
+
+ (void) strcpy (one, "");
+ equal (one, "", 7); /* Boundary condition. */
+
+ for (i = 0; i < 16; i++)
+ {
+ (void) strcpy (one + i, "hi there"); /* Unaligned destination. */
+ equal (one + i, "hi there", 8 + (i * 2));
+ (void) strcpy (two, one + i); /* Unaligned source. */
+ equal (two, "hi there", 9 + (i * 2));
+ }
+
+ SIMPLE_COPY(strcpy, 0, "", 41);
+ SIMPLE_COPY(strcpy, 1, "1", 42);
+ SIMPLE_COPY(strcpy, 2, "22", 43);
+ SIMPLE_COPY(strcpy, 3, "333", 44);
+ SIMPLE_COPY(strcpy, 4, "4444", 45);
+ SIMPLE_COPY(strcpy, 5, "55555", 46);
+ SIMPLE_COPY(strcpy, 6, "666666", 47);
+ SIMPLE_COPY(strcpy, 7, "7777777", 48);
+ SIMPLE_COPY(strcpy, 8, "88888888", 49);
+ SIMPLE_COPY(strcpy, 9, "999999999", 50);
+ SIMPLE_COPY(strcpy, 10, "0000000000", 51);
+ SIMPLE_COPY(strcpy, 11, "11111111111", 52);
+ SIMPLE_COPY(strcpy, 12, "222222222222", 53);
+ SIMPLE_COPY(strcpy, 13, "3333333333333", 54);
+ SIMPLE_COPY(strcpy, 14, "44444444444444", 55);
+ SIMPLE_COPY(strcpy, 15, "555555555555555", 56);
+ SIMPLE_COPY(strcpy, 16, "6666666666666666", 57);
+}
+
+static void
+test_stpcpy (void)
+{
+ it = "stpcpy";
+ check ((stpcpy (one, "a") - one) == 1, 1);
+ equal (one, "a", 2);
+
+ check ((stpcpy (one, "ab") - one) == 2, 3);
+ equal (one, "ab", 4);
+
+ check ((stpcpy (one, "abc") - one) == 3, 5);
+ equal (one, "abc", 6);
+
+ check ((stpcpy (one, "abcd") - one) == 4, 7);
+ equal (one, "abcd", 8);
+
+ check ((stpcpy (one, "abcde") - one) == 5, 9);
+ equal (one, "abcde", 10);
+
+ check ((stpcpy (one, "abcdef") - one) == 6, 11);
+ equal (one, "abcdef", 12);
+
+ check ((stpcpy (one, "abcdefg") - one) == 7, 13);
+ equal (one, "abcdefg", 14);
+
+ check ((stpcpy (one, "abcdefgh") - one) == 8, 15);
+ equal (one, "abcdefgh", 16);
+
+ check ((stpcpy (one, "abcdefghi") - one) == 9, 17);
+ equal (one, "abcdefghi", 18);
+
+ check ((stpcpy (one, "x") - one) == 1, 19);
+ equal (one, "x", 20); /* Writeover. */
+ equal (one+2, "cdefghi", 21); /* Wrote too much? */
+
+ check ((stpcpy (one, "xx") - one) == 2, 22);
+ equal (one, "xx", 23); /* Writeover. */
+ equal (one+3, "defghi", 24); /* Wrote too much? */
+
+ check ((stpcpy (one, "xxx") - one) == 3, 25);
+ equal (one, "xxx", 26); /* Writeover. */
+ equal (one+4, "efghi", 27); /* Wrote too much? */
+
+ check ((stpcpy (one, "xxxx") - one) == 4, 28);
+ equal (one, "xxxx", 29); /* Writeover. */
+ equal (one+5, "fghi", 30); /* Wrote too much? */
+
+ check ((stpcpy (one, "xxxxx") - one) == 5, 31);
+ equal (one, "xxxxx", 32); /* Writeover. */
+ equal (one+6, "ghi", 33); /* Wrote too much? */
+
+ check ((stpcpy (one, "xxxxxx") - one) == 6, 34);
+ equal (one, "xxxxxx", 35); /* Writeover. */
+ equal (one+7, "hi", 36); /* Wrote too much? */
+
+ check ((stpcpy (one, "xxxxxxx") - one) == 7, 37);
+ equal (one, "xxxxxxx", 38); /* Writeover. */
+ equal (one+8, "i", 39); /* Wrote too much? */
+
+ check ((stpcpy (stpcpy (stpcpy (one, "a"), "b"), "c") - one) == 3, 40);
+ equal (one, "abc", 41);
+ equal (one + 4, "xxx", 42);
+
+ SIMPLE_COPY(stpcpy, 0, "", 43);
+ SIMPLE_COPY(stpcpy, 1, "1", 44);
+ SIMPLE_COPY(stpcpy, 2, "22", 45);
+ SIMPLE_COPY(stpcpy, 3, "333", 46);
+ SIMPLE_COPY(stpcpy, 4, "4444", 47);
+ SIMPLE_COPY(stpcpy, 5, "55555", 48);
+ SIMPLE_COPY(stpcpy, 6, "666666", 49);
+ SIMPLE_COPY(stpcpy, 7, "7777777", 50);
+ SIMPLE_COPY(stpcpy, 8, "88888888", 51);
+ SIMPLE_COPY(stpcpy, 9, "999999999", 52);
+ SIMPLE_COPY(stpcpy, 10, "0000000000", 53);
+ SIMPLE_COPY(stpcpy, 11, "11111111111", 54);
+ SIMPLE_COPY(stpcpy, 12, "222222222222", 55);
+ SIMPLE_COPY(stpcpy, 13, "3333333333333", 56);
+ SIMPLE_COPY(stpcpy, 14, "44444444444444", 57);
+ SIMPLE_COPY(stpcpy, 15, "555555555555555", 58);
+ SIMPLE_COPY(stpcpy, 16, "6666666666666666", 59);
+}
+
+static void
+test_stpncpy (void)
+{
+ it = "stpncpy";
+ memset (one, 'x', sizeof (one));
+ check (stpncpy (one, "abc", 2) == one + 2, 1);
+ check (stpncpy (one, "abc", 3) == one + 3, 2);
+ check (stpncpy (one, "abc", 4) == one + 3, 3);
+ check (one[3] == '\0' && one[4] == 'x', 4);
+ check (stpncpy (one, "abcd", 5) == one + 4, 5);
+ check (one[4] == '\0' && one[5] == 'x', 6);
+ check (stpncpy (one, "abcd", 6) == one + 4, 7);
+ check (one[4] == '\0' && one[5] == '\0' && one[6] == 'x', 8);
+}
+
+static void
+test_strcat (void)
+{
+ it = "strcat";
+ (void) strcpy (one, "ijk");
+ check (strcat (one, "lmn") == one, 1); /* Returned value. */
+ equal (one, "ijklmn", 2); /* Basic test. */
+
+ (void) strcpy (one, "x");
+ (void) strcat (one, "yz");
+ equal (one, "xyz", 3); /* Writeover. */
+ equal (one+4, "mn", 4); /* Wrote too much? */
+
+ (void) strcpy (one, "gh");
+ (void) strcpy (two, "ef");
+ (void) strcat (one, two);
+ equal (one, "ghef", 5); /* Basic test encore. */
+ equal (two, "ef", 6); /* Stomped on source? */
+
+ (void) strcpy (one, "");
+ (void) strcat (one, "");
+ equal (one, "", 7); /* Boundary conditions. */
+ (void) strcpy (one, "ab");
+ (void) strcat (one, "");
+ equal (one, "ab", 8);
+ (void) strcpy (one, "");
+ (void) strcat (one, "cd");
+ equal (one, "cd", 9);
+}
+
+static void
+test_strncat (void)
+{
+ /* First test it as strcat, with big counts, then test the count
+ mechanism. */
+ it = "strncat";
+ (void) strcpy (one, "ijk");
+ check (strncat (one, "lmn", 99) == one, 1); /* Returned value. */
+ equal (one, "ijklmn", 2); /* Basic test. */
+
+ (void) strcpy (one, "x");
+ (void) strncat (one, "yz", 99);
+ equal (one, "xyz", 3); /* Writeover. */
+ equal (one+4, "mn", 4); /* Wrote too much? */
+
+ (void) strcpy (one, "gh");
+ (void) strcpy (two, "ef");
+ (void) strncat (one, two, 99);
+ equal (one, "ghef", 5); /* Basic test encore. */
+ equal (two, "ef", 6); /* Stomped on source? */
+
+ (void) strcpy (one, "");
+ (void) strncat (one, "", 99);
+ equal (one, "", 7); /* Boundary conditions. */
+ (void) strcpy (one, "ab");
+ (void) strncat (one, "", 99);
+ equal (one, "ab", 8);
+ (void) strcpy (one, "");
+ (void) strncat (one, "cd", 99);
+ equal (one, "cd", 9);
+
+ (void) strcpy (one, "ab");
+ (void) strncat (one, "cdef", 2);
+ equal (one, "abcd", 10); /* Count-limited. */
+
+ (void) strncat (one, "gh", 0);
+ equal (one, "abcd", 11); /* Zero count. */
+
+ (void) strncat (one, "gh", 2);
+ equal (one, "abcdgh", 12); /* Count and length equal. */
+}
+
+static void
+test_strncmp (void)
+{
+ /* First test as strcmp with big counts, then test count code. */
+ it = "strncmp";
+ check (strncmp ("", "", 99) == 0, 1); /* Trivial case. */
+ check (strncmp ("a", "a", 99) == 0, 2); /* Identity. */
+ check (strncmp ("abc", "abc", 99) == 0, 3); /* Multicharacter. */
+ check (strncmp ("abc", "abcd", 99) < 0, 4); /* Length unequal. */
+ check (strncmp ("abcd", "abc", 99) > 0, 5);
+ check (strncmp ("abcd", "abce", 99) < 0, 6); /* Honestly unequal. */
+ check (strncmp ("abce", "abcd", 99) > 0, 7);
+ check (strncmp ("a\203", "a", 2) > 0, 8); /* Tricky if '\203' < 0 */
+ check (strncmp ("a\203", "a\003", 2) > 0, 9);
+ check (strncmp ("abce", "abcd", 3) == 0, 10); /* Count limited. */
+ check (strncmp ("abce", "abc", 3) == 0, 11); /* Count == length. */
+ check (strncmp ("abcd", "abce", 4) < 0, 12); /* Nudging limit. */
+ check (strncmp ("abc", "def", 0) == 0, 13); /* Zero count. */
+}
+
+static void
+test_strncpy (void)
+{
+ /* Testing is a bit different because of odd semantics. */
+ it = "strncpy";
+ check (strncpy (one, "abc", 4) == one, 1); /* Returned value. */
+ equal (one, "abc", 2); /* Did the copy go right? */
+
+ (void) strcpy (one, "abcdefgh");
+ (void) strncpy (one, "xyz", 2);
+ equal (one, "xycdefgh", 3); /* Copy cut by count. */
+
+ (void) strcpy (one, "abcdefgh");
+ (void) strncpy (one, "xyz", 3); /* Copy cut just before NUL. */
+ equal (one, "xyzdefgh", 4);
+
+ (void) strcpy (one, "abcdefgh");
+ (void) strncpy (one, "xyz", 4); /* Copy just includes NUL. */
+ equal (one, "xyz", 5);
+ equal (one+4, "efgh", 6); /* Wrote too much? */
+
+ (void) strcpy (one, "abcdefgh");
+ (void) strncpy (one, "xyz", 5); /* Copy includes padding. */
+ equal (one, "xyz", 7);
+ equal (one+4, "", 8);
+ equal (one+5, "fgh", 9);
+
+ (void) strcpy (one, "abc");
+ (void) strncpy (one, "xyz", 0); /* Zero-length copy. */
+ equal (one, "abc", 10);
+
+ (void) strncpy (one, "", 2); /* Zero-length source. */
+ equal (one, "", 11);
+ equal (one+1, "", 12);
+ equal (one+2, "c", 13);
+
+ (void) strcpy (one, "hi there");
+ (void) strncpy (two, one, 9);
+ equal (two, "hi there", 14); /* Just paranoia. */
+ equal (one, "hi there", 15); /* Stomped on source? */
+}
+
+static void
+test_strlen (void)
+{
+ it = "strlen";
+ check (strlen ("") == 0, 1); /* Empty. */
+ check (strlen ("a") == 1, 2); /* Single char. */
+ check (strlen ("abcd") == 4, 3); /* Multiple chars. */
+ {
+ char buf[4096];
+ int i;
+ char *p;
+ for (i=0; i < 0x100; i++)
+ {
+ p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i;
+ strcpy (p, "OK");
+ strcpy (p+3, "BAD/WRONG");
+ check (strlen (p) == 2, 4+i);
+ }
+ }
+}
+
+static void
+test_strchr (void)
+{
+ it = "strchr";
+ check (strchr ("abcd", 'z') == NULL, 1); /* Not found. */
+ (void) strcpy (one, "abcd");
+ check (strchr (one, 'c') == one+2, 2); /* Basic test. */
+ check (strchr (one, 'd') == one+3, 3); /* End of string. */
+ check (strchr (one, 'a') == one, 4); /* Beginning. */
+ check (strchr (one, '\0') == one+4, 5); /* Finding NUL. */
+ (void) strcpy (one, "ababa");
+ check (strchr (one, 'b') == one+1, 6); /* Finding first. */
+ (void) strcpy (one, "");
+ check (strchr (one, 'b') == NULL, 7); /* Empty string. */
+ check (strchr (one, '\0') == one, 8); /* NUL in empty string. */
+ {
+ char buf[4096];
+ int i;
+ char *p;
+ for (i=0; i < 0x100; i++)
+ {
+ p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
+ strcpy (p, "OK");
+ strcpy (p+3, "BAD/WRONG");
+ check (strchr (p, '/') == NULL, 9+i);
+ }
+ }
+}
+
+static void
+test_strchrnul (void)
+{
+ const char *os;
+ it = "strchrnul";
+ cp = strchrnul ((os = "abcd"), 'z');
+ check (*cp == '\0', 1); /* Not found. */
+ check (cp == os + 4, 2);
+ (void) strcpy (one, "abcd");
+ check (strchrnul (one, 'c') == one+2, 3); /* Basic test. */
+ check (strchrnul (one, 'd') == one+3, 4); /* End of string. */
+ check (strchrnul (one, 'a') == one, 5); /* Beginning. */
+ check (strchrnul (one, '\0') == one+4, 6); /* Finding NUL. */
+ (void) strcpy (one, "ababa");
+ check (strchrnul (one, 'b') == one+1, 7); /* Finding first. */
+ (void) strcpy (one, "");
+ check (strchrnul (one, 'b') == one, 8); /* Empty string. */
+ check (strchrnul (one, '\0') == one, 9); /* NUL in empty string. */
+ {
+ char buf[4096];
+ int i;
+ char *p;
+ for (i=0; i < 0x100; i++)
+ {
+ p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
+ strcpy (p, "OK");
+ strcpy (p+3, "BAD/WRONG");
+ cp = strchrnul (p, '/');
+ check (*cp == '\0', 9+2*i);
+ check (cp == p+2, 10+2*i);
+ }
+ }
+}
+
+static void
+test_rawmemchr (void)
+{
+ it = "rawmemchr";
+ (void) strcpy (one, "abcd");
+ check (rawmemchr (one, 'c') == one+2, 1); /* Basic test. */
+ check (rawmemchr (one, 'd') == one+3, 2); /* End of string. */
+ check (rawmemchr (one, 'a') == one, 3); /* Beginning. */
+ check (rawmemchr (one, '\0') == one+4, 4); /* Finding NUL. */
+ (void) strcpy (one, "ababa");
+ check (rawmemchr (one, 'b') == one+1, 5); /* Finding first. */
+ (void) strcpy (one, "");
+ check (rawmemchr (one, '\0') == one, 6); /* NUL in empty string. */
+ {
+ char buf[4096];
+ int i;
+ char *p;
+ for (i=0; i < 0x100; i++)
+ {
+ p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
+ strcpy (p, "OK");
+ strcpy (p+3, "BAD/WRONG");
+ check (rawmemchr (p, 'R') == p+8, 6+i);
+ }
+ }
+}
+
+static void
+test_index (void)
+{
+ it = "index";
+ check (index ("abcd", 'z') == NULL, 1); /* Not found. */
+ (void) strcpy (one, "abcd");
+ check (index (one, 'c') == one+2, 2); /* Basic test. */
+ check (index (one, 'd') == one+3, 3); /* End of string. */
+ check (index (one, 'a') == one, 4); /* Beginning. */
+ check (index (one, '\0') == one+4, 5); /* Finding NUL. */
+ (void) strcpy (one, "ababa");
+ check (index (one, 'b') == one+1, 6); /* Finding first. */
+ (void) strcpy (one, "");
+ check (index (one, 'b') == NULL, 7); /* Empty string. */
+ check (index (one, '\0') == one, 8); /* NUL in empty string. */
+}
+
+static void
+test_strrchr (void)
+{
+ it = "strrchr";
+ check (strrchr ("abcd", 'z') == NULL, 1); /* Not found. */
+ (void) strcpy (one, "abcd");
+ check (strrchr (one, 'c') == one+2, 2); /* Basic test. */
+ check (strrchr (one, 'd') == one+3, 3); /* End of string. */
+ check (strrchr (one, 'a') == one, 4); /* Beginning. */
+ check (strrchr (one, '\0') == one+4, 5); /* Finding NUL. */
+ (void) strcpy (one, "ababa");
+ check (strrchr (one, 'b') == one+3, 6); /* Finding last. */
+ (void) strcpy (one, "");
+ check (strrchr (one, 'b') == NULL, 7); /* Empty string. */
+ check (strrchr (one, '\0') == one, 8); /* NUL in empty string. */
+ {
+ char buf[4096];
+ int i;
+ char *p;
+ for (i=0; i < 0x100; i++)
+ {
+ p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
+ strcpy (p, "OK");
+ strcpy (p+3, "BAD/WRONG");
+ check (strrchr (p, '/') == NULL, 9+i);
+ }
+ }
+}
+
+static void
+test_memrchr (void)
+{
+ size_t l;
+ it = "memrchr";
+ check (memrchr ("abcd", 'z', 5) == NULL, 1); /* Not found. */
+ (void) strcpy (one, "abcd");
+ l = strlen (one) + 1;
+ check (memrchr (one, 'c', l) == one+2, 2); /* Basic test. */
+ check (memrchr (one, 'd', l) == one+3, 3); /* End of string. */
+ check (memrchr (one, 'a', l) == one, 4); /* Beginning. */
+ check (memrchr (one, '\0', l) == one+4, 5); /* Finding NUL. */
+ (void) strcpy (one, "ababa");
+ l = strlen (one) + 1;
+ check (memrchr (one, 'b', l) == one+3, 6); /* Finding last. */
+ (void) strcpy (one, "");
+ l = strlen (one) + 1;
+ check (memrchr (one, 'b', l) == NULL, 7); /* Empty string. */
+ check (memrchr (one, '\0', l) == one, 8); /* NUL in empty string. */
+
+ /* now test all possible alignment and length combinations to catch
+ bugs due to unrolled loops (assuming unrolling is limited to no
+ more than 128 byte chunks: */
+ {
+ char buf[128 + sizeof(long)];
+ long align, len, i, pos;
+
+ for (align = 0; align < (long) sizeof(long); ++align) {
+ for (len = 0; len < (long) (sizeof(buf) - align); ++len) {
+ for (i = 0; i < len; ++i)
+ buf[align + i] = 'x'; /* don't depend on memset... */
+
+ for (pos = len - 1; pos >= 0; --pos) {
+#if 0
+ printf("align %d, len %d, pos %d\n", align, len, pos);
+#endif
+ check(memrchr(buf + align, 'x', len) == buf + align + pos, 9);
+ check(memrchr(buf + align + pos + 1, 'x', len - (pos + 1)) == NULL,
+ 10);
+ buf[align + pos] = '-';
+ }
+ }
+ }
+ }
+}
+
+static void
+test_rindex (void)
+{
+ it = "rindex";
+ check (rindex ("abcd", 'z') == NULL, 1); /* Not found. */
+ (void) strcpy (one, "abcd");
+ check (rindex (one, 'c') == one+2, 2); /* Basic test. */
+ check (rindex (one, 'd') == one+3, 3); /* End of string. */
+ check (rindex (one, 'a') == one, 4); /* Beginning. */
+ check (rindex (one, '\0') == one+4, 5); /* Finding NUL. */
+ (void) strcpy (one, "ababa");
+ check (rindex (one, 'b') == one+3, 6); /* Finding last. */
+ (void) strcpy (one, "");
+ check (rindex (one, 'b') == NULL, 7); /* Empty string. */
+ check (rindex (one, '\0') == one, 8); /* NUL in empty string. */
+}
+
+static void
+test_strpbrk (void)
+{
+ it = "strpbrk";
+ check(strpbrk("abcd", "z") == NULL, 1); /* Not found. */
+ (void) strcpy(one, "abcd");
+ check(strpbrk(one, "c") == one+2, 2); /* Basic test. */
+ check(strpbrk(one, "d") == one+3, 3); /* End of string. */
+ check(strpbrk(one, "a") == one, 4); /* Beginning. */
+ check(strpbrk(one, "") == NULL, 5); /* Empty search list. */
+ check(strpbrk(one, "cb") == one+1, 6); /* Multiple search. */
+ (void) strcpy(one, "abcabdea");
+ check(strpbrk(one, "b") == one+1, 7); /* Finding first. */
+ check(strpbrk(one, "cb") == one+1, 8); /* With multiple search. */
+ check(strpbrk(one, "db") == one+1, 9); /* Another variant. */
+ (void) strcpy(one, "");
+ check(strpbrk(one, "bc") == NULL, 10); /* Empty string. */
+ (void) strcpy(one, "");
+ check(strpbrk(one, "bcd") == NULL, 11); /* Empty string. */
+ (void) strcpy(one, "");
+ check(strpbrk(one, "bcde") == NULL, 12); /* Empty string. */
+ check(strpbrk(one, "") == NULL, 13); /* Both strings empty. */
+ (void) strcpy(one, "abcabdea");
+ check(strpbrk(one, "befg") == one+1, 14); /* Finding first. */
+ check(strpbrk(one, "cbr") == one+1, 15); /* With multiple search. */
+ check(strpbrk(one, "db") == one+1, 16); /* Another variant. */
+ check(strpbrk(one, "efgh") == one+6, 17); /* And yet another. */
+}
+
+static void
+test_strstr (void)
+{
+ it = "strstr";
+ check(strstr("abcd", "z") == NULL, 1); /* Not found. */
+ check(strstr("abcd", "abx") == NULL, 2); /* Dead end. */
+ (void) strcpy(one, "abcd");
+ check(strstr(one, "c") == one+2, 3); /* Basic test. */
+ check(strstr(one, "bc") == one+1, 4); /* Multichar. */
+ check(strstr(one, "d") == one+3, 5); /* End of string. */
+ check(strstr(one, "cd") == one+2, 6); /* Tail of string. */
+ check(strstr(one, "abc") == one, 7); /* Beginning. */
+ check(strstr(one, "abcd") == one, 8); /* Exact match. */
+ check(strstr(one, "abcde") == NULL, 9); /* Too long. */
+ check(strstr(one, "de") == NULL, 10); /* Past end. */
+ check(strstr(one, "") == one, 11); /* Finding empty. */
+ (void) strcpy(one, "ababa");
+ check(strstr(one, "ba") == one+1, 12); /* Finding first. */
+ (void) strcpy(one, "");
+ check(strstr(one, "b") == NULL, 13); /* Empty string. */
+ check(strstr(one, "") == one, 14); /* Empty in empty string. */
+ (void) strcpy(one, "bcbca");
+ check(strstr(one, "bca") == one+2, 15); /* False start. */
+ (void) strcpy(one, "bbbcabbca");
+ check(strstr(one, "bbca") == one+1, 16); /* With overlap. */
+}
+
+static void
+test_strspn (void)
+{
+ it = "strspn";
+ check(strspn("abcba", "abc") == 5, 1); /* Whole string. */
+ check(strspn("abcba", "ab") == 2, 2); /* Partial. */
+ check(strspn("abc", "qx") == 0, 3); /* None. */
+ check(strspn("", "ab") == 0, 4); /* Null string. */
+ check(strspn("abc", "") == 0, 5); /* Null search list. */
+}
+
+static void
+test_strcspn (void)
+{
+ it = "strcspn";
+ check(strcspn("abcba", "qx") == 5, 1); /* Whole string. */
+ check(strcspn("abcba", "cx") == 2, 2); /* Partial. */
+ check(strcspn("abc", "abc") == 0, 3); /* None. */
+ check(strcspn("", "ab") == 0, 4); /* Null string. */
+ check(strcspn("abc", "") == 3, 5); /* Null search list. */
+}
+
+static void
+test_strtok (void)
+{
+ it = "strtok";
+ (void) strcpy(one, "first, second, third");
+ equal(strtok(one, ", "), "first", 1); /* Basic test. */
+ equal(one, "first", 2);
+ equal(strtok((char *)NULL, ", "), "second", 3);
+ equal(strtok((char *)NULL, ", "), "third", 4);
+ check(strtok((char *)NULL, ", ") == NULL, 5);
+ (void) strcpy(one, ", first, ");
+ equal(strtok(one, ", "), "first", 6); /* Extra delims, 1 tok. */
+ check(strtok((char *)NULL, ", ") == NULL, 7);
+ (void) strcpy(one, "1a, 1b; 2a, 2b");
+ equal(strtok(one, ", "), "1a", 8); /* Changing delim lists. */
+ equal(strtok((char *)NULL, "; "), "1b", 9);
+ equal(strtok((char *)NULL, ", "), "2a", 10);
+ (void) strcpy(two, "x-y");
+ equal(strtok(two, "-"), "x", 11); /* New string before done. */
+ equal(strtok((char *)NULL, "-"), "y", 12);
+ check(strtok((char *)NULL, "-") == NULL, 13);
+ (void) strcpy(one, "a,b, c,, ,d");
+ equal(strtok(one, ", "), "a", 14); /* Different separators. */
+ equal(strtok((char *)NULL, ", "), "b", 15);
+ equal(strtok((char *)NULL, " ,"), "c", 16); /* Permute list too. */
+ equal(strtok((char *)NULL, " ,"), "d", 17);
+ check(strtok((char *)NULL, ", ") == NULL, 18);
+ check(strtok((char *)NULL, ", ") == NULL, 19); /* Persistence. */
+ (void) strcpy(one, ", ");
+ check(strtok(one, ", ") == NULL, 20); /* No tokens. */
+ (void) strcpy(one, "");
+ check(strtok(one, ", ") == NULL, 21); /* Empty string. */
+ (void) strcpy(one, "abc");
+ equal(strtok(one, ", "), "abc", 22); /* No delimiters. */
+ check(strtok((char *)NULL, ", ") == NULL, 23);
+ (void) strcpy(one, "abc");
+ equal(strtok(one, ""), "abc", 24); /* Empty delimiter list. */
+ check(strtok((char *)NULL, "") == NULL, 25);
+ (void) strcpy(one, "abcdefgh");
+ (void) strcpy(one, "a,b,c");
+ equal(strtok(one, ","), "a", 26); /* Basics again... */
+ equal(strtok((char *)NULL, ","), "b", 27);
+ equal(strtok((char *)NULL, ","), "c", 28);
+ check(strtok((char *)NULL, ",") == NULL, 29);
+ equal(one+6, "gh", 30); /* Stomped past end? */
+ equal(one, "a", 31); /* Stomped old tokens? */
+ equal(one+2, "b", 32);
+ equal(one+4, "c", 33);
+}
+
+static void
+test_strtok_r (void)
+{
+ it = "strtok_r";
+ (void) strcpy(one, "first, second, third");
+ cp = NULL; /* Always initialize cp to make sure it doesn't point to some old data. */
+ equal(strtok_r(one, ", ", &cp), "first", 1); /* Basic test. */
+ equal(one, "first", 2);
+ equal(strtok_r((char *)NULL, ", ", &cp), "second", 3);
+ equal(strtok_r((char *)NULL, ", ", &cp), "third", 4);
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 5);
+ (void) strcpy(one, ", first, ");
+ cp = NULL;
+ equal(strtok_r(one, ", ", &cp), "first", 6); /* Extra delims, 1 tok. */
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 7);
+ (void) strcpy(one, "1a, 1b; 2a, 2b");
+ cp = NULL;
+ equal(strtok_r(one, ", ", &cp), "1a", 8); /* Changing delim lists. */
+ equal(strtok_r((char *)NULL, "; ", &cp), "1b", 9);
+ equal(strtok_r((char *)NULL, ", ", &cp), "2a", 10);
+ (void) strcpy(two, "x-y");
+ cp = NULL;
+ equal(strtok_r(two, "-", &cp), "x", 11); /* New string before done. */
+ equal(strtok_r((char *)NULL, "-", &cp), "y", 12);
+ check(strtok_r((char *)NULL, "-", &cp) == NULL, 13);
+ (void) strcpy(one, "a,b, c,, ,d");
+ cp = NULL;
+ equal(strtok_r(one, ", ", &cp), "a", 14); /* Different separators. */
+ equal(strtok_r((char *)NULL, ", ", &cp), "b", 15);
+ equal(strtok_r((char *)NULL, " ,", &cp), "c", 16); /* Permute list too. */
+ equal(strtok_r((char *)NULL, " ,", &cp), "d", 17);
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 18);
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 19); /* Persistence. */
+ (void) strcpy(one, ", ");
+ cp = NULL;
+ check(strtok_r(one, ", ", &cp) == NULL, 20); /* No tokens. */
+ (void) strcpy(one, "");
+ cp = NULL;
+ check(strtok_r(one, ", ", &cp) == NULL, 21); /* Empty string. */
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 22); /* Persistence. */
+ (void) strcpy(one, "abc");
+ cp = NULL;
+ equal(strtok_r(one, ", ", &cp), "abc", 23); /* No delimiters. */
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 24);
+ (void) strcpy(one, "abc");
+ cp = NULL;
+ equal(strtok_r(one, "", &cp), "abc", 25); /* Empty delimiter list. */
+ check(strtok_r((char *)NULL, "", &cp) == NULL, 26);
+ (void) strcpy(one, "abcdefgh");
+ (void) strcpy(one, "a,b,c");
+ cp = NULL;
+ equal(strtok_r(one, ",", &cp), "a", 27); /* Basics again... */
+ equal(strtok_r((char *)NULL, ",", &cp), "b", 28);
+ equal(strtok_r((char *)NULL, ",", &cp), "c", 29);
+ check(strtok_r((char *)NULL, ",", &cp) == NULL, 30);
+ equal(one+6, "gh", 31); /* Stomped past end? */
+ equal(one, "a", 32); /* Stomped old tokens? */
+ equal(one+2, "b", 33);
+ equal(one+4, "c", 34);
+}
+
+static void
+test_strsep (void)
+{
+ char *ptr;
+ it = "strsep";
+ cp = strcpy(one, "first, second, third");
+ equal(strsep(&cp, ", "), "first", 1); /* Basic test. */
+ equal(one, "first", 2);
+ equal(strsep(&cp, ", "), "", 3);
+ equal(strsep(&cp, ", "), "second", 4);
+ equal(strsep(&cp, ", "), "", 5);
+ equal(strsep(&cp, ", "), "third", 6);
+ check(strsep(&cp, ", ") == NULL, 7);
+ cp = strcpy(one, ", first, ");
+ equal(strsep(&cp, ", "), "", 8);
+ equal(strsep(&cp, ", "), "", 9);
+ equal(strsep(&cp, ", "), "first", 10); /* Extra delims, 1 tok. */
+ equal(strsep(&cp, ", "), "", 11);
+ equal(strsep(&cp, ", "), "", 12);
+ check(strsep(&cp, ", ") == NULL, 13);
+ cp = strcpy(one, "1a, 1b; 2a, 2b");
+ equal(strsep(&cp, ", "), "1a", 14); /* Changing delim lists. */
+ equal(strsep(&cp, ", "), "", 15);
+ equal(strsep(&cp, "; "), "1b", 16);
+ equal(strsep(&cp, ", "), "", 17);
+ equal(strsep(&cp, ", "), "2a", 18);
+ cp = strcpy(two, "x-y");
+ equal(strsep(&cp, "-"), "x", 19); /* New string before done. */
+ equal(strsep(&cp, "-"), "y", 20);
+ check(strsep(&cp, "-") == NULL, 21);
+ cp = strcpy(one, "a,b, c,, ,d ");
+ equal(strsep(&cp, ", "), "a", 22); /* Different separators. */
+ equal(strsep(&cp, ", "), "b", 23);
+ equal(strsep(&cp, " ,"), "", 24);
+ equal(strsep(&cp, " ,"), "c", 25); /* Permute list too. */
+ equal(strsep(&cp, " ,"), "", 26);
+ equal(strsep(&cp, " ,"), "", 27);
+ equal(strsep(&cp, " ,"), "", 28);
+ equal(strsep(&cp, " ,"), "d", 29);
+ equal(strsep(&cp, " ,"), "", 30);
+ check(strsep(&cp, ", ") == NULL, 31);
+ check(strsep(&cp, ", ") == NULL, 32); /* Persistence. */
+ cp = strcpy(one, ", ");
+ equal(strsep(&cp, ", "), "", 33);
+ equal(strsep(&cp, ", "), "", 34);
+ equal(strsep(&cp, ", "), "", 35);
+ check(strsep(&cp, ", ") == NULL, 36); /* No tokens. */
+ cp = strcpy(one, "");
+ equal(strsep(&cp, ", "), "", 37);
+ check(strsep(&cp, ", ") == NULL, 38); /* Empty string. */
+ cp = strcpy(one, "abc");
+ equal(strsep(&cp, ", "), "abc", 39); /* No delimiters. */
+ check(strsep(&cp, ", ") == NULL, 40);
+ cp = strcpy(one, "abc");
+ equal(strsep(&cp, ""), "abc", 41); /* Empty delimiter list. */
+ check(strsep(&cp, "") == NULL, 42);
+ (void) strcpy(one, "abcdefgh");
+ cp = strcpy(one, "a,b,c");
+ equal(strsep(&cp, ","), "a", 43); /* Basics again... */
+ equal(strsep(&cp, ","), "b", 44);
+ equal(strsep(&cp, ","), "c", 45);
+ check(strsep(&cp, ",") == NULL, 46);
+ equal(one+6, "gh", 47); /* Stomped past end? */
+ equal(one, "a", 48); /* Stomped old tokens? */
+ equal(one+2, "b", 49);
+ equal(one+4, "c", 50);
+
+ {
+ char text[] = "This,is,a,test";
+ char *list = strdupa (text);
+ equal (strsep (&list, ","), "This", 51);
+ equal (strsep (&list, ","), "is", 52);
+ equal (strsep (&list, ","), "a", 53);
+ equal (strsep (&list, ","), "test", 54);
+ check (strsep (&list, ",") == NULL, 55);
+ }
+
+ cp = strcpy(one, "a,b, c,, ,d,");
+ equal(strsep(&cp, ","), "a", 56); /* Different separators. */
+ equal(strsep(&cp, ","), "b", 57);
+ equal(strsep(&cp, ","), " c", 58); /* Permute list too. */
+ equal(strsep(&cp, ","), "", 59);
+ equal(strsep(&cp, ","), " ", 60);
+ equal(strsep(&cp, ","), "d", 61);
+ equal(strsep(&cp, ","), "", 62);
+ check(strsep(&cp, ",") == NULL, 63);
+ check(strsep(&cp, ",") == NULL, 64); /* Persistence. */
+
+ cp = strcpy(one, "a,b, c,, ,d,");
+ equal(strsep(&cp, "xy,"), "a", 65); /* Different separators. */
+ equal(strsep(&cp, "x,y"), "b", 66);
+ equal(strsep(&cp, ",xy"), " c", 67); /* Permute list too. */
+ equal(strsep(&cp, "xy,"), "", 68);
+ equal(strsep(&cp, "x,y"), " ", 69);
+ equal(strsep(&cp, ",xy"), "d", 70);
+ equal(strsep(&cp, "xy,"), "", 71);
+ check(strsep(&cp, "x,y") == NULL, 72);
+ check(strsep(&cp, ",xy") == NULL, 73); /* Persistence. */
+
+ cp = strcpy(one, "ABC");
+ one[4] = ':';
+ equal(strsep(&cp, "C"), "AB", 74); /* Access beyond NUL. */
+ ptr = strsep(&cp, ":");
+ equal(ptr, "", 75);
+ check(ptr == one + 3, 76);
+ check(cp == NULL, 77);
+
+ cp = strcpy(one, "ABC");
+ one[4] = ':';
+ equal(strsep(&cp, "CD"), "AB", 78); /* Access beyond NUL. */
+ ptr = strsep(&cp, ":.");
+ equal(ptr, "", 79);
+ check(ptr == one + 3, 80);
+
+ cp = strcpy(one, "ABC"); /* No token in string. */
+ equal(strsep(&cp, ","), "ABC", 81);
+ check(cp == NULL, 82);
+
+ *one = '\0'; /* Empty string. */
+ cp = one;
+ ptr = strsep(&cp, ",");
+ equal(ptr, "", 83);
+ check(ptr == one, 84);
+ check(cp == NULL, 85);
+
+ *one = '\0'; /* Empty string and no token. */
+ cp = one;
+ ptr = strsep(&cp, "");
+ equal(ptr, "", 86);
+ check(ptr == one , 87);
+ check(cp == NULL, 88);
+}
+
+static void
+test_memcmp (void)
+{
+ it = "memcmp";
+ check(memcmp("a", "a", 1) == 0, 1); /* Identity. */
+ check(memcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */
+ check(memcmp("abcd", "abce", 4) < 0, 3); /* Honestly unequal. */
+ check(memcmp("abce", "abcd", 4) > 0, 4);
+ check(memcmp("alph", "beta", 4) < 0, 5);
+ check(memcmp("a\203", "a\003", 2) > 0, 6);
+ check(memcmp("abce", "abcd", 3) == 0, 7); /* Count limited. */
+ check(memcmp("abc", "def", 0) == 0, 8); /* Zero count. */
+}
+
+static void
+test_memchr (void)
+{
+ it = "memchr";
+ check(memchr("abcd", 'z', 4) == NULL, 1); /* Not found. */
+ (void) strcpy(one, "abcd");
+ check(memchr(one, 'c', 4) == one+2, 2); /* Basic test. */
+ check(memchr(one, ~0xff|'c', 4) == one+2, 2); /* ignore highorder bits. */
+ check(memchr(one, 'd', 4) == one+3, 3); /* End of string. */
+ check(memchr(one, 'a', 4) == one, 4); /* Beginning. */
+ check(memchr(one, '\0', 5) == one+4, 5); /* Finding NUL. */
+ (void) strcpy(one, "ababa");
+ check(memchr(one, 'b', 5) == one+1, 6); /* Finding first. */
+ check(memchr(one, 'b', 0) == NULL, 7); /* Zero count. */
+ check(memchr(one, 'a', 1) == one, 8); /* Singleton case. */
+ (void) strcpy(one, "a\203b");
+ check(memchr(one, 0203, 3) == one+1, 9); /* Unsignedness. */
+
+ /* now test all possible alignment and length combinations to catch
+ bugs due to unrolled loops (assuming unrolling is limited to no
+ more than 128 byte chunks: */
+ {
+ char buf[128 + sizeof(long)];
+ long align, len, i, pos;
+
+ for (align = 0; align < (long) sizeof(long); ++align) {
+ for (len = 0; len < (long) (sizeof(buf) - align); ++len) {
+ for (i = 0; i < len; ++i) {
+ buf[align + i] = 'x'; /* don't depend on memset... */
+ }
+ for (pos = 0; pos < len; ++pos) {
+#if 0
+ printf("align %d, len %d, pos %d\n", align, len, pos);
+#endif
+ check(memchr(buf + align, 'x', len) == buf + align + pos, 10);
+ check(memchr(buf + align, 'x', pos) == NULL, 11);
+ buf[align + pos] = '-';
+ }
+ }
+ }
+ }
+}
+
+static void
+test_memcpy (void)
+{
+ int i;
+ it = "memcpy";
+ check(memcpy(one, "abc", 4) == one, 1); /* Returned value. */
+ equal(one, "abc", 2); /* Did the copy go right? */
+
+ (void) strcpy(one, "abcdefgh");
+ (void) memcpy(one+1, "xyz", 2);
+ equal(one, "axydefgh", 3); /* Basic test. */
+
+ (void) strcpy(one, "abc");
+ (void) memcpy(one, "xyz", 0);
+ equal(one, "abc", 4); /* Zero-length copy. */
+
+ (void) strcpy(one, "hi there");
+ (void) strcpy(two, "foo");
+ (void) memcpy(two, one, 9);
+ equal(two, "hi there", 5); /* Just paranoia. */
+ equal(one, "hi there", 6); /* Stomped on source? */
+
+ for (i = 0; i < 16; i++)
+ {
+ const char *x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+ strcpy (one, x);
+ check (memcpy (one + i, "hi there", 9) == one + i,
+ 7 + (i * 6)); /* Unaligned destination. */
+ check (memcmp (one, x, i) == 0, 8 + (i * 6)); /* Wrote under? */
+ equal (one + i, "hi there", 9 + (i * 6));
+ check (one[i + 9] == 'x', 10 + (i * 6)); /* Wrote over? */
+ check (memcpy (two, one + i, 9) == two,
+ 11 + (i * 6)); /* Unaligned source. */
+ equal (two, "hi there", 12 + (i * 6));
+ }
+}
+
+static void
+test_mempcpy (void)
+{
+ int i;
+ it = "mempcpy";
+ check(mempcpy(one, "abc", 4) == one + 4, 1); /* Returned value. */
+ equal(one, "abc", 2); /* Did the copy go right? */
+
+ (void) strcpy(one, "abcdefgh");
+ (void) mempcpy(one+1, "xyz", 2);
+ equal(one, "axydefgh", 3); /* Basic test. */
+
+ (void) strcpy(one, "abc");
+ (void) mempcpy(one, "xyz", 0);
+ equal(one, "abc", 4); /* Zero-length copy. */
+
+ (void) strcpy(one, "hi there");
+ (void) strcpy(two, "foo");
+ (void) mempcpy(two, one, 9);
+ equal(two, "hi there", 5); /* Just paranoia. */
+ equal(one, "hi there", 6); /* Stomped on source? */
+
+ for (i = 0; i < 16; i++)
+ {
+ const char *x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+ strcpy (one, x);
+ check (mempcpy (one + i, "hi there", 9) == one + i + 9,
+ 7 + (i * 6)); /* Unaligned destination. */
+ check (memcmp (one, x, i) == 0, 8 + (i * 6)); /* Wrote under? */
+ equal (one + i, "hi there", 9 + (i * 6));
+ check (one[i + 9] == 'x', 10 + (i * 6)); /* Wrote over? */
+ check (mempcpy (two, one + i, 9) == two + 9,
+ 11 + (i * 6)); /* Unaligned source. */
+ equal (two, "hi there", 12 + (i * 6));
+ }
+}
+
+static void
+test_memmove (void)
+{
+ it = "memmove";
+ check(memmove(one, "abc", 4) == one, 1); /* Returned value. */
+ equal(one, "abc", 2); /* Did the copy go right? */
+
+ (void) strcpy(one, "abcdefgh");
+ (void) memmove(one+1, "xyz", 2);
+ equal(one, "axydefgh", 3); /* Basic test. */
+
+ (void) strcpy(one, "abc");
+ (void) memmove(one, "xyz", 0);
+ equal(one, "abc", 4); /* Zero-length copy. */
+
+ (void) strcpy(one, "hi there");
+ (void) strcpy(two, "foo");
+ (void) memmove(two, one, 9);
+ equal(two, "hi there", 5); /* Just paranoia. */
+ equal(one, "hi there", 6); /* Stomped on source? */
+
+ (void) strcpy(one, "abcdefgh");
+ (void) memmove(one+1, one, 9);
+ equal(one, "aabcdefgh", 7); /* Overlap, right-to-left. */
+
+ (void) strcpy(one, "abcdefgh");
+ (void) memmove(one+1, one+2, 7);
+ equal(one, "acdefgh", 8); /* Overlap, left-to-right. */
+
+ (void) strcpy(one, "abcdefgh");
+ (void) memmove(one, one, 9);
+ equal(one, "abcdefgh", 9); /* 100% overlap. */
+}
+
+static void
+test_memccpy (void)
+{
+ /* First test like memcpy, then the search part The SVID, the only
+ place where memccpy is mentioned, says overlap might fail, so we
+ don't try it. Besides, it's hard to see the rationale for a
+ non-left-to-right memccpy. */
+ it = "memccpy";
+ check(memccpy(one, "abc", 'q', 4) == NULL, 1); /* Returned value. */
+ equal(one, "abc", 2); /* Did the copy go right? */
+
+ (void) strcpy(one, "abcdefgh");
+ (void) memccpy(one+1, "xyz", 'q', 2);
+ equal(one, "axydefgh", 3); /* Basic test. */
+
+ (void) strcpy(one, "abc");
+ (void) memccpy(one, "xyz", 'q', 0);
+ equal(one, "abc", 4); /* Zero-length copy. */
+
+ (void) strcpy(one, "hi there");
+ (void) strcpy(two, "foo");
+ (void) memccpy(two, one, 'q', 9);
+ equal(two, "hi there", 5); /* Just paranoia. */
+ equal(one, "hi there", 6); /* Stomped on source? */
+
+ (void) strcpy(one, "abcdefgh");
+ (void) strcpy(two, "horsefeathers");
+ check(memccpy(two, one, 'f', 9) == two+6, 7); /* Returned value. */
+ equal(one, "abcdefgh", 8); /* Source intact? */
+ equal(two, "abcdefeathers", 9); /* Copy correct? */
+
+ (void) strcpy(one, "abcd");
+ (void) strcpy(two, "bumblebee");
+ check(memccpy(two, one, 'a', 4) == two+1, 10); /* First char. */
+ equal(two, "aumblebee", 11);
+ check(memccpy(two, one, 'd', 4) == two+4, 12); /* Last char. */
+ equal(two, "abcdlebee", 13);
+ (void) strcpy(one, "xyz");
+ check(memccpy(two, one, 'x', 1) == two+1, 14); /* Singleton. */
+ equal(two, "xbcdlebee", 15);
+}
+
+static void
+test_memset (void)
+{
+ int i;
+
+ it = "memset";
+ (void) strcpy(one, "abcdefgh");
+ check(memset(one+1, 'x', 3) == one+1, 1); /* Return value. */
+ equal(one, "axxxefgh", 2); /* Basic test. */
+
+ (void) memset(one+2, 'y', 0);
+ equal(one, "axxxefgh", 3); /* Zero-length set. */
+
+ (void) memset(one+5, 0, 1);
+ equal(one, "axxxe", 4); /* Zero fill. */
+ equal(one+6, "gh", 5); /* And the leftover. */
+
+ (void) memset(one+2, 010045, 1);
+ equal(one, "ax\045xe", 6); /* Unsigned char convert. */
+
+ /* Non-8bit fill character. */
+ memset (one, 0x101, sizeof (one));
+ for (i = 0; i < (int) sizeof (one); ++i)
+ check (one[i] == '\01', 7);
+
+ /* Test for more complex versions of memset, for all alignments and
+ lengths up to 256. This test takes a little while, perhaps it should
+ be made weaker? */
+ {
+ char data[512];
+ int j;
+ int k;
+ int c;
+
+ for (i = 0; i < 512; i++)
+ data[i] = 'x';
+ for (c = 0; c <= 'y'; c += 'y') /* check for memset(,0,) and
+ memset(,'y',) */
+ for (j = 0; j < 256; j++)
+ for (i = 0; i < 256; i++)
+ {
+ memset (data + i, c, j);
+ for (k = 0; k < i; k++)
+ if (data[k] != 'x')
+ goto fail;
+ for (k = i; k < i+j; k++)
+ {
+ if (data[k] != c)
+ goto fail;
+ data[k] = 'x';
+ }
+ for (k = i+j; k < 512; k++)
+ if (data[k] != 'x')
+ goto fail;
+ continue;
+
+ fail:
+ check (0, 8 + i + j * 256 + (c != 0) * 256 * 256);
+ }
+ }
+}
+
+static void
+test_bcopy (void)
+{
+ /* Much like memcpy. Berklix manual is silent about overlap, so
+ don't test it. */
+ it = "bcopy";
+ (void) bcopy("abc", one, 4);
+ equal(one, "abc", 1); /* Simple copy. */
+
+ (void) strcpy(one, "abcdefgh");
+ (void) bcopy("xyz", one+1, 2);
+ equal(one, "axydefgh", 2); /* Basic test. */
+
+ (void) strcpy(one, "abc");
+ (void) bcopy("xyz", one, 0);
+ equal(one, "abc", 3); /* Zero-length copy. */
+
+ (void) strcpy(one, "hi there");
+ (void) strcpy(two, "foo");
+ (void) bcopy(one, two, 9);
+ equal(two, "hi there", 4); /* Just paranoia. */
+ equal(one, "hi there", 5); /* Stomped on source? */
+}
+
+static void
+test_bzero (void)
+{
+ it = "bzero";
+ (void) strcpy(one, "abcdef");
+ bzero(one+2, 2);
+ equal(one, "ab", 1); /* Basic test. */
+ equal(one+3, "", 2);
+ equal(one+4, "ef", 3);
+
+ (void) strcpy(one, "abcdef");
+ bzero(one+2, 0);
+ equal(one, "abcdef", 4); /* Zero-length copy. */
+}
+
+static void
+test_strndup (void)
+{
+ char *p, *q;
+ it = "strndup";
+ p = strndup("abcdef", 12);
+ check(p != NULL, 1);
+ if (p != NULL)
+ {
+ equal(p, "abcdef", 2);
+ q = strndup(p + 1, 2);
+ check(q != NULL, 3);
+ if (q != NULL)
+ equal(q, "bc", 4);
+ free (q);
+ }
+ free (p);
+ p = strndup("abc def", 3);
+ check(p != NULL, 5);
+ if (p != NULL)
+ equal(p, "abc", 6);
+ free (p);
+}
+
+static void
+test_bcmp (void)
+{
+ it = "bcmp";
+ check(bcmp("a", "a", 1) == 0, 1); /* Identity. */
+ check(bcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */
+ check(bcmp("abcd", "abce", 4) != 0, 3); /* Honestly unequal. */
+ check(bcmp("abce", "abcd", 4) != 0, 4);
+ check(bcmp("alph", "beta", 4) != 0, 5);
+ check(bcmp("abce", "abcd", 3) == 0, 6); /* Count limited. */
+ check(bcmp("abc", "def", 0) == 0, 8); /* Zero count. */
+}
+
+static void
+test_strerror (void)
+{
+ it = "strerror";
+ check(strerror(EDOM) != 0, 1);
+ check(strerror(ERANGE) != 0, 2);
+ check(strerror(ENOENT) != 0, 3);
+}
+
+int
+main (void)
+{
+ int status;
+
+ /* Test strcmp first because we use it to test other things. */
+ test_strcmp ();
+
+ /* Test strcpy next because we need it to set up other tests. */
+ test_strcpy ();
+
+ /* A closely related function is stpcpy. */
+ test_stpcpy ();
+
+ /* stpncpy. */
+ test_stpncpy ();
+
+ /* strcat. */
+ test_strcat ();
+
+ /* strncat. */
+ test_strncat ();
+
+ /* strncmp. */
+ test_strncmp ();
+
+ /* strncpy. */
+ test_strncpy ();
+
+ /* strlen. */
+ test_strlen ();
+
+ /* strchr. */
+ test_strchr ();
+
+ /* strchrnul. */
+ test_strchrnul ();
+
+ /* rawmemchr. */
+ test_rawmemchr ();
+
+ /* index - just like strchr. */
+ test_index ();
+
+ /* strrchr. */
+ test_strrchr ();
+
+ /* memrchr. */
+ test_memrchr ();
+
+ /* rindex - just like strrchr. */
+ test_rindex ();
+
+ /* strpbrk - somewhat like strchr. */
+ test_strpbrk ();
+
+ /* strstr - somewhat like strchr. */
+ test_strstr ();
+
+ /* strspn. */
+ test_strspn ();
+
+ /* strcspn. */
+ test_strcspn ();
+
+ /* strtok - the hard one. */
+ test_strtok ();
+
+ /* strtok_r. */
+ test_strtok_r ();
+
+ /* strsep. */
+ test_strsep ();
+
+ /* memcmp. */
+ test_memcmp ();
+
+ /* memchr. */
+ test_memchr ();
+
+ /* memcpy - need not work for overlap. */
+ test_memcpy ();
+
+ /* memmove - must work on overlap. */
+ test_memmove ();
+
+ /* mempcpy */
+ test_mempcpy ();
+
+ /* memccpy. */
+ test_memccpy ();
+
+ /* memset. */
+ test_memset ();
+
+ /* bcopy. */
+ test_bcopy ();
+
+ /* bzero. */
+ test_bzero ();
+
+ /* bcmp - somewhat like memcmp. */
+ test_bcmp ();
+
+ /* strndup. */
+ test_strndup ();
+
+ /* strerror - VERY system-dependent. */
+ test_strerror ();
+
+
+ if (errors == 0)
+ {
+ status = EXIT_SUCCESS;
+ puts("No errors.");
+ }
+ else
+ {
+ status = EXIT_FAILURE;
+ printf("%d errors.\n", errors);
+ }
+
+ return status;
+}
Index: string/testcopy.c
===================================================================
--- string/testcopy.c (nonexistent)
+++ string/testcopy.c (revision 1765)
@@ -0,0 +1,108 @@
+/* Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include
+#include
+#include
+#include
+
+int main(int argc, char **argv)
+{
+ char *mem, *memp;
+ char *rand_mem;
+ char *lo_around, *hi_around;
+ int size, max_size;
+ int src_off, dst_off;
+ int i;
+ int space_around = 10;
+
+ max_size = 256;
+
+ mem = malloc (max_size + 2 * max_size + 2 * space_around);
+ rand_mem = malloc (max_size);
+ lo_around = malloc (space_around);
+ hi_around = malloc (space_around);
+ memp = mem + space_around;
+
+ /* Fill RAND_MEM with random bytes, each non-zero. */
+ for (i = 0; i < max_size; i++)
+ {
+ int x;
+ do
+ x = rand ();
+ while (x == 0);
+ rand_mem[i] = x;
+ }
+
+ for (size = 0; size < max_size; size++)
+ {
+ printf("phase %d\n", size);
+ for (src_off = 0; src_off <= 16; src_off++)
+ {
+ for (dst_off = 0; dst_off <= 16; dst_off++)
+ {
+ /* Put zero around the intended destination, to check
+ that it's not clobbered. */
+ for (i = 1; i < space_around; i++)
+ {
+ memp[dst_off - i] = 0;
+ memp[dst_off + size - 1 + i] = 0;
+ }
+
+ /* Fill the source area with known contents. */
+ for (i = 0; i < size; i++)
+ memp[src_off + i] = rand_mem[i];
+
+ /* Remember the contents around the destination area.
+ (It might not be what we wrote some lines above, since
+ the src area and the dst area overlap.) */
+ for (i = 1; i < space_around; i++)
+ {
+ lo_around[i] = memp[dst_off - i];
+ hi_around[i] = memp[dst_off + size - 1 + i];
+ }
+
+ memmove (memp + dst_off, memp + src_off, size);
+
+ /* Check that the destination area has the same
+ contents we wrote to the source area. */
+ for (i = 0; i < size; i++)
+ {
+ if (memp[dst_off + i] != rand_mem[i])
+ abort ();
+ }
+
+ /* Check that the area around the destination is not
+ clobbered. */
+ for (i = 1; i < space_around; i++)
+ {
+ if (memp[dst_off - i] != lo_around[i])
+ abort ();
+ if (memp[dst_off + size - 1 + i] != hi_around[i])
+ abort ();
+ }
+ }
+ }
+ }
+
+ puts ("Test succeeded.");
+
+ return 0;
+}
Index: string/Makefile
===================================================================
--- string/Makefile (nonexistent)
+++ string/Makefile (revision 1765)
@@ -0,0 +1,108 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+TARGETS=string string_glibc
+TARGETS+=testcopy testcopy_glibc
+TARGETS+=#strerror #strsignal
+
+all: $(TARGETS)
+
+string: string.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+string_glibc: string.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+testcopy: testcopy.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ > testcopy.out
+ -@ echo " "
+
+testcopy_glibc: testcopy.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ > testcopy.gnu.out
+ -@ echo " "
+
+testcopy_diff: testcopy testcopy_glibc
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing output: "
+ -@ echo " "
+ -diff -u testcopy.gnu.out testcopy.out
+ -@ echo " "
+
+
+strerror: ../../libc/string/strerror.c $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -DCHECK_BUF -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+strsignal: ../../libc/string/strsignal.c
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -DCHECK_BUF -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS) testcopy.gnu.out testcopy.out
+
+
Index: string
===================================================================
--- string (nonexistent)
+++ string (revision 1765)
string
Property changes :
Added: svn:ignore
## -0,0 +1,9 ##
+string
+string.o
+string_glibc
+string_glibc.o
+testcopy.out
+testcopy.gnu.out
+testcopy
+testcopy_glibc
+strerror
Index: malloc/realloc0.c
===================================================================
--- malloc/realloc0.c (nonexistent)
+++ malloc/realloc0.c (revision 1765)
@@ -0,0 +1,13 @@
+#include
+
+int main(int argc, char **argv)
+{
+ void *ptr = NULL;
+ ptr = realloc(ptr, 0);
+ printf("realloc(NULL, 0) -- pointer = %p\n", ptr);
+
+ ptr = malloc(0);
+ printf("malloc(0) -- pointer = %p\n", ptr);
+ return 0;
+}
+
Index: malloc/mallocbug.c
===================================================================
--- malloc/mallocbug.c (nonexistent)
+++ malloc/mallocbug.c (revision 1765)
@@ -0,0 +1,67 @@
+/* Reproduce a GNU malloc bug. */
+#include
+#include
+#include
+
+#define size_t unsigned int
+
+int
+main (int argc, char *argv[])
+{
+ char *dummy0;
+ char *dummy1;
+ char *fill_info_table1;
+ char *over_top;
+ size_t over_top_size = 0x3000;
+ char *over_top_dup;
+ size_t over_top_dup_size = 0x7000;
+ char *x;
+ size_t i;
+
+ /* Here's what memory is supposed to look like (hex):
+ size contents
+ 3000 original_info_table, later fill_info_table1
+ 3fa000 dummy0
+ 3fa000 dummy1
+ 6000 info_table_2
+ 3000 over_top
+
+ */
+ /* mem: original_info_table */
+ dummy0 = malloc (0x3fa000);
+ /* mem: original_info_table, dummy0 */
+ dummy1 = malloc (0x3fa000);
+ /* mem: free, dummy0, dummy1, info_table_2 */
+ fill_info_table1 = malloc (0x3000);
+ /* mem: fill_info_table1, dummy0, dummy1, info_table_2 */
+
+ x = malloc (0x1000);
+ free (x);
+ /* mem: fill_info_table1, dummy0, dummy1, info_table_2, freexx */
+
+ /* This is what loses; info_table_2 and freexx get combined unbeknownst
+ to mmalloc, and mmalloc puts over_top in a section of memory which
+ is on the free list as part of another block (where info_table_2 had
+ been). */
+ over_top = malloc (over_top_size);
+ over_top_dup = malloc (over_top_dup_size);
+ memset (over_top, 0, over_top_size);
+ memset (over_top_dup, 1, over_top_dup_size);
+
+ for (i = 0; i < over_top_size; ++i)
+ if (over_top[i] != 0)
+ {
+ printf ("FAIL: malloc expands info table\n");
+ return 0;
+ }
+
+ for (i = 0; i < over_top_dup_size; ++i)
+ if (over_top_dup[i] != 1)
+ {
+ printf ("FAIL: malloc expands info table\n");
+ return 0;
+ }
+
+ printf ("PASS: malloc expands info table\n");
+ return 0;
+}
Index: malloc/time_malloc.c
===================================================================
--- malloc/time_malloc.c (nonexistent)
+++ malloc/time_malloc.c (revision 1765)
@@ -0,0 +1,62 @@
+#include
+#define REPS (100000)
+int sizes[] = {
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50,
+ 100000, 1024, 42000, 350, 100, 80, 3 ,3,3,3,3,3,3,3,3,3,3,3,3,50
+};
+#define NUM (sizeof sizes / sizeof sizes[0])
+int main ()
+{
+ int i, j;
+ void *allocs[NUM];
+ for (i = 0; i < REPS; i++) {
+ for (j = 0; j < NUM; j++) {
+ allocs[j] = malloc(sizes[j]);
+ }
+ for (j = 0; j < NUM; j++) {
+ free(allocs[j]);
+ }
+ }
+ return 0;
+}
+
Index: malloc/malloc.c
===================================================================
--- malloc/malloc.c (nonexistent)
+++ malloc/malloc.c (revision 1765)
@@ -0,0 +1,70 @@
+
+#include
+#include
+#include
+
+#define N_PTRS 1000
+#define N_ALLOCS 10000
+#define MAX_SIZE 0x10000
+
+#define random_size() (random()%MAX_SIZE)
+#define random_ptr() (random()%N_PTRS)
+
+void test1(void);
+void test2(void);
+
+int main(int argc,char *argv[])
+{
+ test1();
+ test2();
+ return 0;
+}
+
+void test1(void)
+{
+ void **ptrs;
+ int i,j;
+ int size;
+
+ srandom(0x19730929);
+
+ ptrs = malloc(N_PTRS*sizeof(void *));
+
+ for(i=0;i
+#include
+#include
+
+
+struct list {
+ struct list *next;
+};
+
+int main(void)
+{
+ int z=999;
+ int *y=&z;
+ int *x=NULL;
+ struct list *save;
+ struct list *lp;
+ int i;
+
+
+ printf("pointer to x is %p\n", x);
+ printf("pointer to y is %p\n", y);
+ x=malloc(sizeof(int)*2000);
+ printf("pointer to x is %p\n", x);
+ y=malloc(sizeof(int)*100);
+ printf("pointer to y is %p\n", y);
+ free(x);
+ free(y);
+ printf("about to free(0)\n");
+ free(0);
+
+ x=malloc(13);
+ printf("x = %p\n", x);
+ memcpy(x, "Small string", 13);
+ printf("0x%p test string1: %s\n", x, (char *)x);
+ y = realloc(x, 36);
+ printf("0x%p test string1: %s\n", y, (char *)y);
+ memcpy(y, "********** Larger string **********", 36);
+ printf("0x%p test string2: %s\n", y, (char *)y);
+ free(y);
+
+
+ printf("Allocate 100 nodes 500 bytes each\n");
+ save = 0;
+ for (i=0; i<100; i++) {
+ lp = malloc(500);
+ if (lp == 0) {
+ printf("loop 1: malloc returned 0\n");
+ goto Failed;
+ }
+ lp->next = save;
+ save = lp;
+ }
+
+ printf("freeing 100 nodes\n");
+ while (save) {
+ lp = save;
+ save = save->next;
+ free(lp);
+ }
+
+ printf("try realloc 100 times \n");
+ lp = 0;
+ for (i=1; i<=100; i++) {
+ lp = realloc(lp, i*200);
+ if (lp == 0) {
+ printf("loop 3: realloc returned 0\n");
+ goto Failed;
+ }
+ }
+ realloc(lp, 0);
+
+ printf("Allocate another 100 nodes 600 bytes each\n");
+ save = 0;
+ for (i=0; i<100; i++) {
+ lp = malloc(600);
+ if (lp == 0) {
+ printf("loop 2: malloc returned 0\n");
+ goto Failed;
+ }
+ lp->next = save;
+ save = lp;
+ }
+
+ printf("freeing 100 nodes\n");
+ while (save) {
+ lp = save;
+ save = save->next;
+ free(lp);
+ }
+
+
+ printf("alloc test PASSED\n");
+ exit(0);
+
+Failed:
+ printf("!!!!!!!!!!!! alloc test FAILED. !!!!!!!!!!!!!!!\n");
+ exit(1);
+}
Index: malloc/Makefile
===================================================================
--- malloc/Makefile (nonexistent)
+++ malloc/Makefile (revision 1765)
@@ -0,0 +1,129 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+
+TARGETS=malloc
+TARGETS+=testmalloc testmalloc_glibc
+TARGETS+=mallocbug mallocbug_glibc
+TARGETS+=realloc0 realloc0_glibc
+all: $(TARGETS)
+
+malloc: malloc.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+testmalloc_source:
+ -@ echo "-------"
+ -@ echo "testmalloc.c source: "
+ -@ echo " "
+ -@ cat testmalloc.c
+ -@ echo " "
+
+testmalloc: testmalloc.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+testmalloc_glibc: testmalloc.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+mallocbug: mallocbug.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+mallocbug_glibc: mallocbug.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+realloc0: realloc0.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+realloc0_glibc: realloc0.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
+
Index: malloc
===================================================================
--- malloc (nonexistent)
+++ malloc (revision 1765)
malloc
Property changes :
Added: svn:ignore
## -0,0 +1,9 ##
+malloc
+testmalloc
+testmalloc.o
+testmalloc_glibc
+testmalloc_glibc.o
+mallocbug
+mallocbug_glibc
+realloc0
+realloc0_glibc
Index: stat/stat.c
===================================================================
--- stat/stat.c (nonexistent)
+++ stat/stat.c (revision 1765)
@@ -0,0 +1,68 @@
+#include
+#include
+#include
+
+void print_struct_stat(char *msg, struct stat *s)
+{
+ printf("%s\n", msg);
+ /* The casts are because glibc thinks it's cool */
+ printf("device : 0x%llx\n",(long long)s->st_dev);
+ printf("inode : %lld\n", (long long)s->st_ino);
+ printf("mode : 0x%llx\n",(long long)s->st_mode);
+ printf("nlink : %lld\n", (long long)s->st_nlink);
+ printf("uid : %lld\n", (long long)s->st_uid);
+ printf("gid : %lld\n", (long long)s->st_gid);
+ printf("rdev : 0x%llx\n",(long long)s->st_rdev);
+ printf("size : %lld\n", (long long)s->st_size);
+ printf("blksize : %lld\n", (long long)s->st_blksize);
+ printf("blocks : %lld\n", (long long)s->st_blocks);
+ printf("atime : %lld\n", (long long)s->st_atime);
+ printf("mtime : %lld\n", (long long)s->st_mtime);
+ printf("ctime : %lld\n", (long long)s->st_ctime);
+}
+
+int main(int argc,char **argv)
+{
+ int fd, ret;
+ char *file;
+ struct stat s;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: stat FILE\n");
+ exit(1);
+ }
+ file = argv[1];
+
+ memset(&s, 0, sizeof(struct stat));
+ ret = stat(file, &s);
+ if(ret<0){
+ perror("stat");
+ exit(1);
+ }
+ print_struct_stat("\nTesting stat:", &s);
+
+ memset(&s, 0, sizeof(struct stat));
+ ret = lstat(file, &s);
+ if(ret<0){
+ perror("lstat");
+ exit(1);
+ }
+ print_struct_stat("\nTesting lstat:", &s);
+
+
+ fd = open(file, O_RDONLY);
+ if(fd<0){
+ perror("open");
+ exit(1);
+ }
+ memset(&s, 0, sizeof(struct stat));
+ ret = fstat(fd,&s);
+ if(ret<0){
+ perror("fstat");
+ exit(1);
+ }
+ print_struct_stat("\nTesting fstat:", &s);
+
+ exit(0);
+}
+
Index: stat/Makefile
===================================================================
--- stat/Makefile (nonexistent)
+++ stat/Makefile (revision 1765)
@@ -0,0 +1,101 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+CFLAGS64=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+
+
+TARGETS=stat_diff stat64_diff
+
+all: $(TARGETS)
+
+stat_source:
+ -@ $(RM) $(TARGETS)
+ -@ echo "-------"
+ -@ echo "stat.c source: "
+ -@ echo " "
+ -@ cat stat.c
+ -@ echo " "
+
+stat: stat.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ stat.c > $@.out
+ -@ echo " "
+
+stat_glibc: stat.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ stat.c > $@.out
+ -@ echo " "
+
+stat_diff: stat stat_glibc
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing stat output: "
+ -@ echo " "
+ -diff -u stat_glibc.out stat.out
+ -@ echo " "
+
+stat64: stat.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) $(CFLAGS64) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ stat.c > $@.out
+ -@ echo " "
+
+stat64_glibc: stat.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) $(CFLAGS64) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@ stat.c > $@.out
+ -@ echo " "
+
+stat64_diff: stat64 stat64_glibc
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Diffing stat64 output: "
+ -@ echo " "
+ -diff -u stat64_glibc.out stat64.out
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core stat stat_glibc stat_glibc.out stat.out \
+ stat64 stat64_glibc stat64_glibc.out stat64.out
+
+
Index: stat
===================================================================
--- stat (nonexistent)
+++ stat (revision 1765)
stat
Property changes :
Added: svn:ignore
## -0,0 +1,12 ##
+stat
+stat.o
+stat.out
+stat64
+stat64.o
+stat64.out
+stat64_glibc
+stat64_glibc.o
+stat64_glibc.out
+stat_glibc
+stat_glibc.o
+stat_glibc.out
Index: signal/Makefile
===================================================================
--- signal/Makefile (nonexistent)
+++ signal/Makefile (revision 1765)
@@ -0,0 +1,74 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+
+CFLAGS += -D_GNU_SOURCE
+
+TARGETS=signal signal_glibc sigchld sigchld_glibc
+all: $(TARGETS)
+
+signal: signal.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+signal_glibc: signal.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+sigchld: sigchld.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+sigchld_glibc: sigchld.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
+clean:
+ $(RM) *.[oa] *~ core $(TARGETS)
+
+
Index: signal/.indent.pro
===================================================================
--- signal/.indent.pro (nonexistent)
+++ signal/.indent.pro (revision 1765)
@@ -0,0 +1,33 @@
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--break-before-boolean-operator
+--no-blank-lines-after-commas
+--braces-on-if-line
+--braces-on-struct-decl-line
+--comment-indentation25
+--declaration-comment-column25
+--no-comment-delimiters-on-blank-lines
+--cuddle-else
+--continuation-indentation4
+--case-indentation0
+--else-endif-column33
+--space-after-cast
+--line-comments-indentation0
+--declaration-indentation1
+--dont-format-first-column-comments
+--dont-format-comments
+--honour-newlines
+--indent-level4
+/* changed from 0 to 4 */
+--parameter-indentation4
+--line-length78 /* changed from 75 */
+--continue-at-parentheses
+--no-space-after-function-call-names
+--dont-break-procedure-type
+--dont-star-comments
+--leave-optional-blank-lines
+--dont-space-special-semicolon
+--tab-size4
+/* additions by Mark */
+--case-brace-indentation0
+--leave-preprocessor-space
Index: signal/sigchld.c
===================================================================
--- signal/sigchld.c (nonexistent)
+++ signal/sigchld.c (revision 1765)
@@ -0,0 +1,59 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+void test_handler(int signo)
+{
+ write(1, "caught SIGCHLD\n", 15);
+ return;
+}
+
+
+int main(void)
+{
+ pid_t mypid;
+ struct sigaction siga;
+ static sigset_t sigset;
+
+ /* Set up sighandling */
+ sigfillset(&sigset);
+ siga.sa_handler = test_handler;
+ siga.sa_mask = sigset;
+ siga.sa_flags = 0;
+ if (sigaction(SIGCHLD, &siga, (struct sigaction *)NULL) != 0) {
+ fprintf(stderr, "sigaction choked: %s!", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+
+ /* Setup a child process to exercise the sig handling for us */
+ mypid = getpid();
+ if (fork() == 0) {
+ int i;
+
+ for (i=0; i < 3; i++) {
+ sleep(2);
+ kill(mypid, SIGCHLD);
+ }
+ _exit(EXIT_SUCCESS);
+ }
+
+
+ /* Wait for signals */
+ write(1, "waiting for a SIGCHLD\n",22);
+ for(;;) {
+ sleep(10);
+ if (waitpid(-1, NULL, WNOHANG | WUNTRACED) > 0)
+ break;
+ write(1, "after sleep\n", 12);
+ }
+
+ printf("Bye-bye! All done!\n");
+ return 0;
+}
+
Index: signal/signal.c
===================================================================
--- signal/signal.c (nonexistent)
+++ signal/signal.c (revision 1765)
@@ -0,0 +1,101 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * signal testing function for uClibc
+ *
+ * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 2000,2001 by Erik Andersen
+ * Written by Erik Andersen
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+/* -------------------------------------------------*/
+/* This stuff is common to all the testing routines */
+/* -------------------------------------------------*/
+const char *it = ""; /* Routine name for message routines. */
+size_t errors = 0;
+
+void check(int thing, int number)
+{
+ if (!thing) {
+ printf("%s: flunked test %d\n", it, number);
+ ++errors;
+ }
+}
+
+void equal(const char *a, const char *b, int number)
+{
+ check(a != NULL && b != NULL && (strcmp(a, b) == 0), number);
+}
+
+
+/* -------------------------------------------------*/
+/* Let the tests begin.... */
+/* -------------------------------------------------*/
+
+int global_int = 0;
+
+void set_global_int_to_one(int signum)
+{
+ printf ("Received signal %d (%s).\n", signum, strsignal(signum));
+ global_int = 1;
+ return;
+}
+
+void signal_test_1(void)
+{
+ global_int = 0;
+
+ it = "global variable set from signal handler";
+ signal(SIGUSR1, set_global_int_to_one);
+ raise(SIGUSR1);
+
+ /* This should already have jumped to the signal handler */
+ check((global_int == 1), 1);
+
+ global_int = 0;
+ signal(SIGUSR1, SIG_IGN);
+ raise(SIGUSR1);
+ /* This should not go to the signal handler this time since we */
+ check((global_int == 0), 1);
+}
+
+
+int main(void)
+{
+ int status;
+
+ signal_test_1();
+
+ if (errors == 0) {
+ status = EXIT_SUCCESS;
+ printf("No errors.\n");
+ } else {
+ status = EXIT_FAILURE;
+ printf("%d errors.\n", errors);
+ }
+ exit(status);
+}
Index: signal
===================================================================
--- signal (nonexistent)
+++ signal (revision 1765)
signal
Property changes :
Added: svn:ignore
## -0,0 +1,8 ##
+signal
+signal.o
+signal_glibc
+signal_glibc.o
+sigchld
+sigchld.o
+sigchld_glibc
+sigchld_glibc.o
Index: Makefile
===================================================================
--- Makefile (nonexistent)
+++ Makefile (revision 1765)
@@ -0,0 +1,58 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000,2001 Erik Andersen
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+TOPDIR=../
+-include $(TOPDIR).config
+
+.EXPORT_ALL_VARIABLES:
+
+
+ALL_SUBDIRS = args assert ctype dlopen pwd_grp signal silly stdlib string unistd crypt #misc
+DIRS = $(ALL_SUBDIRS)
+#ifeq ($(TARGET_ARCH), $(HOST_ARCH))
+# DIRS = $(ALL_SUBDIRS)
+#else
+# DIRS =
+#endif
+ifeq ($(strip $(HAVE_SHARED)),true)
+ ifeq ($(strip $(DODYNAMIC)),true)
+ DIRS += dlopen
+ endif
+endif
+ifeq ($(strip $(INCLUDE_THREADS)),true)
+ DIRS += pthread
+endif
+
+all: subdirs
+
+tags:
+ ctags -R
+
+clean: subdirs_clean
+ $(RM) *.[oa] *~ core
+
+subdirs: $(patsubst %, _dir_%, $(DIRS))
+subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
+
+$(patsubst %, _dir_%, $(DIRS)) : dummy
+ $(MAKE) -C $(patsubst _dir_%, %, $@)
+
+$(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
+ $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
+
+.PHONY: dummy
Index: .
===================================================================
--- . (nonexistent)
+++ . (revision 1765)
.
Property changes :
Added: svn:ignore
## -0,0 +1,8 ##
+hello
+hello.o
+hello_glibc
+hello_glibc.o
+testmalloc
+testmalloc.o
+testmalloc_glibc
+testmalloc_glibc.o