root/mtcp/restore_libc.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*****************************************************************************
   2  * Copyright (C) 2010-2014 Kapil Arya <kapil@ccs.neu.edu>                    *
   3  * Copyright (C) 2010-2014 Gene Cooperman <gene@ccs.neu.edu>                 *
   4  *                                                                           *
   5  * DMTCP is free software: you can redistribute it and/or                    *
   6  * modify it under the terms of the GNU Lesser General Public License as     *
   7  * published by the Free Software Foundation, either version 3 of the        *
   8  * License, or (at your option) any later version.                           *
   9  *                                                                           *
  10  * DMTCP is distributed in the hope that it will be useful,                  *
  11  * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
  12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
  13  * GNU Lesser General Public License for more details.                       *
  14  *                                                                           *
  15  * You should have received a copy of the GNU Lesser General Public          *
  16  * License along with DMTCP.  If not, see <http://www.gnu.org/licenses/>.    *
  17  *****************************************************************************/
  18 
  19 #ifndef TLSINFO_H
  20 #define TLSINFO_H
  21 
  22 #include "ldt.h"
  23 #include "protectedfds.h"
  24 #include "mtcp_header.h"
  25 
  26 #ifdef __cplusplus
  27 extern "C" {
  28 #endif
  29 
  30 #ifdef __x86_64__
  31 # define eax rax
  32 # define ebx rbx
  33 # define ecx rcx
  34 # define edx rax
  35 # define ebp rbp
  36 # define esi rsi
  37 # define edi rdi
  38 # define esp rsp
  39 # define CLEAN_FOR_64_BIT(args...) CLEAN_FOR_64_BIT_HELPER(args)
  40 # define CLEAN_FOR_64_BIT_HELPER(args...) #args
  41 #elif __i386__
  42 # define CLEAN_FOR_64_BIT(args...) #args
  43 #else
  44 # define CLEAN_FOR_64_BIT(args...) "CLEAN_FOR_64_BIT_undefined"
  45 #endif
  46 
  47 #define PRINTF(fmt, ...) \
  48   do { \
  49     /* In some cases, the user stack may be very small (less than 10KB). */ \
  50     /* We will overrun the buffer with just two extra stack frames. */ \
  51     char buf[256]; \
  52     int c = snprintf(buf, sizeof(buf) - 1, "[%d] %s:%d in %s; REASON= " fmt, \
  53                  getpid(), __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
  54     if (c == sizeof(buf) - 1) buf[c] = '\n'; \
  55     /* assign to rc in order to avoid 'unused result' compiler warnings */ \
  56     ssize_t rc __attribute__((unused)); \
  57     rc = write(PROTECTED_STDERR_FD, buf, c + 1); \
  58   } while (0);
  59 
  60 #ifdef DEBUG
  61 # define DPRINTF PRINTF
  62 #else
  63 # define DPRINTF(args...) // debug printing
  64 #endif
  65 
  66 #define ASSERT(condition) \
  67   do { \
  68     if (! (condition)) { \
  69       PRINTF("Assertion failed: %s\n", #condition); \
  70       _exit(0); \
  71     } \
  72   } while (0);
  73 
  74 #define ASSERT_NOT_REACHED() \
  75   do { \
  76     PRINTF("NOT_REACHED Assertion failed.\n"); \
  77     _exit(0); \
  78   } while (0);
  79 
  80 
  81 int  TLSInfo_GetTidOffset();
  82 int  TLSInfo_GetPidOffset();
  83 void TLSInfo_PostRestart();
  84 void TLSInfo_VerifyPidTid(pid_t pid, pid_t tid);
  85 void TLSInfo_UpdatePid();
  86 void TLSInfo_SaveTLSState (ThreadTLSInfo *tlsInfo);
  87 void TLSInfo_RestoreTLSState(ThreadTLSInfo *tlsInfo);
  88 void TLSInfo_SetThreadSysinfo(void *sysinfo);
  89 void *TLSInfo_GetThreadSysinfo();
  90 int  TLSInfo_HaveThreadSysinfoOffset();
  91 
  92 void Thread_RestoreAllThreads(void);
  93 
  94 #ifdef __cplusplus
  95 }
  96 #endif
  97 
  98 #endif

/* [<][>][^][v][top][bottom][index][help] */