checkup.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : checkup                                                           *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *******************************************************************************
00007 * Copyright (c) 1990-$now By Author.  This program is free software; you can  *
00008 * redistribute it and/or modify it under the terms of the GNU General Public  *
00009 * License as published by the Free Software Foundation; either version 2 of   *
00010 * the License or (at your option) any later version.  This is online at:      *
00011 *     http://www.fsf.org/copyleft/gpl.html                                    *
00012 * Please send any updates to: fred@gruntose.com                               *
00013 \*****************************************************************************/
00014 
00015 #include "checkup.h"
00016 
00017 #include <basis/guards.h>
00018 #include <basis/istring.h>
00019 
00020 namespace system_checkup {
00021 
00022 bool check_system_characteristics()
00023 {
00024   // a big assumption is that the size of an unsigned character is just
00025   // one byte.  if this is not true, probably many things would break...
00026   int byte_size = sizeof(byte);
00027   if (byte_size != 1) {
00028     continuable_error("check", "system_characteristics",
00029         "byte size should be 1 and it is not!");
00030     return false;
00031   }
00032   int int16_size = sizeof(int16);
00033   if ( (sizeof(uint16) != int16_size) || (int16_size != 2) ) {
00034     continuable_error("check", "system_characteristics",
00035         "uint16 size is inappropriate!");
00036     return false;
00037   }
00038   int uint_size = sizeof(u_int);
00039 //hmmm: the checks are actually redundant...
00040   if ( (uint_size != sizeof(int)) || (uint_size != 4) ) {
00041     continuable_error("check", "system_characteristics",
00042         "u_int size is inappropriate!");
00043     return false;
00044   }
00045   // we check size_t, because we are just ensuring that this is never
00046   // made into a better size for recognizing file sizes.  currently, size_t
00047   // fails at the 4 gig mark.
00048   int size_t_size = sizeof(size_t);
00049   if ( (size_t_size != uint_size) || (size_t_size != 4) ) {
00050     continuable_error("check", "system_characteristics",
00051         "size_t size is inappropriate!");
00052     return false;
00053   }
00054   int long_size = sizeof(long);
00055   if (long_size != uint_size) {
00056     continuable_error("check", "system_characteristics",
00057         isprintf("long size is larger than expected: it is %d instead "
00058             "of %d", long_size, uint_size));
00059   }
00060 
00061 
00062 //hmmm: bad assumption.  we must root this out.
00063   // another big assumption; that ints are capable of holding memory addresses.
00064   int int_size = sizeof(int);
00065   int addr_size = sizeof(void *);
00066   if (int_size < addr_size) {
00067     continuable_error("check", "system_characteristics",
00068         "int size is less than address size!  it should be at least equal.");
00069     return false;
00070   }
00071 
00072   // all tests successfully passed.
00073   return true;
00074 }
00075 
00076 } // namespace
00077 

Generated on Fri Nov 28 04:29:34 2008 for HOOPLE Libraries by  doxygen 1.5.1