Mutex code (untested)
This commit is contained in:
@ -34,7 +34,7 @@ CFLAGS = -g -march=i486 -pipe -Wall
|
|||||||
|
|
||||||
CFLAGS += -I$(SAMINCDIR) -I$(TOMCRYPTDIR)
|
CFLAGS += -I$(SAMINCDIR) -I$(TOMCRYPTDIR)
|
||||||
LDFLAGS = -L$(SAMLIBDIR) -L$(TOMCRYPTDIR)
|
LDFLAGS = -L$(SAMLIBDIR) -L$(TOMCRYPTDIR)
|
||||||
LIBS = -lsam -ltomcrypt
|
LIBS = -lsam -ltomcrypt -lpthread
|
||||||
|
|
||||||
#
|
#
|
||||||
# Object files
|
# Object files
|
||||||
@ -45,6 +45,7 @@ OBJS = $(OBJDIR)/bigint.o \
|
|||||||
$(OBJDIR)/config.o \
|
$(OBJDIR)/config.o \
|
||||||
$(OBJDIR)/logger.o \
|
$(OBJDIR)/logger.o \
|
||||||
$(OBJDIR)/main.o \
|
$(OBJDIR)/main.o \
|
||||||
|
$(OBJDIR)/mutex.o \
|
||||||
$(OBJDIR)/peers.o \
|
$(OBJDIR)/peers.o \
|
||||||
$(OBJDIR)/random.o \
|
$(OBJDIR)/random.o \
|
||||||
$(OBJDIR)/rpc.o \
|
$(OBJDIR)/rpc.o \
|
||||||
|
@ -42,3 +42,20 @@ Logger::Logger(const string& file)
|
|||||||
throw runtime_error("Error opening log file");
|
throw runtime_error("Error opening log file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIN_STRERROR
|
||||||
|
/*
|
||||||
|
* strerror() for primitive operating systems
|
||||||
|
*/
|
||||||
|
TCHAR* win_strerror(TCHAR* str, size_t size)
|
||||||
|
{
|
||||||
|
LPVOID lpMsgBuf;
|
||||||
|
DWORD dw = GetLastError();
|
||||||
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf,
|
||||||
|
0, NULL);
|
||||||
|
snprintf(str, size, "%s", lpMsgBuf);
|
||||||
|
LocalFree(lpMsgBuf);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -81,4 +81,8 @@ class Logger {
|
|||||||
ofstream logf;
|
ofstream logf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef WIN_STRERROR
|
||||||
|
TCHAR* win_strerror(TCHAR* str, size_t size);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // LOGGER_HPP
|
#endif // LOGGER_HPP
|
||||||
|
@ -39,6 +39,11 @@
|
|||||||
#define LINUX 2 // Linux
|
#define LINUX 2 // Linux
|
||||||
#define CYGWIN 3 // Cygwin
|
#define CYGWIN 3 // Cygwin
|
||||||
|
|
||||||
|
#if OS == MINGW
|
||||||
|
#define WIN_STRERROR
|
||||||
|
#define WINTHREADS
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System includes
|
* System includes
|
||||||
*/
|
*/
|
||||||
@ -49,6 +54,11 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#ifdef WINTHREADS
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
Reference in New Issue
Block a user