root/jalibinterface.cpp
/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- initializeJalib
1 /****************************************************************************
2 * Copyright (C) 2006-2013 by Jason Ansel, Kapil Arya, and Gene Cooperman *
3 * jansel@csail.mit.edu, kapil@ccs.neu.edu, gene@ccs.neu.edu *
4 * *
5 * This file is part of DMTCP. *
6 * *
7 * DMTCP is free software: you can redistribute it and/or *
8 * modify it under the terms of the GNU Lesser General Public License as *
9 * published by the Free Software Foundation, either version 3 of the *
10 * License, or (at your option) any later version. *
11 * *
12 * DMTCP is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU Lesser General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with DMTCP:dmtcp/src. If not, see *
19 * <http://www.gnu.org/licenses/>. *
20 ****************************************************************************/
21
22 #include "dmtcp.h"
23 #include "protectedfds.h"
24 #include "util.h"
25 #include "syscallwrappers.h"
26 #include "../jalib/jalib.h"
27
28 using namespace dmtcp;
29
30 extern "C" void initializeJalib()
31 {
32 jalib::JalibFuncPtrs jalibFuncPtrs;
33
34 #define INIT_JALIB_FPTR(name) jalibFuncPtrs.name = _real_ ## name;
35
36 jalibFuncPtrs.writeAll = Util::writeAll;
37 jalibFuncPtrs.readAll = Util::readAll;
38
39 INIT_JALIB_FPTR(open);
40 INIT_JALIB_FPTR(fopen);
41 INIT_JALIB_FPTR(close);
42 INIT_JALIB_FPTR(fclose);
43 INIT_JALIB_FPTR(dup);
44 INIT_JALIB_FPTR(dup2);
45 INIT_JALIB_FPTR(readlink);
46
47 INIT_JALIB_FPTR(syscall);
48 INIT_JALIB_FPTR(mmap);
49 INIT_JALIB_FPTR(munmap);
50
51 INIT_JALIB_FPTR(read);
52 INIT_JALIB_FPTR(write);
53 INIT_JALIB_FPTR(select);
54
55 INIT_JALIB_FPTR(socket);
56 INIT_JALIB_FPTR(connect);
57 INIT_JALIB_FPTR(bind);
58 INIT_JALIB_FPTR(listen);
59 INIT_JALIB_FPTR(accept);
60 INIT_JALIB_FPTR(setsockopt);
61
62 INIT_JALIB_FPTR(pthread_mutex_lock);
63 INIT_JALIB_FPTR(pthread_mutex_trylock);
64 INIT_JALIB_FPTR(pthread_mutex_unlock);
65
66 jalib_init(jalibFuncPtrs,
67 ELF_INTERPRETER,
68 PROTECTED_STDERR_FD,
69 PROTECTED_JASSERTLOG_FD,
70 DMTCP_FAIL_RC);
71 }