Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get_pid() for Windows is GetCurrentProcess()
[simgrid.git] / src / gras / Virtu / rl_process.c
index 7f4846f..fdb33f1 100644 (file)
@@ -1,33 +1,40 @@
 /* $Id$ */
 
-/* process_rl - GRAS process handling on real life                         */
+/* process_rl - GRAS process handling on real life                          */
 
-/* Authors: Martin Quinson                                                  */
-/* Copyright (C) 2003,2004 da GRAS posse.                                   */
+/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
 
 /* This program is free software; you can redistribute it and/or modify it
  under the terms of the license (GNU LGPL) which comes with this package. */
* under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "gras_modinter.h" /* module initialization interface */
 #include "gras/Virtu/virtu_rl.h"
-
-GRAS_LOG_EXTERNAL_CATEGORY(process);
-GRAS_LOG_DEFAULT_CATEGORY(process);
+#include "portable.h"
 
 /* globals */
 static gras_procdata_t *_gras_procdata = NULL;
+char const *_gras_procname = NULL;
 
-gras_error_t gras_process_init() {
-  gras_error_t errcode;
-
-  if (!(_gras_procdata=gras_new(gras_procdata_t,1)))
-    RAISE_MALLOC;
-
-  TRY(gras_procdata_init());
-  return no_error;
+void gras_process_init() {
+  _gras_procdata=xbt_new0(gras_procdata_t,1);
+  gras_procdata_init();
 }
-gras_error_t gras_process_exit() {
+void gras_process_exit() {
   gras_procdata_exit();
-  return no_error;
+  free(_gras_procdata);
+}
+
+const char *xbt_procname(void) {
+  if(_gras_procname) return _gras_procname;
+  else return "";
+}
+
+long int gras_os_getpid(void) {
+       #ifdef _WIN32
+       return (long int) GetCurrentProcess();
+       #else
+       return (long int) getpid();
+       #endif
 }
 
 /* **************************************************************************
@@ -35,7 +42,7 @@ gras_error_t gras_process_exit() {
  * **************************************************************************/
 
 gras_procdata_t *gras_procdata_get(void) {
-  gras_assert0(_gras_procdata,"Run gras_process_init!");
+  xbt_assert0(_gras_procdata,"Run gras_process_init (ie, gras_init)!");
 
   return _gras_procdata;
 }