3 /* gras.c -- generic functions not fitting anywhere else */
5 /* Copyright (c) 2003, 2004 Martin Quinson. */
6 /* All rights reserved. */
8 /* This program is free software; you can redistribute it and/or modify it
9 * under the terms of the license (GNU LGPL) which comes with this package. */
12 #include "xbt/module.h" /* xbt_init/exit */
14 #include "gras_modinter.h" /* module init/exit */
15 #include "xbt_modinter.h" /* module init/exit */
18 #include "gras/process.h" /* FIXME: killme and put process_init in modinter */
20 /* FIXME: move it to some random header */
21 void hexa_print(const char*name, unsigned char *data, int size);
24 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras,XBT_LOG_ROOT_CAT,"All GRAS categories (cf. section \ref GRAS_API)");
25 static int gras_running_process = 0;
27 void gras_init(int *argc,char **argv) {
29 VERB0("Initialize GRAS");
31 /* First initialize the XBT */
34 /* module registrations:
35 * - declare process specific data we need (without creating them)
37 if (gras_running_process == 0) {
43 * Initialize the process specific stuff
45 gras_process_init(); /* calls procdata_init, which creates process specific data for each module */
48 * Initialize the global stuff if it's not the first process created
50 if (gras_running_process++ == 0) {
58 void gras_exit(void) {
59 INFO0("Exiting GRAS");
60 if (--gras_running_process == 0) {
70 void hexa_print(const char*name, unsigned char *data, int size) {
73 for (i=0;i<size;i++) {
74 if (data[i]<32) /* || data[i]>'9') */
75 printf("'\\%d'",data[i]);