00001 /** 00002 \file Robots/LoBot/util/LoSysConf.C 00003 \brief System configuration related functions. 00004 */ 00005 00006 // //////////////////////////////////////////////////////////////////// // 00007 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00008 // by the University of Southern California (USC) and the iLab at USC. // 00009 // See http://iLab.usc.edu for information about this project. // 00010 // //////////////////////////////////////////////////////////////////// // 00011 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00012 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00013 // in Visual Environments, and Applications'' by Christof Koch and // 00014 // Laurent Itti, California Institute of Technology, 2001 (patent // 00015 // pending; application number 09/912,225 filed July 23, 2001; see // 00016 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00017 // //////////////////////////////////////////////////////////////////// // 00018 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00019 // // 00020 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00021 // redistribute it and/or modify it under the terms of the GNU General // 00022 // Public License as published by the Free Software Foundation; either // 00023 // version 2 of the License, or (at your option) any later version. // 00024 // // 00025 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00026 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00027 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00028 // PURPOSE. See the GNU General Public License for more details. // 00029 // // 00030 // You should have received a copy of the GNU General Public License // 00031 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00032 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00033 // Boston, MA 02111-1307 USA. // 00034 // //////////////////////////////////////////////////////////////////// // 00035 // 00036 // Primary maintainer for this file: mviswana usc edu 00037 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/util/LoSysConf.C $ 00038 // $Id: LoSysConf.C 13967 2010-09-18 08:00:07Z mviswana $ 00039 // 00040 00041 //------------------------------ HEADERS -------------------------------- 00042 00043 // lobot headers 00044 #include "Robots/LoBot/util/LoSysConf.H" 00045 00046 // Standard Unix headers 00047 #include <unistd.h> 00048 00049 //----------------------------- NAMESPACE ------------------------------- 00050 00051 namespace lobot { 00052 00053 //---------------------- SYSTEM CONFIG FUNCTIONS ------------------------ 00054 00055 // Return the number of processors available on the system 00056 int num_cpu() 00057 { 00058 #ifdef _SC_NPROCESSORS_ONLN 00059 long n = sysconf(_SC_NPROCESSORS_ONLN) ; 00060 return (n < 1) ? 1 : static_cast<int>(n) ; 00061 #else // sysconf not setup to determine num CPU's 00062 return 1 ; 00063 #endif 00064 } 00065 00066 // Return maximum file name length for given directory 00067 int maxlen_filename(const char* path) 00068 { 00069 long n = pathconf(path, _PC_NAME_MAX) ; 00070 return (n == -1) ? 255 // no limit? make up some reasonable number 00071 : static_cast<int>(n) ; 00072 } 00073 00074 //----------------------------------------------------------------------- 00075 00076 } // end of namespace encapsulating this file's definitions 00077 00078 /* So things look consistent in everyone's emacs... */ 00079 /* Local Variables: */ 00080 /* indent-tabs-mode: nil */ 00081 /* End: */