Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get_pid() for Windows is GetCurrentProcess()
[simgrid.git] / src / gras / Virtu / rl_process.c
1 /* $Id$ */
2
3 /* process_rl - GRAS process handling on real life                          */
4
5 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #include "gras_modinter.h" /* module initialization interface */
11 #include "gras/Virtu/virtu_rl.h"
12 #include "portable.h"
13
14 /* globals */
15 static gras_procdata_t *_gras_procdata = NULL;
16 char const *_gras_procname = NULL;
17
18 void gras_process_init() {
19   _gras_procdata=xbt_new0(gras_procdata_t,1);
20   gras_procdata_init();
21 }
22 void gras_process_exit() {
23   gras_procdata_exit();
24   free(_gras_procdata);
25 }
26
27 const char *xbt_procname(void) {
28   if(_gras_procname) return _gras_procname;
29   else return "";
30 }
31
32 long int gras_os_getpid(void) {
33         #ifdef _WIN32
34         return (long int) GetCurrentProcess();
35         #else
36         return (long int) getpid();
37         #endif
38 }
39
40 /* **************************************************************************
41  * Process data
42  * **************************************************************************/
43
44 gras_procdata_t *gras_procdata_get(void) {
45   xbt_assert0(_gras_procdata,"Run gras_process_init (ie, gras_init)!");
46
47   return _gras_procdata;
48 }