Changeset 5 in libcf


Ignore:
Timestamp:
01/30/13 13:12:40 (11 years ago)
Author:
cheese
Message:

#1 add windows project and fix build compatibility

Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/cf_file.h

    r4 r5  
    77#include "cf_base.h"
    88#include <fcntl.h>
    9 
    10 #ifdef _WIN32
    11 # define O_RDONLY       _O_RDONLY   | _O_BINARY
    12 # define O_WRONLY       _O_WRONLY   | _O_BINARY
    13 # define O_RDWR         _O_RDWR     | _O_BINARY
    14 # define O_APPEND       _O_APPEND   | _O_BINARY
    15 # define O_CREAT        _O_CREAT    | _O_BINARY
    16 # define O_TRUNC        _O_TRUNC
    17 #endif // #ifdef _WIN32
    189
    1910#define CF_ERROR_FILE                   CF_ERROR_BASE * 2
  • trunk/include/cf_thread.h

    r4 r5  
    99#ifdef _WIN32
    1010//# include <stddef.h>
    11 # define CF_THREAD_RETURN   uintptr_t
     11# define CF_THREAD_RETURN   unsigned int
    1212# define CF_THREAD_CALL     __stdcall
    1313#else // #ifdef _WIN32
     
    1616#endif // #ifdef _WIN32
    1717
    18 #define CF_THREAD_FUNCTION  CF_THREAD_RETURN CF_THREAD_CALL
     18typedef CF_THREAD_RETURN  (CF_THREAD_CALL * CF_Thread_Function) (void *);
    1919
    2020#define CF_ERROR_THREAD                 CF_ERROR_BASE * 4
     
    3535CF_EXPORT int
    3636CF_Thread_Create    (CF_Thread          * threadID,
    37                      CF_THREAD_RETURN   callback,
     37                     CF_Thread_Function callback,
    3838                     void               * arg);
    3939
  • trunk/src/cf_file.c

    r4 r5  
    66#ifdef _WIN32
    77# include <io.h>
     8# include <stdio.h>
    89#else // #ifdef _WIN32
    910# include <unistd.h>
  • trunk/src/cf_socket.c

    r4 r5  
    77#ifdef _WIN32
    88# include <WinSock2.h>
     9# pragma comment (lib, "ws2_32.lib")
     10# define close(__sock)  closesocket(__sock)
     11# define sa_family_t    unsigned short
    912#else
    1013# include <netinet/in.h>
     
    7477    CHECK_INVALID_SOCKET (sock);
    7578
    76     result = /* continued */
    77 #ifdef _WIN32
    78         closesocket (socket);
    79 #else
    80         close (sock);
    81 #endif
     79    result = close (sock);
    8280
    8381    if (result != 0)
     
    143141    int result = 0;
    144142
    145     CHECK_INVALID_SOCKET (sock);
    146 
    147     if (timeout < 0)
    148         return CF_ERROR_SOCKET_INVALID_ARGS;
    149 
    150 #ifndef _WIN32
     143#ifdef _WIN32
     144    int time_ms = timeout * 1000;
     145#else
    151146    struct timeval  timeval;
    152147    timeval.tv_sec = timeout;
    153148    timeval.tv_usec= 0;
    154 #else
    155     int             time_ms = timeout * 1000;
    156 #endif
     149#endif
     150
     151    CHECK_INVALID_SOCKET (sock);
     152
     153    if (timeout < 0)
     154        return CF_ERROR_SOCKET_INVALID_ARGS;
    157155
    158156    result = CF_Socket_SetOption (sock,
  • trunk/src/cf_thread.c

    r4 r5  
    3939
    4040int
    41 CF_Thread_Create (CF_Thread         * threadID,
    42                   CF_THREAD_RETURN  callback,
    43                   void              * arg)
     41CF_Thread_Create (CF_Thread             * threadID,
     42                  CF_Thread_Function    callback,
     43                  void                  * arg)
    4444{
    4545    int result = 0;
     
    8686
    8787#ifdef _WIN32
    88     WaitForSingleObject ((THREAD_TYPE) *threaID, INFINITE);
     88    WaitForSingleObject ((THREAD_TYPE) *threadID, INFINITE);
    8989#else
    9090    int status;
Note: See TracChangeset for help on using the changeset viewer.