X-Git-Url: https://rtime.felk.cvut.cz/gitweb/frescor/frsh-include.git/blobdiff_plain/c53673feac3326fbb83a368bd453c70c7c39ab91..HEAD:/frsh_error.h diff --git a/frsh_error.h b/frsh_error.h index 32765e2..47e4430 100644 --- a/frsh_error.h +++ b/frsh_error.h @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// Copyright (C) 2006 - 2007 FRESCOR consortium partners: +// Copyright (C) 2006 - 2009 FRESCOR consortium partners: // // Universidad de Cantabria, SPAIN // University of York, UK @@ -12,7 +12,7 @@ // Visual Tools S.A. SPAIN // Rapita Systems Ltd UK // Evidence ITALY -// +// // See http://www.frescor.org for a link to partners' websites // // FRESCOR project (FP6/2005/IST/5-034026) is funded @@ -22,7 +22,7 @@ // // // based on previous work (FSF) done in the FIRST project -// +// // Copyright (C) 2005 Mälardalen University, SWEDEN // Scuola Superiore S.Anna, ITALY // Universidad de Cantabria, SPAIN @@ -31,29 +31,26 @@ // FSF API web pages: http://marte.unican.es/fsf/docs // http://shark.sssup.it/contrib/first/docs/ // -// This file is part of FRSH API -// -// FRSH API is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or (at your option) -// any later version. +// This file is part of FRSH (FRescor ScHeduler) // -// FRSH API is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. +// FRSH is free software; you can redistribute it and/or modify it +// under terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) any +// later version. FRSH is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. You should have received a +// copy of the GNU General Public License along with FRSH; see file +// COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, +// Cambridge, MA 02139, USA. // -// You should have received a copy of the GNU General Public License -// distributed with FRSH API; see file COPYING. If not, write to the -// Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -// As a special exception, if you include this header file into source -// files to be compiled, this header file does not by itself cause -// the resulting executable to be covered by the GNU General Public -// License. This exception does not however invalidate any other -// reasons why the executable file might be covered by the GNU General -// Public License. +// As a special exception, including FRSH header files in a file, +// instantiating FRSH generics or templates, or linking other files +// with FRSH objects to produce an executable application, does not +// by itself cause the resulting executable application to be covered +// by the GNU General Public License. This exception does not +// however invalidate any other reasons why the executable file might be +// covered by the GNU Public License. // ----------------------------------------------------------------------- //frsh_error.h //============================================== @@ -64,7 +61,7 @@ // **//// /**///** ////////** /**//////** // ** /** //** /** /** /** // ** /** //** ******** /** /** -// // // // //////// // // +// // // // //////// // // // // FRSH(FRescor ScHeduler), pronounced "fresh" //============================================== @@ -72,6 +69,10 @@ #ifndef FRSH_ERROR_H_ #define FRSH_ERROR_H_ +#ifdef __cplusplus +extern "C" { +#endif + /** * @file frsh_error.h **/ @@ -119,22 +120,32 @@ #define FRSH_WRN_MODULE_NOT_SUPPORTED 0x0200401E #define FRSH_ERR_NOT_INITIALIZED 0x0200401F #define FRSH_ERR_TOO_MANY_SHARED_OBJS 0x02004020 -#define FRSH_ERR_CONTRACT_ID_ALREADY_EXISTS 0x02004021 +#define FRSH_ERR_CONTRACT_LABEL_ALREADY_EXISTS 0x02004021 #define FRSH_ERR_BUDGET_EXPIRED 0x02004022 #define FRSH_ERR_SHARED_OBJECT_NOT_PROTECTED 0x02004023 #define FRSH_ERR_NOT_IMPLEMENTED 0x02004024 #define FRSH_ERR_CONTRACT_TYPE_NOT_COMPATIBLE 0x02004025 #define FRSH_ERR_CAPACITY_NOT_DECREASING 0x02004026 +#define FRSH_ERR_CONTRACT_LABEL_UNKNOWN 0x02004027 +#define FRSH_ERR_OUT_OF_BUDGET 0x02004028 +#define FRSH_ERR_ALREADY_IN_FRSH 0x02004029 -#define FRSH_ERR_LAST_VALUE 0x02004027 +#define FRSH_ERR_LAST_VALUE 0x02004030 -#define ERROR(nn,ss) do {if(nn>FRSH_ERR_BASE_VALUE) my_frsh_strerror(nn, ss); else perror(ss); exit (nn);} while (0) + + +#ifdef AQuoSA +#define my_frsh_perror(nn,ss) do { errno = nn; perror(ss); } while(0) +#else +#define my_frsh_perror(nn,ss) do { perror(ss); } while(0) +#endif + +#define ERROR(nn,ss) do {if(nn>FRSH_ERR_BASE_VALUE) my_frsh_strerror(nn, ss); else { my_frsh_perror(nn, ss); } exit (nn);} while (0) int frsh_strerror (int error, char *message, size_t size); void my_frsh_strerror(int error, char *sss); - /** * This str_helper is needed to ensure argument expansion, * see http://www.iar.com/p180591/p180591_eng.php @@ -153,37 +164,15 @@ void my_frsh_strerror(int error, char *sss); \ char error_string[1024]; \ \ - sprintf(error_string, "File: %s, at line %d, error %d: %s", __FILE__, __LINE__, (_nn_), _ss_); \ + sprintf(error_string, "File: %s, in function %s at line %d, error %d: %s\n", __FILE__, __FUNCTION__, __LINE__, (_nn_), _ss_); \ \ if( (_nn_)>FRSH_ERR_BASE_VALUE ) { \ my_frsh_strerror( (_nn_), error_string); \ } else { \ - perror(error_string); \ + my_frsh_perror(_nn_, error_string); \ } \ -} while(0) +} while(0) -/** - * PERROR_FRESCOR_FUNCNAME - * - * This macro checks the given error number and composes a messages accordingly. - * - * FUNCNAME (char *) has to point to the current function name. - * - * @param nn Error number - * @param ss Error string (to be appended to FRSH or system error string) - * - **/ -#define PERROR_FRESCOR_FUNCNAME(_nn_,_ss_) do { \ - \ - char error_string[1024]; \ - \ - sprintf(error_string, "File: %s, in function %s at line %d, error %d: %s", __FILE__, FUNCNAME, __LINE__, (_nn_), _ss_); \ - if( (_nn_) > FRSH_ERR_BASE_VALUE ) { \ - my_frsh_strerror( (_nn_), error_string); \ - } else { \ - perror(error_string); \ - } \ -} while(0) /** @@ -200,22 +189,6 @@ void my_frsh_strerror(int error, char *sss); return (nn); \ } while (0) -/** - * PERROR_AND_RETURN_FUNCNAME - * - * Macro that displays an error code and message and then returns from - * the current function - * - * FUNCNAME (char *) has to point to the current function name. - * - * @param nn Error number - * @param ss Error string (to be appended to FRSH or system error string) - **/ -#define PERROR_AND_RETURN_FUNCNAME(nn,ss) do { \ - PERROR_FRESCOR_FUNCNAME(nn, ss); \ - return (nn); \ - } while (0) - @@ -234,22 +207,6 @@ void my_frsh_strerror(int error, char *sss); } while (0) -/** - * PERROR_AND_EXIT_FUNCNAME - * - * Macro that displays an error code and message and then aborts the - * program. - * - * FUNCNAME (char *) has to point to the current function name. - * - * @param nn Error number - * @param ss Error string (to be appended to FRSH or system error string) - **/ -#define PERROR_AND_EXIT_FUNCNAME(nn,ss) do { \ - PERROR_FRESCOR_FUNCNAME(nn,ss); \ - exit(nn); \ - } while (0) - /** * PRW: Perror and Return Wrapper * @@ -260,7 +217,7 @@ void my_frsh_strerror(int error, char *sss); * terror (int) needs to be visible in the point of call. * * @param funccall Code to execute that should return 0 in a non error - * case. + * case. **/ #define PRW(funccall) do { \ if ( (terror = funccall ) != 0) \ @@ -270,22 +227,6 @@ void my_frsh_strerror(int error, char *sss); } while(0) -/** - * PRFW: Perror and Return Funcname Wrapper - * - * Function that displays an error code and message and then returns from - * the current function and returns from the function.. - * - * @param nn Error number - * @param ss Error string (to be appended to FRSH or system error string) - **/ -#define PRFW(funccall) do { \ - if ( (terror = funccall ) != 0) \ - { \ - PERROR_AND_RETURN_FUNCNAME( terror, STR_HELPER(funccall) ); \ - } \ -} while(0) - /** * PXW: Perror and eXit Wrapper @@ -297,7 +238,7 @@ void my_frsh_strerror(int error, char *sss); * terror (int) needs to be visible in the point of call. * * @param funccall Code to execute that should return 0 in a non error - * case. + * case. **/ #define PXW(funccall) do { \ if ( (terror = funccall ) != 0) \ @@ -308,23 +249,6 @@ void my_frsh_strerror(int error, char *sss); -/** - * PXFW: Perror and eXit Funcname Wrapper - * - * Function that displays an error code and message and then returns from - * the current function - * - * @param nn Error number - * @param ss Error string (to be appended to FRSH or system error string) - **/ -#define PXFW(funccall) do { \ - if ( (terror = funccall ) != 0) \ - { \ - PERROR_AND_EXIT_FUNCNAME( terror, STR_HELPER(funccall) ); \ - } \ -} while(0) - - /** * PERROR_KERN_AND_EXIT * @@ -345,4 +269,9 @@ void my_frsh_strerror(int error, char *sss); /*}*/ +#ifdef __cplusplus +} +#endif + + #endif /* !FRSH_ERROR_H_ */