summaryrefslogtreecommitdiffstats
path: root/config/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'config/cmake')
-rw-r--r--config/cmake/ConversionTests.c234
-rw-r--r--config/cmake/HDFTests.c138
2 files changed, 200 insertions, 172 deletions
diff --git a/config/cmake/ConversionTests.c b/config/cmake/ConversionTests.c
index f100dd8..80de31f 100644
--- a/config/cmake/ConversionTests.c
+++ b/config/cmake/ConversionTests.c
@@ -11,13 +11,13 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#if defined(__has_attribute)
-#if __has_attribute(no_sanitize)
-#define HDF_NO_UBSAN __attribute__((no_sanitize("undefined")))
+# if __has_attribute(no_sanitize)
+# define HDF_NO_UBSAN __attribute__((no_sanitize("undefined")))
+# else
+# define HDF_NO_UBSAN
+# endif
#else
-#define HDF_NO_UBSAN
-#endif
-#else
-#define HDF_NO_UBSAN
+# define HDF_NO_UBSAN
#endif
#ifdef H5_LDOUBLE_TO_LONG_SPECIAL_TEST
@@ -34,45 +34,49 @@ int HDF_NO_UBSAN main(void)
unsigned char s2[8];
int ret = 1;
- if(sizeof(long double) == 16 && sizeof(long) == 8) {
- /*make sure the long double type has 16 bytes in size and
- * 11 bits of exponent. If it is,
- *the bit sequence should be like below. It's not
- *a decent way to check but this info isn't available. */
- memcpy(s, &ld, 16);
- if(s[0]==0x43 && s[1]==0x51 && s[2]==0xcc && s[3]==0xf3 &&
- s[4]==0x85 && s[5]==0xeb && s[6]==0xc8 && s[7]==0xa0 &&
- s[8]==0xbf && s[9]==0xcc && s[10]==0x2a && s[11]==0x3c) {
-
- /* Assign the hexadecimal value of long double type. */
- s[0]=0x43; s[1]=0x51; s[2]=0xcc; s[3]=0xf3;
- s[4]=0x85; s[5]=0xeb; s[6]=0xc8; s[7]=0xa0;
- s[8]=0xbf; s[9]=0xcc; s[10]=0x2a; s[11]=0x3c;
- s[12]=0x3d; s[13]=0x85; s[14]=0x56; s[15]=0x20;
-
- memcpy(&ld, s, 16);
-
- ll = (long)ld;
- memcpy(s2, &ll, 8);
-
- /* The library's algorithm converts it to 0x 00 47 33 ce 17 af 22 82
- * and gets wrong value 20041683600089730 on the IBM Power6 Linux.
- * But the IBM Power6 Linux converts it to 0x00 47 33 ce 17 af 22 7f
- * and gets the correct value 20041683600089727. It uses some special
- * algorithm. We're going to define the macro and skip the test until
- * we can figure out how they do it. */
- if(s2[0]==0x00 && s2[1]==0x47 && s2[2]==0x33 && s2[3]==0xce &&
- s2[4]==0x17 && s2[5]==0xaf && s2[6]==0x22 && s2[7]==0x7f)
- ret = 0;
-
- ull = (unsigned long)ld;
- memcpy(s2, &ull, 8);
-
- /* The unsigned long is the same as signed long. */
- if(s2[0]==0x00 && s2[1]==0x47 && s2[2]==0x33 && s2[3]==0xce &&
- s2[4]==0x17 && s2[5]==0xaf && s2[6]==0x22 && s2[7]==0x7f)
- ret = 0;
- }
+ if (sizeof(long double) == 16 && sizeof(long) == 8) {
+ /* Make sure the long double type has 16 bytes in size and
+ * 11 bits of exponent. If it is, the bit sequence should be
+ * like below. It's not a decent way to check but this info
+ * isn't available.
+ */
+ memcpy(s, &ld, 16);
+ if (s[0]==0x43 && s[1]==0x51 && s[2]==0xcc && s[3]==0xf3 &&
+ s[4]==0x85 && s[5]==0xeb && s[6]==0xc8 && s[7]==0xa0 &&
+ s[8]==0xbf && s[9]==0xcc && s[10]==0x2a && s[11]==0x3c) {
+
+ /* Assign the hexadecimal value of long double type. */
+ s[0]=0x43; s[1]=0x51; s[2]=0xcc; s[3]=0xf3;
+ s[4]=0x85; s[5]=0xeb; s[6]=0xc8; s[7]=0xa0;
+ s[8]=0xbf; s[9]=0xcc; s[10]=0x2a; s[11]=0x3c;
+ s[12]=0x3d; s[13]=0x85; s[14]=0x56; s[15]=0x20;
+
+ memcpy(&ld, s, 16);
+
+ ll = (long)ld;
+ memcpy(s2, &ll, 8);
+
+ /* The library's algorithm converts it to 0x 00 47 33 ce 17 af 22 82
+ * and gets wrong value 20041683600089730 on the IBM Power6 Linux.
+ * But the IBM Power6 Linux converts it to 0x00 47 33 ce 17 af 22 7f
+ * and gets the correct value 20041683600089727. It uses some special
+ * algorithm. We're going to define the macro and skip the test until
+ * we can figure out how they do it.
+ */
+ if (s2[0]==0x00 && s2[1]==0x47 && s2[2]==0x33 && s2[3]==0xce &&
+ s2[4]==0x17 && s2[5]==0xaf && s2[6]==0x22 && s2[7]==0x7f)
+
+ ret = 0;
+
+ ull = (unsigned long)ld;
+ memcpy(s2, &ull, 8);
+
+ /* The unsigned long is the same as signed long */
+ if(s2[0]==0x00 && s2[1]==0x47 && s2[2]==0x33 && s2[3]==0xce &&
+ s2[4]==0x17 && s2[5]==0xaf && s2[6]==0x22 && s2[7]==0x7f)
+
+ ret = 0;
+ }
}
done:
@@ -94,50 +98,60 @@ int HDF_NO_UBSAN main(void)
unsigned char s[16];
int flag=0, ret=1;
- /*Determine if long double has 16 byte in size, 11 bit exponent, and
- *the bias is 0x3ff */
- if(sizeof(long double) == 16) {
- ld = 1.0L;
- memcpy(s, &ld, 16);
- if(s[0]==0x3f && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 &&
- s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00)
- flag = 1;
- }
+ /* Determine if long double has 16 byte in size, 11 bit exponent, and
+ * the bias is 0x3ff
+ */
+ if (sizeof(long double) == 16) {
+ ld = 1.0L;
+ memcpy(s, &ld, 16);
+
+ if (s[0]==0x3f && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 &&
+ s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00)
- if(flag==1 && sizeof(long)==8) {
- ll = 0x003fffffffffffffL;
- ld = (long double)ll;
- memcpy(s, &ld, 16);
- /* The library converts the value to 0x434fffffffffffff8000000000000000.
- * In decimal it is 18014398509481982.000000, one value short of the original.
- * The IBM Power6 Linux converts it to 0x4350000000000000bff0000000000000.
- * The value is correct in decimal. It uses some special
- * algorithm. We're going to define the macro and skip the test until
- * we can figure out how they do it. */
- if(s[0]==0x43 && s[1]==0x50 && s[2]==0x00 && s[3]==0x00 &&
- s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00 &&
- s[8]==0xbf && s[9]==0xf0 && s[10]==0x00 && s[11]==0x00 &&
- s[12]==0x00 && s[13]==0x00 && s[14]==0x00 && s[15]==0x00)
- ret = 0;
+ flag = 1;
}
- if(flag==1 && sizeof(unsigned long)==8) {
- ull = 0xffffffffffffffffUL;
- ld = (long double)ull;
- memcpy(s, &ld, 16);
- /* Use a different value from signed long to test. The problem is the same
- * for both long and unsigned long. The value is 18446744073709551615.
- * The library converts the value to 0x43effffffffffffffe000000000000000.
- * In decimal it's 18446744073709548544.000000, very different from the original.
- * The IBM Power6 Linux converts it to 0x43f0000000000000bff0000000000000.
- * The value is correct in decimal. It uses some special
- * algorithm. We're going to define the macro and skip the test until
- * we can figure out how they do it. */
- if(s[0]==0x43 && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 &&
- s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00 &&
- s[8]==0xbf && s[9]==0xf0 && s[10]==0x00 && s[11]==0x00 &&
- s[12]==0x00 && s[13]==0x00 && s[14]==0x00 && s[15]==0x00)
- ret = 0;
+
+ if (flag==1 && sizeof(long)==8) {
+ ll = 0x003fffffffffffffL;
+ ld = (long double)ll;
+ memcpy(s, &ld, 16);
+
+ /* The library converts the value to 0x434fffffffffffff8000000000000000.
+ * In decimal it is 18014398509481982.000000, one value short of the original.
+ * The IBM Power6 Linux converts it to 0x4350000000000000bff0000000000000.
+ * The value is correct in decimal. It uses some special
+ * algorithm. We're going to define the macro and skip the test until
+ * we can figure out how they do it.
+ */
+ if (s[0]==0x43 && s[1]==0x50 && s[2]==0x00 && s[3]==0x00 &&
+ s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00 &&
+ s[8]==0xbf && s[9]==0xf0 && s[10]==0x00 && s[11]==0x00 &&
+ s[12]==0x00 && s[13]==0x00 && s[14]==0x00 && s[15]==0x00)
+
+ ret = 0;
}
+
+ if (flag==1 && sizeof(unsigned long)==8) {
+ ull = 0xffffffffffffffffUL;
+ ld = (long double)ull;
+ memcpy(s, &ld, 16);
+
+ /* Use a different value from signed long to test. The problem is the same
+ * for both long and unsigned long. The value is 18446744073709551615.
+ * The library converts the value to 0x43effffffffffffffe000000000000000.
+ * In decimal it's 18446744073709548544.000000, very different from the original.
+ * The IBM Power6 Linux converts it to 0x43f0000000000000bff0000000000000.
+ * The value is correct in decimal. It uses some special
+ * algorithm. We're going to define the macro and skip the test until
+ * we can figure out how they do it.
+ */
+ if (s[0]==0x43 && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 &&
+ s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00 &&
+ s[8]==0xbf && s[9]==0xf0 && s[10]==0x00 && s[11]==0x00 &&
+ s[12]==0x00 && s[13]==0x00 && s[14]==0x00 && s[15]==0x00)
+
+ ret = 0;
+ }
done:
exit(ret);
}
@@ -157,18 +171,21 @@ int HDF_NO_UBSAN main(void)
unsigned char s[16];
int ret = 0;
- if(sizeof(long double) == 16) {
- /*make sure the long double type is the same as the failing type
- *which has 16 bytes in size and 11 bits of exponent. If it is,
- *the bit sequence should be like below. It's not
- *a decent way to check but this info isn't available. */
+ if (sizeof(long double) == 16) {
+ /* Make sure the long double type is the same as the failing type
+ * which has 16 bytes in size and 11 bits of exponent. If it is,
+ * the bit sequence should be like below. It's not
+ * a decent way to check but this info isn't available.
+ */
memcpy(s, &ld, 16);
- if(s[0]==0x43 && s[1]==0x51 && s[2]==0xcc && s[3]==0xf3 &&
+
+ if (s[0]==0x43 && s[1]==0x51 && s[2]==0xcc && s[3]==0xf3 &&
s[4]==0x85 && s[5]==0xeb && s[6]==0xc8 && s[7]==0xa0 &&
s[8]==0xbf && s[9]==0xcc && s[10]==0x2a && s[11]==0x3c) {
- /*slightly adjust the bit sequence (s[8]=0xdf). The converted
- *values will go wild on Mac OS 10.4 and IRIX64 6.5.*/
+ /* Slightly adjust the bit sequence (s[8]=0xdf). The converted
+ * values will go wild on Mac OS 10.4 and IRIX64 6.5.
+ */
s[0]=0x43; s[1]=0x51; s[2]=0xcc; s[3]=0xf3;
s[4]=0x85; s[5]=0xeb; s[6]=0xc8; s[7]=0xa0;
s[8]=0xdf; s[9]=0xcc; s[10]=0x2a; s[11]=0x3c;
@@ -178,7 +195,7 @@ int HDF_NO_UBSAN main(void)
ll = (long long)ld;
ull = (unsigned long long)ld;
- if(ll != 20041683600089728 || ull != 20041683600089728)
+ if (ll != 20041683600089728 || ull != 20041683600089728)
ret = 1;
}
}
@@ -200,35 +217,42 @@ int HDF_NO_UBSAN main(void)
unsigned char s[16];
int flag=0, ret=0;
- /*Determine if long double has 16 byte in size, 11 bit exponent, and
- *the bias is 0x3ff */
- if(sizeof(long double) == 16) {
+ /* Determine if long double has 16 byte in size, 11 bit exponent, and
+ * the bias is 0x3ff
+ */
+ if (sizeof(long double) == 16) {
ld = 1.0L;
memcpy(s, &ld, 16);
- if(s[0]==0x3f && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 &&
+ if (s[0]==0x3f && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 &&
s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00)
+
flag = 1;
}
- if(flag==1 && sizeof(long long)==8) {
+ if (flag==1 && sizeof(long long)==8) {
ll = 0x01ffffffffffffffLL;
ld = (long double)ll;
memcpy(s, &ld, 16);
- /*Check if the bit sequence is as supposed to be*/
- if(s[0]!=0x43 || s[1]!=0x7f || s[2]!=0xff || s[3]!=0xff ||
+
+ /* Check if the bit sequence is as expected*/
+ if (s[0]!=0x43 || s[1]!=0x7f || s[2]!=0xff || s[3]!=0xff ||
s[4]!=0xff || s[5]!=0xff || s[6]!=0xff || s[7]!=0xff ||
s[8]!=0xf0 || s[9]!=0x00 || s[10]!=0x00 || s[11]!=0x00)
+
ret = 1;
}
- if(flag==1 && sizeof(unsigned long long)==8) {
+ if (flag==1 && sizeof(unsigned long long)==8) {
ull = 0x01ffffffffffffffULL;
ld = (long double)ull;
memcpy(s, &ld, 16);
- if(s[0]!=0x43 || s[1]!=0x7f || s[2]!=0xff || s[3]!=0xff ||
+
+ if (s[0]!=0x43 || s[1]!=0x7f || s[2]!=0xff || s[3]!=0xff ||
s[4]!=0xff || s[5]!=0xff || s[6]!=0xff || s[7]!=0xff ||
s[8]!=0xf0 || s[9]!=0x00 || s[10]!=0x00 || s[11]!=0x00)
+
ret = 1;
}
+
done:
exit(ret);
}
@@ -251,7 +275,7 @@ int HDF_NO_UBSAN main(void)
pclose(fp);
- if(strncmp(cpu, "ppc64le", 7) == 0)
+ if (strncmp(cpu, "ppc64le", 7) == 0)
return 0;
return 1;
diff --git a/config/cmake/HDFTests.c b/config/cmake/HDFTests.c
index 66b9bf6..96460d7 100644
--- a/config/cmake/HDFTests.c
+++ b/config/cmake/HDFTests.c
@@ -9,42 +9,31 @@
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#define SIMPLE_TEST(x) int main(){ x; return 0; }
-#ifdef HAVE_ATTRIBUTE
+/* A simple test program to see if a function "works" */
+#define SIMPLE_TEST(x) int main(){ x; return 0; }
-#if 0
-static void test int __attribute((unused)) var)
-{
- int __attribute__((unused)) x = var;
-}
-int main(void)
-{
- test(19);
-}
+#ifdef HAVE_ATTRIBUTE
-#else
int
main ()
{
-int __attribute__((unused)) x
- ;
- return 0;
-}
-#endif
+ int __attribute__((unused)) x;
+ return 0;
+}
#endif /* HAVE_ATTRIBUTE */
#ifdef HAVE_TIMEZONE
#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
+# include <sys/time.h>
#endif
#include <time.h>
-SIMPLE_TEST(timezone=0);
+SIMPLE_TEST(timezone = 0);
#endif /* HAVE_TIMEZONE */
@@ -58,8 +47,8 @@ int main(void)
int ret;
pthread_attr_init(&attribute);
- ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
- if (ret==0)
+ ret = pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
+ if (ret == 0)
return 0;
return 1;
}
@@ -71,13 +60,13 @@ int main(void)
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
+# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
+# include <sys/socket.h>
#endif
SIMPLE_TEST(socklen_t foo);
@@ -92,35 +81,41 @@ SIMPLE_TEST(socklen_t foo);
int main ()
{
- dev_t d1, d2;
- if(d1==d2)
- return 0;
- return 1;
+ dev_t d1, d2;
+ if (d1 == d2)
+ return 0;
+ return 1;
}
#endif /* DEV_T_IS_SCALAR */
#ifdef HAVE_OFF64_T
+
#include <sys/types.h>
+
int main()
{
- off64_t n = 0;
- return (int)n;
+ off64_t n = 0;
+ return (int)n;
}
#endif
#ifdef TEST_DIRECT_VFD_WORKS
+
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+
int main(void)
{
- int fid;
- if((fid=open("tst_file", O_CREAT | O_TRUNC | O_DIRECT, 0755))<0)
- return 1;
- close(fid);
- remove("tst_file");
- return 0;
+ int fid;
+
+ if ((fid = open("tst_file", O_CREAT | O_TRUNC | O_DIRECT, 0755)) < 0)
+ return 1;
+ close(fid);
+ remove("tst_file");
+
+ return 0;
}
#endif
@@ -129,49 +124,54 @@ int main(void)
#endif
#ifdef HAVE_DEFAULT_SOURCE
-/* check default source */
+/* Check default source */
#include <features.h>
int
main(void)
{
#ifdef __GLIBC_PREREQ
- return __GLIBC_PREREQ(2,19);
+ return __GLIBC_PREREQ(2,19);
#else
- return 0;
-#endif /* defined(__GLIBC_PREREQ) */
+ return 0;
+#endif
}
#endif
#ifdef TEST_LFS_WORKS
+
/* Return 0 when LFS is available and 1 otherwise. */
+
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _LARGE_FILES
#define _FILE_OFFSET_BITS 64
+
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <stdio.h>
+#define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+
int main(int argc, char **argv)
{
- /* check that off_t can hold 2^63 - 1 and perform basic operations... */
-#define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- if (OFF_T_64 % 2147483647 != 1)
- return 1;
- /* stat breaks on SCO OpenServer */
- struct stat buf;
- stat( argv[0], &buf );
- if (!S_ISREG(buf.st_mode))
- return 2;
-
- FILE *file = fopen( argv[0], "r" );
- off_t offset = ftello( file );
- fseek( file, offset, SEEK_CUR );
- fclose( file );
- return 0;
+ /* Check that off_t can hold 2^63 - 1 and perform basic operations... */
+ if (OFF_T_64 % 2147483647 != 1)
+ return 1;
+
+ /* stat breaks on SCO OpenServer */
+ struct stat buf;
+ stat(argv[0], &buf);
+ if (!S_ISREG(buf.st_mode))
+ return 2;
+
+ FILE *file = fopen(argv[0], "r");
+ off_t offset = ftello(file);
+ fseek(file, offset, SEEK_CUR);
+ fclose(file);
+ return 0;
}
#endif
@@ -182,15 +182,19 @@ int main(int argc, char **argv)
#endif
int main(void)
{
- struct timeval tv;
- struct timezone tz;
- tz.tz_minuteswest = 7777; /* Initialize to an unreasonable number */
- tz.tz_dsttime = 7;
- gettimeofday(&tv, &tz);
+ struct timeval tv;
+ struct timezone tz;
+
+ tz.tz_minuteswest = 7777; /* Initialize to an unreasonable number */
+ tz.tz_dsttime = 7;
+
+ gettimeofday(&tv, &tz);
+
/* Check whether the function returned any value at all */
- if(tz.tz_minuteswest == 7777 && tz.tz_dsttime == 7)
- return 1;
- else return 0;
+ if (tz.tz_minuteswest == 7777 && tz.tz_dsttime == 7)
+ return 1;
+ else
+ return 0;
}
#endif
@@ -201,10 +205,10 @@ typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
int main ()
{
PGNSI pGNSI;
- pGNSI = (PGNSI) GetProcAddress(
- GetModuleHandle(TEXT("kernel32.dll")),
- "InitOnceExecuteOnce");
- if(NULL == pGNSI)
+
+ pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "InitOnceExecuteOnce");
+
+ if (NULL == pGNSI)
return 1;
else
return 0;