Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

util.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright 2005 Daniel Ferullo                                             *
00003  *                                                                           *
00004  * Licensed under the Apache License, Version 2.0 (the "License");           *
00005  * you may not use this file except in compliance with the License.          *
00006  * You may obtain a copy of the License at                                   *
00007  *                                                                           *
00008  *    http://www.apache.org/licenses/LICENSE-2.0                             *
00009  *                                                                           *
00010  * Unless required by applicable law or agreed to in writing, software       *
00011  * distributed under the License is distributed on an "AS IS" BASIS,         *
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  *
00013  * See the License for the specific language governing permissions and       *
00014  * limitations under the License.                                            *
00015  *                                                                           *
00016  *****************************************************************************/
00017 
00018 /**
00019  * @file util.h
00020  * @author Daniel Ferullo (ferullo@cmu.edu)
00021  *
00022  * @brief contains useful utility functions
00023  */
00024 
00025 #ifndef __UTIL_H__
00026 #define __UTIL_H__
00027 
00028 #include "errorcodes.h"
00029 #include "flag.h"
00030 
00031 /**
00032  * @brief decrements a signed number by one, but not past zero
00033  *
00034  * @param x The number to decrement
00035  * @return The decremented value
00036  **/
00037 int inline DEC_UNTIL_ZERO(int x);
00038 
00039 /** @brief a macro to determine if two boolean values are the same (ie both
00040  *  true or both false */
00041 #define BOOL_MATCH(x,y) ( (((x)!=0)&&((y)!=0))||(((x)==0)&&((y)==0)) ? 1 : 0)
00042 
00043 /**
00044  * @brief a 'safe' free
00045  *
00046  * @param memory pointer to the memory to free
00047  *
00048  * @return SUCCESS, errorcode on failure
00049  */
00050 errorcode safe_free(void *memory);
00051 
00052 /**
00053  * @brief waits for a flag to take one of many specified values
00054  *
00055  * Success if the check_flag takes on any one of the stop_flags before timeout
00056  *
00057  * @param check_flag pointer to the flag to watch
00058  * @param stop_flags all the flags to wait for or'ed together.
00059  * @param timeout the timeout time, in seconds
00060  *
00061  * @return SUCCESS, errorcode on failure
00062  */
00063 errorcode wait_for_flag(flag_t *check_flag, flag_t stop_flags, int timeout);
00064 
00065 #endif /* __UTIL_H__ */
00066 

Generated on Wed Mar 30 23:20:47 2005 for NATBLASTER by  doxygen 1.3.9.1