Updated makefiles and build scripts for Borland tools.
This commit is contained in:
@@ -273,6 +273,10 @@ SOURCE=..\..\..\src\mstp.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\mstptext.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\demo\handler\noserv.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -461,6 +465,10 @@ SOURCE=..\..\..\include\mstp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\mstptext.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\npdu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -38,88 +38,16 @@
|
||||
#include <sys/timeb.h>
|
||||
#include <process.h>
|
||||
|
||||
#ifdef __MSC_VER
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#define close closesocket
|
||||
|
||||
typedef int socklen_t;
|
||||
|
||||
typedef HANDLE sem_t;
|
||||
|
||||
#define sem_post(x) ReleaseSemaphore(*(x), 1, NULL)
|
||||
#define sem_close(x) CloseHandle(*(x))
|
||||
|
||||
struct timespec {
|
||||
time_t tv_sec; /* Seconds */
|
||||
long tv_nsec; /* Nanoseconds [0 .. 999999999] */
|
||||
};
|
||||
|
||||
|
||||
static inline int gettimeofday(
|
||||
struct timeval *tp,
|
||||
void *tzp)
|
||||
{
|
||||
struct _timeb timebuffer;
|
||||
|
||||
_ftime(&timebuffer);
|
||||
tp->tv_sec = timebuffer.time;
|
||||
tp->tv_usec = timebuffer.millitm * 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: not a complete implementation of the posix function */
|
||||
static inline int sem_timedwait(
|
||||
sem_t * sem,
|
||||
const struct timespec *abs_timeout)
|
||||
{
|
||||
struct timeval tp;
|
||||
DWORD wait_status = 0;
|
||||
DWORD dwMilliseconds =
|
||||
(abs_timeout->tv_sec * 1000) + (abs_timeout->tv_nsec / 1000);
|
||||
|
||||
gettimeofday(&tp, NULL);
|
||||
if (abs_timeout->tv_sec >= tp.tv_sec) {
|
||||
dwMilliseconds = (abs_timeout->tv_sec - tp.tv_sec) * 1000;
|
||||
if (abs_timeout->tv_nsec >= (tp.tv_usec * 1000)) {
|
||||
dwMilliseconds +=
|
||||
((abs_timeout->tv_nsec - (tp.tv_usec * 1000)) / (1000 * 1000));
|
||||
}
|
||||
} else {
|
||||
dwMilliseconds = 0;
|
||||
}
|
||||
|
||||
wait_status = WaitForSingleObject(*sem, dwMilliseconds);
|
||||
if (wait_status == WAIT_OBJECT_0) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int sem_init(
|
||||
sem_t * sem,
|
||||
int pshared,
|
||||
unsigned int value)
|
||||
{
|
||||
(void) pshared;
|
||||
*sem = CreateSemaphore(NULL /*lpSecurityDescriptor */ ,
|
||||
value /* lInitialCount */ ,
|
||||
1 /* lMaximumCount */ ,
|
||||
NULL /* lpName */ );
|
||||
if ((*sem) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int nanosleep(
|
||||
const struct timespec *rqtp,
|
||||
struct timespec *rmtp)
|
||||
{
|
||||
DWORD dwMilliseconds = (rqtp->tv_sec * 1000) + (rqtp->tv_nsec / 1000);
|
||||
|
||||
Sleep(dwMilliseconds);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "mstp.h"
|
||||
#include "net.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
Reference in New Issue
Block a user