test/testplatform.c
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1621 f12379c41042
child 1668 4da1ee79c9af
     1.1 --- a/test/testplatform.c	Sun May 21 17:27:13 2006 +0000
     1.2 +++ b/test/testplatform.c	Sun May 28 13:04:16 2006 +0000
     1.3 @@ -10,200 +10,208 @@
     1.4   *  compare them directly, so we push it through a function to keep the
     1.5   *  compiler quiet.  --ryan.
     1.6   */
     1.7 -static int badsize(size_t sizeoftype, size_t hardcodetype)
     1.8 +static int
     1.9 +badsize (size_t sizeoftype, size_t hardcodetype)
    1.10  {
    1.11      return sizeoftype != hardcodetype;
    1.12  }
    1.13  
    1.14 -int TestTypes(SDL_bool verbose)
    1.15 +int
    1.16 +TestTypes (SDL_bool verbose)
    1.17  {
    1.18 -	int error = 0;
    1.19 +    int error = 0;
    1.20  
    1.21 -	if ( badsize(sizeof(Uint8), 1) ) {
    1.22 -		if ( verbose )
    1.23 -			printf("sizeof(Uint8) != 1, instead = %ul\n",
    1.24 -								sizeof(Uint8));
    1.25 -		++error;
    1.26 -	}
    1.27 -	if ( badsize(sizeof(Uint16), 2) ) {
    1.28 -		if ( verbose )
    1.29 -			printf("sizeof(Uint16) != 2, instead = %ul\n",
    1.30 -								sizeof(Uint16));
    1.31 -		++error;
    1.32 -	}
    1.33 -	if ( badsize(sizeof(Uint32), 4) ) {
    1.34 -		if ( verbose )
    1.35 -			printf("sizeof(Uint32) != 4, instead = %ul\n",
    1.36 -								sizeof(Uint32));
    1.37 -		++error;
    1.38 -	}
    1.39 +    if (badsize (sizeof (Uint8), 1)) {
    1.40 +        if (verbose)
    1.41 +            printf ("sizeof(Uint8) != 1, instead = %ul\n", sizeof (Uint8));
    1.42 +        ++error;
    1.43 +    }
    1.44 +    if (badsize (sizeof (Uint16), 2)) {
    1.45 +        if (verbose)
    1.46 +            printf ("sizeof(Uint16) != 2, instead = %ul\n", sizeof (Uint16));
    1.47 +        ++error;
    1.48 +    }
    1.49 +    if (badsize (sizeof (Uint32), 4)) {
    1.50 +        if (verbose)
    1.51 +            printf ("sizeof(Uint32) != 4, instead = %ul\n", sizeof (Uint32));
    1.52 +        ++error;
    1.53 +    }
    1.54  #ifdef SDL_HAS_64BIT_TYPE
    1.55 -	if ( badsize(sizeof(Uint64), 8) ) {
    1.56 -		if ( verbose )
    1.57 -			printf("sizeof(Uint64) != 8, instead = %ul\n",
    1.58 -								sizeof(Uint64));
    1.59 -		++error;
    1.60 -	}
    1.61 +    if (badsize (sizeof (Uint64), 8)) {
    1.62 +        if (verbose)
    1.63 +            printf ("sizeof(Uint64) != 8, instead = %ul\n", sizeof (Uint64));
    1.64 +        ++error;
    1.65 +    }
    1.66  #else
    1.67 -	if ( verbose ) {
    1.68 -		printf("WARNING: No 64-bit datatype on this platform\n");
    1.69 -	}
    1.70 +    if (verbose) {
    1.71 +        printf ("WARNING: No 64-bit datatype on this platform\n");
    1.72 +    }
    1.73  #endif
    1.74 -	if ( verbose && !error )
    1.75 -		printf("All data types are the expected size.\n");
    1.76 +    if (verbose && !error)
    1.77 +        printf ("All data types are the expected size.\n");
    1.78  
    1.79 -	return( error ? 1 : 0 );
    1.80 +    return (error ? 1 : 0);
    1.81  }
    1.82  
    1.83 -int TestEndian(SDL_bool verbose)
    1.84 +int
    1.85 +TestEndian (SDL_bool verbose)
    1.86  {
    1.87 -	int error = 0;
    1.88 -	Uint16 value = 0x1234;
    1.89 -	int real_byteorder;
    1.90 -	Uint16 value16 = 0xCDAB;
    1.91 -	Uint16 swapped16 = 0xABCD;
    1.92 -	Uint32 value32 = 0xEFBEADDE;
    1.93 -	Uint32 swapped32 = 0xDEADBEEF;
    1.94 +    int error = 0;
    1.95 +    Uint16 value = 0x1234;
    1.96 +    int real_byteorder;
    1.97 +    Uint16 value16 = 0xCDAB;
    1.98 +    Uint16 swapped16 = 0xABCD;
    1.99 +    Uint32 value32 = 0xEFBEADDE;
   1.100 +    Uint32 swapped32 = 0xDEADBEEF;
   1.101  #ifdef SDL_HAS_64BIT_TYPE
   1.102 -	Uint64 value64, swapped64;
   1.103 -	value64 = 0xEFBEADDE;
   1.104 -	value64 <<= 32;
   1.105 -	value64 |= 0xCDAB3412;
   1.106 -	swapped64 = 0x1234ABCD;
   1.107 -	swapped64 <<= 32;
   1.108 -	swapped64 |= 0xDEADBEEF;
   1.109 +    Uint64 value64, swapped64;
   1.110 +    value64 = 0xEFBEADDE;
   1.111 +    value64 <<= 32;
   1.112 +    value64 |= 0xCDAB3412;
   1.113 +    swapped64 = 0x1234ABCD;
   1.114 +    swapped64 <<= 32;
   1.115 +    swapped64 |= 0xDEADBEEF;
   1.116  #endif
   1.117  
   1.118 -	if ( verbose ) {
   1.119 -		printf("Detected a %s endian machine.\n",
   1.120 -			(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
   1.121 -	}
   1.122 -	if ( (*((char *)&value) >> 4) == 0x1 ) {
   1.123 -		real_byteorder = SDL_BIG_ENDIAN;
   1.124 -	} else {
   1.125 -		real_byteorder = SDL_LIL_ENDIAN;
   1.126 -	}
   1.127 -	if ( real_byteorder != SDL_BYTEORDER ) {
   1.128 -		if ( verbose ) {
   1.129 -			printf("Actually a %s endian machine!\n",
   1.130 -				(real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
   1.131 -		}
   1.132 -		++error;
   1.133 -	}
   1.134 -	if ( verbose ) {
   1.135 -		printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, SDL_Swap16(value16));
   1.136 -	}
   1.137 -	if ( SDL_Swap16(value16) != swapped16 ) {
   1.138 -		if ( verbose ) {
   1.139 -			printf("16 bit value swapped incorrectly!\n");
   1.140 -		}
   1.141 -		++error;
   1.142 -	}
   1.143 -	if ( verbose ) {
   1.144 -		printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, SDL_Swap32(value32));
   1.145 -	}
   1.146 -	if ( SDL_Swap32(value32) != swapped32 ) {
   1.147 -		if ( verbose ) {
   1.148 -			printf("32 bit value swapped incorrectly!\n");
   1.149 -		}
   1.150 -		++error;
   1.151 -	}
   1.152 +    if (verbose) {
   1.153 +        printf ("Detected a %s endian machine.\n",
   1.154 +                (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
   1.155 +    }
   1.156 +    if ((*((char *) &value) >> 4) == 0x1) {
   1.157 +        real_byteorder = SDL_BIG_ENDIAN;
   1.158 +    } else {
   1.159 +        real_byteorder = SDL_LIL_ENDIAN;
   1.160 +    }
   1.161 +    if (real_byteorder != SDL_BYTEORDER) {
   1.162 +        if (verbose) {
   1.163 +            printf ("Actually a %s endian machine!\n",
   1.164 +                    (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
   1.165 +        }
   1.166 +        ++error;
   1.167 +    }
   1.168 +    if (verbose) {
   1.169 +        printf ("Value 16 = 0x%X, swapped = 0x%X\n", value16,
   1.170 +                SDL_Swap16 (value16));
   1.171 +    }
   1.172 +    if (SDL_Swap16 (value16) != swapped16) {
   1.173 +        if (verbose) {
   1.174 +            printf ("16 bit value swapped incorrectly!\n");
   1.175 +        }
   1.176 +        ++error;
   1.177 +    }
   1.178 +    if (verbose) {
   1.179 +        printf ("Value 32 = 0x%X, swapped = 0x%X\n", value32,
   1.180 +                SDL_Swap32 (value32));
   1.181 +    }
   1.182 +    if (SDL_Swap32 (value32) != swapped32) {
   1.183 +        if (verbose) {
   1.184 +            printf ("32 bit value swapped incorrectly!\n");
   1.185 +        }
   1.186 +        ++error;
   1.187 +    }
   1.188  #ifdef SDL_HAS_64BIT_TYPE
   1.189 -	if ( verbose ) {
   1.190 +    if (verbose) {
   1.191  #ifdef _MSC_VER
   1.192 -		printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, SDL_Swap64(value64));
   1.193 +        printf ("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64,
   1.194 +                SDL_Swap64 (value64));
   1.195  #else
   1.196 -		printf("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, SDL_Swap64(value64));
   1.197 +        printf ("Value 64 = 0x%llX, swapped = 0x%llX\n", value64,
   1.198 +                SDL_Swap64 (value64));
   1.199  #endif
   1.200 -	}
   1.201 -	if ( SDL_Swap64(value64) != swapped64 ) {
   1.202 -		if ( verbose ) {
   1.203 -			printf("64 bit value swapped incorrectly!\n");
   1.204 -		}
   1.205 -		++error;
   1.206 -	}
   1.207 +    }
   1.208 +    if (SDL_Swap64 (value64) != swapped64) {
   1.209 +        if (verbose) {
   1.210 +            printf ("64 bit value swapped incorrectly!\n");
   1.211 +        }
   1.212 +        ++error;
   1.213 +    }
   1.214  #endif
   1.215 -	return( error ? 1 : 0 );
   1.216 +    return (error ? 1 : 0);
   1.217  }
   1.218  
   1.219  
   1.220 -int TestCPUInfo(SDL_bool verbose)
   1.221 +int
   1.222 +TestCPUInfo (SDL_bool verbose)
   1.223  {
   1.224 -	if ( verbose ) {
   1.225 -		printf("RDTSC %s\n", SDL_HasRDTSC() ? "detected" : "not detected");
   1.226 -		printf("MMX %s\n", SDL_HasMMX() ? "detected" : "not detected");
   1.227 -		printf("MMX Ext %s\n", SDL_HasMMXExt() ? "detected" : "not detected");
   1.228 -		printf("3DNow %s\n", SDL_Has3DNow() ? "detected" : "not detected");
   1.229 -		printf("3DNow Ext %s\n", SDL_Has3DNowExt() ? "detected" : "not detected");
   1.230 -		printf("SSE %s\n", SDL_HasSSE() ? "detected" : "not detected");
   1.231 -		printf("SSE2 %s\n", SDL_HasSSE2() ? "detected" : "not detected");
   1.232 -		printf("AltiVec %s\n", SDL_HasAltiVec() ? "detected" : "not detected");
   1.233 -	}
   1.234 -	return(0);
   1.235 +    if (verbose) {
   1.236 +        printf ("RDTSC %s\n", SDL_HasRDTSC ()? "detected" : "not detected");
   1.237 +        printf ("MMX %s\n", SDL_HasMMX ()? "detected" : "not detected");
   1.238 +        printf ("MMX Ext %s\n",
   1.239 +                SDL_HasMMXExt ()? "detected" : "not detected");
   1.240 +        printf ("3DNow %s\n", SDL_Has3DNow ()? "detected" : "not detected");
   1.241 +        printf ("3DNow Ext %s\n",
   1.242 +                SDL_Has3DNowExt ()? "detected" : "not detected");
   1.243 +        printf ("SSE %s\n", SDL_HasSSE ()? "detected" : "not detected");
   1.244 +        printf ("SSE2 %s\n", SDL_HasSSE2 ()? "detected" : "not detected");
   1.245 +        printf ("AltiVec %s\n",
   1.246 +                SDL_HasAltiVec ()? "detected" : "not detected");
   1.247 +    }
   1.248 +    return (0);
   1.249  }
   1.250  
   1.251 -int main(int argc, char *argv[])
   1.252 +int
   1.253 +main (int argc, char *argv[])
   1.254  {
   1.255 -	SDL_bool verbose = SDL_TRUE;
   1.256 -	int status = 0;
   1.257 +    SDL_bool verbose = SDL_TRUE;
   1.258 +    int status = 0;
   1.259  
   1.260 -	if ( argv[1] && (SDL_strcmp(argv[1], "-q") == 0) ) {
   1.261 -		verbose = SDL_FALSE;
   1.262 -	}
   1.263 -	if ( verbose ) {
   1.264 -		printf("This system is running %s\n",
   1.265 +    if (argv[1] && (SDL_strcmp (argv[1], "-q") == 0)) {
   1.266 +        verbose = SDL_FALSE;
   1.267 +    }
   1.268 +    if (verbose) {
   1.269 +        printf ("This system is running %s\n",
   1.270  #if __AIX__
   1.271 -			"AIX"
   1.272 +                "AIX"
   1.273  #elif __AMIGA__
   1.274 -			"AmigaOS"
   1.275 +                "AmigaOS"
   1.276  #elif __BEOS__
   1.277 -			"BeOS"
   1.278 +                "BeOS"
   1.279  #elif __BSDI__
   1.280 -			"BSDI"
   1.281 +                "BSDI"
   1.282  #elif __DREAMCAST__
   1.283 -			"Dreamcast"
   1.284 +                "Dreamcast"
   1.285  #elif __FREEBSD__
   1.286 -			"FreeBSD"
   1.287 +                "FreeBSD"
   1.288  #elif __HPUX__
   1.289 -			"HP-UX"
   1.290 +                "HP-UX"
   1.291  #elif __IRIX__
   1.292 -			"Irix"
   1.293 +                "Irix"
   1.294  #elif __LINUX__
   1.295 -			"Linux"
   1.296 +                "Linux"
   1.297  #elif __MINT__
   1.298 -			"Atari MiNT"
   1.299 +                "Atari MiNT"
   1.300  #elif __MACOS__
   1.301 -			"MacOS Classic"
   1.302 +                "MacOS Classic"
   1.303  #elif __MACOSX__
   1.304 -			"Mac OS X"
   1.305 +                "Mac OS X"
   1.306  #elif __NETBSD__
   1.307 -			"NetBSD"
   1.308 +                "NetBSD"
   1.309  #elif __OPENBSD__
   1.310 -			"OpenBSD"
   1.311 +                "OpenBSD"
   1.312  #elif __OS2__
   1.313 -			"OS/2"
   1.314 +                "OS/2"
   1.315  #elif __OSF__
   1.316 -			"OSF/1"
   1.317 +                "OSF/1"
   1.318  #elif __QNXNTO__
   1.319 -			"QNX Neutrino"
   1.320 +                "QNX Neutrino"
   1.321  #elif __RISCOS__
   1.322 -			"RISC OS"
   1.323 +                "RISC OS"
   1.324  #elif __SOLARIS__
   1.325 -			"Solaris"
   1.326 +                "Solaris"
   1.327  #elif __WIN32__
   1.328  #ifdef _WIN32_WCE
   1.329 -			"Windows CE"
   1.330 +                "Windows CE"
   1.331  #else
   1.332 -			"Windows"
   1.333 +                "Windows"
   1.334  #endif
   1.335  #else
   1.336 -			"an unknown operating system! (see SDL_platform.h)"
   1.337 +                "an unknown operating system! (see SDL_platform.h)"
   1.338  #endif
   1.339 -		);
   1.340 -	}
   1.341 +            );
   1.342 +    }
   1.343  
   1.344 -	status += TestTypes(verbose);
   1.345 -	status += TestEndian(verbose);
   1.346 -	status += TestCPUInfo(verbose);
   1.347 -	return status;
   1.348 +    status += TestTypes (verbose);
   1.349 +    status += TestEndian (verbose);
   1.350 +    status += TestCPUInfo (verbose);
   1.351 +    return status;
   1.352  }