Changeset 21865 for branches/gcc-kmk/src


Ignore:
Timestamp:
Dec 8, 2011, 2:32:54 PM (14 years ago)
Author:
dmik
Message:

Port WSOCK32 and IPHLPAPI to GCC/kBuild.

Location:
branches/gcc-kmk/src
Files:
2 added
10 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/gcc-kmk/src/Makefile.kmk

    r21860 r21865  
    3232include $(PATH_SUB_CURRENT)/shlwapi/Makefile.kmk
    3333include $(PATH_SUB_CURRENT)/shell32/Makefile.kmk
     34include $(PATH_SUB_CURRENT)/wsock32/Makefile.kmk
     35include $(PATH_SUB_CURRENT)/iphlpapi/Makefile.kmk
    3436
    3537include $(FILE_KBUILD_SUB_FOOTER)
  • branches/gcc-kmk/src/iphlpapi/iphlpapi.cpp

    r21563 r21865  
    6060
    6161//We don't want to use the OS2 version directly, but the one in wsock32
    62 int WIN32API ODIN_gethostname (char * name, int namelen);
     62int WIN32API OS2gethostname (char * name, int namelen);
    6363
    6464ODINDEBUGCHANNEL(IPHLPAPI-IPHLPAPI)
     
    274274        // fill pipAdapter->IpAddressList
    275275        int cIfAddresses = 0;
    276         for (int j = 0; j < cAddresses; ++j)
     276        int j;
     277        for (j = 0; j < cAddresses; ++j)
    277278        {
    278279#ifdef DEBUG
     
    580581  memset(pFixedInfo,0,memNeeded);
    581582
    582   ODIN_gethostname(fi->HostName,128);
     583  OS2gethostname(fi->HostName,128);
    583584  strcpy(fi->DomainName,_res.defdname);
    584585
  • branches/gcc-kmk/src/iphlpapi/iphlpapi.def

    r10066 r21865  
    66
    77EXPORTS
    8  GetAdaptersInfo    = _GetAdaptersInfo@8                    @17
    9  GetNetworkParams   = _GetNetworkParams@8                   @38
     8 GetAdaptersInfo    = "_GetAdaptersInfo@8"                  @17
     9 GetNetworkParams   = "_GetNetworkParams@8"                 @38
    1010
    11  GetIpAddrTable     = _GetIpAddrTable@12                    @40
    12  GetIfTable         = _GetIfTable@12                        @41
    13  GetFriendlyIfIndex = _GetFriendlyIfIndex@4                 @42
     11 GetIpAddrTable     = "_GetIpAddrTable@12"                  @40
     12 GetIfTable         = "_GetIfTable@12"                      @41
     13 GetFriendlyIfIndex = "_GetFriendlyIfIndex@4"               @42
    1414
    15 ;to tell the linker to look elsewhere for this function
    16  _ODIN_gethostname@8 = _gethostname@8                     @50
    17 
  • branches/gcc-kmk/src/iphlpapi/iphlwrap.h

    r21720 r21865  
    88#include <netinet/tcp.h>
    99#include <nerrno.h>
    10 
    11 int _System os2_ioctl (int, unsigned long, char *, int);
    1210
    1311inline int _os2_ioctl (int a, unsigned long b, char *c, int d)
     
    2321
    2422#undef  os2_ioctl
    25 #define os2_ioctl _os2_ioctl
    26 
    27 inline int _ioctl(int a, int b, char *c, int d)
    28 {
    29  int yyrc;
    30  USHORT sel = RestoreOS2FS();
    31 
    32     yyrc = ioctl(a, b, c, d);
    33     SetFS(sel);
    34 
    35     return yyrc;
    36 }
    37 
    38 #undef  ioctl
    39 #define ioctl _ioctl
     23#define ioctl _os2_ioctl
    4024
    4125inline int _res_init(void)
  • branches/gcc-kmk/src/wsock32/asyncapi.cpp

    r21656 r21865  
    408408
    409409#ifdef DEBUG_LOGGING
    410     char *pszEvent = NULL;
     410    const char *pszEvent = NULL;
    411411
    412412    switch(event) {
  • branches/gcc-kmk/src/wsock32/dbglocal.cpp

    r6375 r21865  
    1919USHORT DbgEnabledLvl2WSOCK32[DBG_MAXFILES] = {0};
    2020
    21 static char *DbgFileNames[DBG_MAXFILES] =
     21static const char *DbgFileNames[DBG_MAXFILES] =
    2222{
    2323"initterm",
  • branches/gcc-kmk/src/wsock32/initterm.cpp

    r21842 r21865  
    1 /* $Id: initwsock32.cpp,v 1.4 2001-10-13 18:51:08 sandervl Exp $
     1/* $Id: initterm.cpp,v 1.17 2001-09-05 10:26:30 bird Exp $
    22 *
    3  * DLL entry point
     3 * WSOCK32 DLL entry point
    44 *
    55 * Copyright 1998 Sander van Leeuwen
    66 * Copyright 1998 Peter Fitzsimmons
    77 *
    8  *
    98 * Project Odin Software License can be found in LICENSE.TXT
    10  *
    119 */
    1210
    13 /*-------------------------------------------------------------*/
    14 /* INITERM.C -- Source for a custom dynamic link library       */
    15 /*              initialization and termination (_DLL_InitTerm) */
    16 /*              function.                                      */
    17 /*                                                             */
    18 /* When called to perform initialization, this sample function */
    19 /* gets storage for an array of integers, and initializes its  */
    20 /* elements with random integers.  At termination time, it     */
    21 /* frees the array.  Substitute your own special processing.   */
    22 /*-------------------------------------------------------------*/
    23 
    24 
    25 /* Include files */
    2611#define  INCL_DOSMODULEMGR
    2712#define  INCL_DOSPROCESS
     
    4025#include "dbglocal.h"
    4126
    42 extern "C" {
    43  //Win32 resource table (produced by wrc)
    44  extern DWORD wsock32_PEResTab;
    45 }
     27// Win32 resource table (produced by wrc)
     28extern DWORD wsock32_PEResTab;
     29
    4630static HMODULE dllHandle = 0;
    4731
    4832INT WIN32API WSACleanup();
    49 //******************************************************************************
    50 //******************************************************************************
     33
    5134BOOL WINAPI WinsockLibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
    5235{
    53    switch (fdwReason)
    54    {
    55    case DLL_PROCESS_ATTACH:
    56     return TRUE;
     36    switch (fdwReason)
     37    {
     38    case DLL_PROCESS_ATTACH:
     39        return TRUE;
    5740
    58    case DLL_THREAD_ATTACH:
    59    case DLL_THREAD_DETACH:
    60     return TRUE;
     41    case DLL_THREAD_ATTACH:
     42    case DLL_THREAD_DETACH:
     43        return TRUE;
    6144
    62    case DLL_PROCESS_DETACH:
    63     WSACleanup();
    64     return TRUE;
    65    }
    66    return FALSE;
     45    case DLL_PROCESS_DETACH:
     46        WSACleanup();
     47        return TRUE;
     48    }
     49    return FALSE;
    6750}
    68 /****************************************************************************/
    69 /* _DLL_InitTerm is the function that gets called by the operating system   */
    70 /* loader when it loads and frees this DLL for each process that accesses   */
    71 /* this DLL.  However, it only gets called the first time the DLL is loaded */
    72 /* and the last time it is freed for a particular process.  The system      */
    73 /* linkage convention MUST be used because the operating system loader is   */
    74 /* calling this function.                                                   */
    75 /****************************************************************************/
    76 ULONG APIENTRY inittermWsock32(ULONG hModule, ULONG ulFlag)
     51
     52ULONG SYSTEM DLL_InitWSock32(ULONG hModule)
    7753{
    78    size_t i;
    79    APIRET rc;
     54    CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    8055
    81    /*-------------------------------------------------------------------------*/
    82    /* If ulFlag is zero then the DLL is being loaded so initialization should */
    83    /* be performed.  If ulFlag is 1 then the DLL is being freed so            */
    84    /* termination should be performed.                                        */
    85    /*-------------------------------------------------------------------------*/
     56    ParseLogStatusWSOCK32();
    8657
    87    switch (ulFlag) {
    88       case 0 :
    89          ParseLogStatusWSOCK32();
     58    dllHandle = RegisterLxDll(hModule, WinsockLibMain, (PVOID)&wsock32_PEResTab);
     59    if (dllHandle == 0)
     60           return -1;
    9061
    91          dllHandle = RegisterLxDll(hModule, WinsockLibMain, (PVOID)&wsock32_PEResTab);
    92          if(dllHandle == 0)
    93              return 0UL;
     62    return 0;
     63}
    9464
    95          break;
    96       case 1 :
    97          if(dllHandle) {
    98              UnregisterLxDll(dllHandle);
    99          }
    100          break;
    101       default  :
    102          return 0UL;
    103    }
     65void SYSTEM DLL_TermWSock32(ULONG hModule)
     66{
     67    if (dllHandle)
     68       UnregisterLxDll(dllHandle);
     69}
    10470
    105    /***********************************************************/
    106    /* A non-zero value must be returned to indicate success.  */
    107    /***********************************************************/
    108    return 1UL;
     71ULONG SYSTEM DLL_Init(ULONG hModule)
     72{
     73    if (DLL_InitDefault(hModule) == -1)
     74        return -1;
     75    return DLL_InitWSock32(hModule);
    10976}
    110 //******************************************************************************
    111 //******************************************************************************
     77
     78void SYSTEM DLL_Term(ULONG hModule)
     79{
     80    DLL_TermWSock32(hModule);
     81    DLL_TermDefault(hModule);
     82}
  • branches/gcc-kmk/src/wsock32/socketwrap.h

    r21720 r21865  
    118118#define getsockopt _getsockopt
    119119
    120 inline int _ioctl(int a, int b, char *c, int d)
    121 {
    122  int yyrc;
    123  USHORT sel = RestoreOS2FS();
    124 
    125     yyrc = ioctl(a, b, c, d);
     120inline int _os2_ioctl(int a, int b, char *c, int d)
     121{
     122 int yyrc;
     123 USHORT sel = RestoreOS2FS();
     124
     125    yyrc = os2_ioctl(a, b, c, d);
    126126    SetFS(sel);
    127127
     
    130130
    131131#undef  ioctl
    132 #define ioctl _ioctl
     132#define ioctl _os2_ioctl
    133133
    134134inline int _listen(int a, int b)
     
    202202#define removesocketfromlist _removesocketfromlist
    203203
    204 inline int _select(int *a, int b, int c, int d, long e)
    205 {
    206  int yyrc;
    207  USHORT sel = RestoreOS2FS();
    208 
    209     yyrc = select(a, b, c, d, e);
     204inline int _os2_select(int *a, int b, int c, int d, long e)
     205{
     206 int yyrc;
     207 USHORT sel = RestoreOS2FS();
     208
     209    yyrc = os2_select(a, b, c, d, e);
    210210    SetFS(sel);
    211211
     
    214214
    215215#undef  select
    216 #define select _select
     216#define select _os2_select
    217217
    218218inline int _send(int a, char *b, int c, int d)
  • branches/gcc-kmk/src/wsock32/wsock32.cpp

    r21456 r21865  
    10391039//******************************************************************************
    10401040//******************************************************************************
    1041 char *debugsockopt(int optname)
     1041const char *debugsockopt(int optname)
    10421042{
    10431043    switch(optname) {
     
    17321732
    17331733                    localhost_address       = *(unsigned long *)&addr->sin_addr;
    1734                     localhost.h_name        = "localhost"; /* This is what the old workaround did. */
     1734                    localhost.h_name        = (char *)"localhost"; /* This is what the old workaround did. */
    17351735                    localhost.h_addrtype    = AF_INET;
    17361736                    localhost.h_length      = 4;
  • branches/gcc-kmk/src/wsock32/wsock32.def

    r21308 r21865  
    1010IMPORTS
    1111  ; this is not in every so32dll.lib
    12   winsockcleanupsockets = SO32DLL.WINSOCKCLEANUPSOCKETS
     12  winsockcleanupsockets = SO32DLL.38 ; WINSOCKCLEANUPSOCKETS
    1313
    1414
     
    1919; ----------------------
    2020
    21    accept                      = _OS2accept@12                            @1
    22    bind                        = _OS2bind@12                              @2
    23    closesocket                 = _OS2closesocket@4                        @3
    24    connect                     = _OS2connect@12                           @4
    25    getpeername                 = _OS2getpeername@12                       @5
    26    getsockname                 = _OS2getsockname@12                       @6
    27    getsockopt                  = _OS2getsockopt@20                        @7
    28    htonl                       = _OS2htonl@4                              @8
    29    htons                       = _OS2htons@4                              @9
    30    inet_addr                   = _OS2inet_addr@4                          @10
    31    inet_ntoa                   = _OS2inet_ntoa@4                          @11
    32    ioctlsocket                 = _OS2ioctlsocket@12                       @12
    33    listen                      = _OS2listen@8                             @13
    34    ntohl                       = _OS2ntohl@4                              @14
    35    ntohs                       = _OS2ntohs@4                              @15
    36    recv                        = _OS2recv@16                              @16
    37    recvfrom                    = _OS2recvfrom@24                          @17
    38    select                      = _OS2select@20                            @18
    39    send                        = _OS2send@16                              @19
    40    sendto                      = _OS2sendto@24                            @20
    41    setsockopt                  = _OS2setsockopt@20                        @21
    42    shutdown                    = _OS2shutdown@8                           @22
    43    socket                      = _OS2socket@12                            @23
     21   accept                      = "_OS2accept@12"                          @1
     22   bind                        = "_OS2bind@12"                            @2
     23   closesocket                 = "_OS2closesocket@4"                      @3
     24   connect                     = "_OS2connect@12"                         @4
     25   getpeername                 = "_OS2getpeername@12"                     @5
     26   getsockname                 = "_OS2getsockname@12"                     @6
     27   getsockopt                  = "_OS2getsockopt@20"                      @7
     28   htonl                       = "_OS2htonl@4"                            @8
     29   htons                       = "_OS2htons@4"                            @9
     30   inet_addr                   = "_OS2inet_addr@4"                        @10
     31   inet_ntoa                   = "_OS2inet_ntoa@4"                        @11
     32   ioctlsocket                 = "_OS2ioctlsocket@12"                     @12
     33   listen                      = "_OS2listen@8"                           @13
     34   ntohl                       = "_OS2ntohl@4"                            @14
     35   ntohs                       = "_OS2ntohs@4"                            @15
     36   recv                        = "_OS2recv@16"                            @16
     37   recvfrom                    = "_OS2recvfrom@24"                        @17
     38   select                      = "_OS2select@20"                          @18
     39   send                        = "_OS2send@16"                            @19
     40   sendto                      = "_OS2sendto@24"                          @20
     41   setsockopt                  = "_OS2setsockopt@20"                      @21
     42   shutdown                    = "_OS2shutdown@8"                         @22
     43   socket                      = "_OS2socket@12"                          @23
    4444
    45    gethostbyaddr               = _OS2gethostbyaddr@12                     @51
    46    gethostbyname               = _OS2gethostbyname@4                      @52
    47    getprotobyname              = _OS2getprotobyname@4                     @53
    48    getprotobynumber            = _OS2getprotobynumber@4                   @54
    49    getservbyname               = _OS2getservbyname@8                      @55
    50    getservbyport               = _OS2getservbyport@8                      @56
    51    gethostname                 = _OS2gethostname@8                        @57
     45   gethostbyaddr               = "_OS2gethostbyaddr@12"                   @51
     46   gethostbyname               = "_OS2gethostbyname@4"                    @52
     47   getprotobyname              = "_OS2getprotobyname@4"                   @53
     48   getprotobynumber            = "_OS2getprotobynumber@4"                 @54
     49   getservbyname               = "_OS2getservbyname@8"                    @55
     50   getservbyport               = "_OS2getservbyport@8"                    @56
     51   gethostname                 = "_OS2gethostname@8"                      @57
    5252
    5353; ----------------------------
     
    5555; ----------------------------
    5656
    57    WSAAsyncSelect              = _WSAAsyncSelect@16                    @101
    58    WSAAsyncGetHostByAddr       = _WSAAsyncGetHostByAddr@28             @102
    59    WSAAsyncGetHostByName       = _WSAAsyncGetHostByName@20             @103
    60    WSAAsyncGetProtoByNumber    = _WSAAsyncGetProtoByNumber@20          @104
    61    WSAAsyncGetProtoByName      = _WSAAsyncGetProtoByName@20            @105
    62    WSAAsyncGetServByPort       = _WSAAsyncGetServByPort@24             @106
    63    WSAAsyncGetServByName       = _WSAAsyncGetServByName@24             @107
    64    WSACancelAsyncRequest       = _WSACancelAsyncRequest@4              @108
    65    WSASetBlockingHook          = _WSASetBlockingHook@4                 @109
    66    WSAUnhookBlockingHook       = _WSAUnhookBlockingHook@0              @110
    67    WSAGetLastError             = _WSAGetLastError@0                    @111
    68    WSASetLastError             = _WSASetLastError@4                    @112
    69    WSACancelBlockingCall       = _WSACancelBlockingCall@0              @113
    70    WSAIsBlocking               = _WSAIsBlocking@0                      @114
    71    WSAStartup                  = _WSAStartup@8                         @115
    72    WSACleanup                  = _WSACleanup@0                         @116
    73    __WSAFDIsSet                = ___WSAFDIsSet@8                       @151
     57   WSAAsyncSelect              = "_WSAAsyncSelect@16"                  @101
     58   WSAAsyncGetHostByAddr       = "_WSAAsyncGetHostByAddr@28"           @102
     59   WSAAsyncGetHostByName       = "_WSAAsyncGetHostByName@20"           @103
     60   WSAAsyncGetProtoByNumber    = "_WSAAsyncGetProtoByNumber@20"        @104
     61   WSAAsyncGetProtoByName      = "_WSAAsyncGetProtoByName@20"          @105
     62   WSAAsyncGetServByPort       = "_WSAAsyncGetServByPort@24"           @106
     63   WSAAsyncGetServByName       = "_WSAAsyncGetServByName@24"           @107
     64   WSACancelAsyncRequest       = "_WSACancelAsyncRequest@4"            @108
     65   WSASetBlockingHook          = "_WSASetBlockingHook@4"               @109
     66   WSAUnhookBlockingHook       = "_WSAUnhookBlockingHook@0"            @110
     67   WSAGetLastError             = "_WSAGetLastError@0"                  @111
     68   WSASetLastError             = "_WSASetLastError@4"                  @112
     69   WSACancelBlockingCall       = "_WSACancelBlockingCall@0"            @113
     70   WSAIsBlocking               = "_WSAIsBlocking@0"                    @114
     71   WSAStartup                  = "_WSAStartup@8"                       @115
     72   WSACleanup                  = "_WSACleanup@0"                       @116
     73   __WSAFDIsSet                = "___WSAFDIsSet@8"                     @151
    7474
    75    rcmd                        = _OS2rcmd@24                              @1102
    76    rexec                       = _OS2rexec@24                             @1103
    77    WSARecvEx                   = _WSARecvEx@16                         @1107
    78    s_perror                    = _OS2s_perror@8                           @1108
     75   rcmd                        = "_OS2rcmd@24"                            @1102
     76   rexec                       = "_OS2rexec@24"                           @1103
     77   WSARecvEx                   = "_WSARecvEx@16"                       @1107
     78   s_perror                    = "_OS2s_perror@8"                         @1108
    7979
    8080; -------------------
     
    116116; -----------------------
    117117
    118                                  _OS2gethostname@8                        @2000
     118                                 "_OS2gethostname@8"                      @2000
    119119
    120120; functions for ws2_32 implemented here
    121    WSAEventSelect              = _WSAEventSelect@12                       @3001
    122    WSAEnumNetworkEvents        = _WSAEnumNetworkEvents@12                 @3002
     121   WSAEventSelect              = "_WSAEventSelect@12"                     @3001
     122   WSAEnumNetworkEvents        = "_WSAEnumNetworkEvents@12"               @3002
  • branches/gcc-kmk/src/wsock32/wsock32.h

    r21720 r21865  
    2020
    2121#include <odinwrap.h>
     22
     23#ifdef __EMX__
     24// EMX 0.6.4 and before lacks this
     25#ifndef SOCBASEERR
     26#define SOCBASEERR 0
     27#endif
     28#endif
    2229
    2330#ifndef IP_TTL
     
    128135typedef u_int           SOCKET;
    129136
     137#ifndef FD_SETSIZE
    130138#define FD_SETSIZE      64
     139#endif
    131140
    132141#pragma pack(1)
Note: See TracChangeset for help on using the changeset viewer.