test/testplatform.c
changeset 1895 c121d94672cb
parent 1621 f12379c41042
child 2062 c9aa6bcb26f3
     1.1 --- a/test/testplatform.c	Thu Jul 06 18:01:37 2006 +0000
     1.2 +++ b/test/testplatform.c	Mon Jul 10 21:04:37 2006 +0000
     1.3 @@ -10,200 +10,206 @@
     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", SDL_HasMMXExt()? "detected" : "not detected");
   1.239 +        printf("3DNow %s\n", SDL_Has3DNow()? "detected" : "not detected");
   1.240 +        printf("3DNow Ext %s\n",
   1.241 +               SDL_Has3DNowExt()? "detected" : "not detected");
   1.242 +        printf("SSE %s\n", SDL_HasSSE()? "detected" : "not detected");
   1.243 +        printf("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected");
   1.244 +        printf("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected");
   1.245 +    }
   1.246 +    return (0);
   1.247  }
   1.248  
   1.249 -int main(int argc, char *argv[])
   1.250 +int
   1.251 +main(int argc, char *argv[])
   1.252  {
   1.253 -	SDL_bool verbose = SDL_TRUE;
   1.254 -	int status = 0;
   1.255 +    SDL_bool verbose = SDL_TRUE;
   1.256 +    int status = 0;
   1.257  
   1.258 -	if ( argv[1] && (SDL_strcmp(argv[1], "-q") == 0) ) {
   1.259 -		verbose = SDL_FALSE;
   1.260 -	}
   1.261 -	if ( verbose ) {
   1.262 -		printf("This system is running %s\n",
   1.263 +    if (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) {
   1.264 +        verbose = SDL_FALSE;
   1.265 +    }
   1.266 +    if (verbose) {
   1.267 +        printf("This system is running %s\n",
   1.268  #if __AIX__
   1.269 -			"AIX"
   1.270 +               "AIX"
   1.271  #elif __AMIGA__
   1.272 -			"AmigaOS"
   1.273 +               "AmigaOS"
   1.274  #elif __BEOS__
   1.275 -			"BeOS"
   1.276 +               "BeOS"
   1.277  #elif __BSDI__
   1.278 -			"BSDI"
   1.279 +               "BSDI"
   1.280  #elif __DREAMCAST__
   1.281 -			"Dreamcast"
   1.282 +               "Dreamcast"
   1.283  #elif __FREEBSD__
   1.284 -			"FreeBSD"
   1.285 +               "FreeBSD"
   1.286  #elif __HPUX__
   1.287 -			"HP-UX"
   1.288 +               "HP-UX"
   1.289  #elif __IRIX__
   1.290 -			"Irix"
   1.291 +               "Irix"
   1.292  #elif __LINUX__
   1.293 -			"Linux"
   1.294 +               "Linux"
   1.295  #elif __MINT__
   1.296 -			"Atari MiNT"
   1.297 +               "Atari MiNT"
   1.298  #elif __MACOS__
   1.299 -			"MacOS Classic"
   1.300 +               "MacOS Classic"
   1.301  #elif __MACOSX__
   1.302 -			"Mac OS X"
   1.303 +               "Mac OS X"
   1.304  #elif __NETBSD__
   1.305 -			"NetBSD"
   1.306 +               "NetBSD"
   1.307  #elif __OPENBSD__
   1.308 -			"OpenBSD"
   1.309 +               "OpenBSD"
   1.310  #elif __OS2__
   1.311 -			"OS/2"
   1.312 +               "OS/2"
   1.313  #elif __OSF__
   1.314 -			"OSF/1"
   1.315 +               "OSF/1"
   1.316  #elif __QNXNTO__
   1.317 -			"QNX Neutrino"
   1.318 +               "QNX Neutrino"
   1.319  #elif __RISCOS__
   1.320 -			"RISC OS"
   1.321 +               "RISC OS"
   1.322  #elif __SOLARIS__
   1.323 -			"Solaris"
   1.324 +               "Solaris"
   1.325  #elif __WIN32__
   1.326  #ifdef _WIN32_WCE
   1.327 -			"Windows CE"
   1.328 +               "Windows CE"
   1.329  #else
   1.330 -			"Windows"
   1.331 +               "Windows"
   1.332  #endif
   1.333  #else
   1.334 -			"an unknown operating system! (see SDL_platform.h)"
   1.335 +               "an unknown operating system! (see SDL_platform.h)"
   1.336  #endif
   1.337 -		);
   1.338 -	}
   1.339 +            );
   1.340 +    }
   1.341  
   1.342 -	status += TestTypes(verbose);
   1.343 -	status += TestEndian(verbose);
   1.344 -	status += TestCPUInfo(verbose);
   1.345 -	return status;
   1.346 +    status += TestTypes(verbose);
   1.347 +    status += TestEndian(verbose);
   1.348 +    status += TestCPUInfo(verbose);
   1.349 +    return status;
   1.350  }