shared_LIBRARIES = contract
-contract_SOURCES = fres_contract.c fres_container.c
+contract_SOURCES = fres_contract.c fres_container.c fres_error.c
contract_CLIENT_IDL = fres_contract_idl.idl fres_blocks.idl
fres_contract_idl_IDLFLAGS = --include=fres_contract_type.h
include_HEADERS = fres_container.h fres_container_type.h \
fres_contract_type.h fres_container_internal.h \
- idl_native.h fres_contract.h
+ idl_native.h fres_contract.h fres_error.h
include_GEN_HEADERS = fres_contract_idl.h fres_blocks.h
--- /dev/null
+// -----------------------------------------------------------------------
+// Copyright (C) 2006 - 2008 FRESCOR consortium partners:
+//
+// Universidad de Cantabria, SPAIN
+// University of York, UK
+// Scuola Superiore Sant'Anna, ITALY
+// Kaiserslautern University, GERMANY
+// Univ. Politécnica Valencia, SPAIN
+// Czech Technical University in Prague, CZECH REPUBLIC
+// ENEA SWEDEN
+// Thales Communication S.A. FRANCE
+// 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
+// in part by the European Union Sixth Framework Programme
+// The European Union is not liable of any use that may be
+// made of this code.
+//
+//
+// 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
+// University of York, UK
+//
+// FSF API web pages: http://marte.unican.es/fsf/docs
+// http://shark.sssup.it/contrib/first/docs/
+//
+// This file is part of FRSH (FRescor ScHeduler)
+//
+// 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.
+//
+// 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(FRescor ScHeduler), pronounced "fresh"
+//==============================================
+
+#include <string.h>
+#include "fres_error.h"
+#include <frsh_error.h>
+
+/**
+ * fres_strerror()
+ *
+ * This function converts an error code to an error message that is
+ * stored in the buffer starting at the location pointed to by
+ * message. The size of this buffer is specified by the size
+ * argument. If the error message is longer than size-1, it is
+ * truncated to that length. Regardless of whether the message is
+ * truncated or not, a final zero character that marks the end of the
+ * string is stored in the buffer. The function fails if the error
+ * code passed does not correspond to any of the fres error codes.
+ * [@return:
+ * FRSH_ERR_BAD_ARGUMENT : error is not a valid value
+ * ]
+ **/
+int fres_strerror (int error, char *message, size_t size)
+{
+ char *s = NULL;
+ enum fres_error e = error;
+
+#define MSG(error) case FRES_ERR_##error: s = #error; break
+
+ switch (e) {
+ MSG(FCB_NOT_RUNNING);
+ }
+
+ if (s == NULL) return FRSH_ERR_BAD_ARGUMENT;
+
+ if (message != NULL && size > 0) {
+ strncpy(message, s, size);
+ message[size-1] = '\0';
+ }
+
+ return 0;
+}
--- /dev/null
+#ifndef FRES_ERROR_H
+#define FRES_ERROR_H
+
+#define FRES_ERR_BASE_VALUE 0x02008000
+
+enum fres_error {
+ FRES_ERR_FCB_NOT_RUNNING = FRES_ERR_BASE_VALUE,
+};
+
+int fres_strerror (int error, char *message, size_t size);
+
+
+#endif
+++ /dev/null
-////////////////////////////////////////////////////////////////////////////
-// ---------------------------------------------------------------------- //
-// Copyright (C) 2006 - 2008 FRESCOR consortium partners: //
-// //
-// Universidad de Cantabria, SPAIN //
-// University of York, UK //
-// Scuola Superiore Sant'Anna, ITALY //
-// Kaiserslautern University, GERMANY //
-// Univ. Politécnica Valencia, SPAIN //
-// Czech Technical University in Prague, CZECH REPUBLIC //
-// ENEA SWEDEN //
-// Thales Communication S.A. FRANCE //
-// 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 //
-// in part by the European Union Sixth Framework Programme //
-// The European Union is not liable of any use that may be //
-// made of this code. //
-// //
-// //
-// 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 //
-// University of York, UK //
-// //
-// FSF API web pages: http:marte.unican.es/fsf/docs //
-// http:shark.sssup.it/contrib/first/docs/ //
-// //
-// This file is part of FORB (Frescor Object Request Broker) //
-// //
-// FORB 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. FORB 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 FORB; see file //
-// COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, //
-// Cambridge, MA 02139, USA. //
-// //
-// As a special exception, including FORB header files in a file, //
-// instantiating FORB generics or templates, or linking other files //
-// with FORB 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. //
-////////////////////////////////////////////////////////////////////////////
-
-#ifndef _CM_IDL
-#define _CM_IDL
-
-#include "contract/fres_contract_idl.idl"
-#include "contract/fres_blocks.idl"
-#include "frm.idl"
-#include "frs.idl"
-
-module fres {
- interface contract_broker {
- const string reg_name = "fcb";
- /**
- * Registers a resource manager with the contract broker
- *
- * @param restype
- * @param resid
- * @param rm_obj
- *
- * @return Zero on success, non-zero error code on error.
- */
- long register_manager(in frsh_resource_type_t restype,
- in frsh_resource_id_t resid,
- in resource_manager rm_obj);
-
- /**
- * Registers a resource scheduler with the contract broker
- *
- * @param restype
- * @param resid
- * @param rs_obj
- *
- * @return Zero on success, non-zero error code on error.
- */
- long register_scheduler(in frsh_resource_type_t restype,
- in frsh_resource_id_t resid,
- in resource_scheduler rs_obj);
-
-
- /**
- * Tries to negotiate a contract
- *
- * @param[in] contract Contract to negotiate
- *
- * @param[out] id Global ID of the contract if
- * negotiation was successful.
- *
- * @return Zero if the contract was successfully
- * negotiated, non-zero code on error or when
- * negotiation failed.
- */
- long negotiate_contract(in contract::ptr contract, out fres::contract::id_t id);
- };
-};
-
-#endif
global.fcb = forb_resolve_reference(global.orb,
fres_contract_broker_reg_name);
- if (!global.fcb) return FRSH_ERR_NOT_INITIALIZED;
+ if (!global.fcb) return FRES_ERR_FCB_NOT_RUNNING;
return 0;
}
+
--- /dev/null
+// -----------------------------------------------------------------------
+// Copyright (C) 2006 - 2008 FRESCOR consortium partners:
+//
+// Universidad de Cantabria, SPAIN
+// University of York, UK
+// Scuola Superiore Sant'Anna, ITALY
+// Kaiserslautern University, GERMANY
+// Univ. Politécnica Valencia, SPAIN
+// Czech Technical University in Prague, CZECH REPUBLIC
+// ENEA SWEDEN
+// Thales Communication S.A. FRANCE
+// 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
+// in part by the European Union Sixth Framework Programme
+// The European Union is not liable of any use that may be
+// made of this code.
+//
+//
+// 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
+// University of York, UK
+//
+// FSF API web pages: http://marte.unican.es/fsf/docs
+// http://shark.sssup.it/contrib/first/docs/
+//
+// This file is part of FRSH (FRescor ScHeduler)
+//
+// 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.
+//
+// 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(FRescor ScHeduler), pronounced "fresh"
+//==============================================
+
+#include <stdio.h>
+#include <string.h>
+
+#include <frsh.h>
+#include <fres_error.h>
+
+
+////////////////////////////////////////////////////////////////////////
+// ERROR REPORTING
+////////////////////////////////////////////////////////////////////////
+
+/* Use to debug an error condition */
+/***********************************/
+int global_error_condition = 0;
+
+
+
+/* These variables get initialised in frsh_init() */
+/**************************************************/
+fosa_abs_time_t frsh_trace_init_timespec;
+long frsh_trace_init_timemsec = -1;
+
+
+//error codes to message section
+static const int frsh_strerror_table_size = FRSH_ERR_LAST_VALUE-FRSH_ERR_BASE_VALUE;
+static char * frsh_strerror_table[] =
+{
+ "TOO_MANY_TASKS ",
+ "BAD_ARGUMENT ",
+ "INVALID_SYNCH_OBJ_HANDLE ",
+ "NO_RENEGOTIATION_REQUESTED ",
+ "CONTRACT_REJECTED ",
+ "NOT_SCHEDULED_CALLING_THREAD ",
+ "NOT_BOUND_THREAD ",
+ "UNKNOWN_SCHEDULED_THREAD ",
+ "NOT_CONTRACTED_SERVER ",
+ "NOT_SCHEDULED_THREAD ",
+ "TOO_MANY_SERVICE_JOBS ",
+ "TOO_MANY_SYNCH_OBJS ",
+ "TOO_MANY_SERVERS_IN_SYNCH_OBJ ",
+ "TOO_MANY_EVENTS_IN_SYNCH_OBJ ",
+ "INTERNAL_ERROR ",
+ "TOO_MANY_SERVERS ",
+ "INVALID_SCHEDULER_REPLY ",
+ "TOO_MANY_PENDING_REPLENISHMENTS",
+ "SYSTEM_ALREADY_INITIALIZED ",
+ "SHARED_OBJ_ALREADY_INITIALIZED ",
+ "SHARED_OBJ_NOT_INITIALIZED ",
+ "SCHED_POLICY_NOT_COMPATIBLE ",
+ "SERVER_WORKLOAD_NOT_COMPATIBLE ",
+ "ALREADY_BOUND ",
+ "WRONG_NETWORK ",
+ "TOO_LARGE ",
+ "BUFFER_FULL ",
+ "NO_SPACE ",
+ "NO_MESSAGES ",
+ "MODULE_NOT_SUPPORTED ",
+ "SYSTEM_NOT_INITIALIZED ",
+ "TOO_MANY_SHARED_OBJS ",
+ "CONTRACT_LABEL_ALREADY_EXISTS ",
+ "BUDGET_EXPIRED ",
+ "SHARED_OBJECT_NOT_PROTECTED ",
+ "NOT_IMPLEMENTED ",
+ "CONTRACT_TYPE_NOT_COMPATIBLE ",
+ "CAPACITY_NOT_DECREASING ",
+ "CONTRACT_LABEL_UNKNOWN "
+};
+
+
+
+/**
+ * frsh_strerror()
+ *
+ * This function converts an error code to an error message that is
+ * stored in the buffer starting at the location pointed to by
+ * message. The size of this buffer is specified by the size
+ * argument. If the error message is longer than size-1, it is
+ * truncated to that length. Regardless of whether the message is
+ * truncated or not, a final zero character that marks the end of the
+ * string is stored in the buffer. The function fails if the error
+ * code passed does not correspond to any of the frsh error codes.
+ * [@return:
+ * FRSH_ERR_BAD_ARGUMENT : error is not a valid value
+ * ]
+ **/
+int frsh_strerror (int error, char *message, size_t size)
+{
+ char *s;
+ int ret;
+
+ ret = fres_strerror(error, message, size);
+ if (ret == 0) return 0;
+
+ if ((error > FRSH_ERR_LAST_VALUE) ||
+ (error <= FRSH_ERR_BASE_VALUE))
+ return FRSH_ERR_BAD_ARGUMENT;
+
+ s = frsh_strerror_table[error - FRSH_ERR_BASE_VALUE -1];
+
+ if ( message != NULL && size > 0) {
+ strncpy(message, s, size);
+ message[size-1] = '\0';
+ }
+
+ return 0;
+}
+
+/* ------------------------------------------------------------------------------------ */
+void my_frsh_strerror(int error, char *sss)
+{
+ char s[32];
+ frsh_strerror(error, s, 32);
+ printf("(%x ", error);
+ printf(s);
+ printf(") ");
+ printf(sss);
+}
#include <fres_contract_type.h>
#include <frsh_cpp_macros.h>
#include <fres_contract_idl.h>
+#include <fres_error.h>
FRSH_CPP_BEGIN_DECLS