Changeset 21398 for trunk/src


Ignore:
Timestamp:
Jul 28, 2010, 8:14:30 PM (15 years ago)
Author:
dmik
Message:

Build minivcrt.lib (accessible through minivcrt.h) that aims at providing MSVCRT-specific functions such as the wide character version of _getcwd() and similar to other runtimes.

Location:
trunk/src/msvcrt
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/msvcrt/dir.c

    r10005 r21398  
    3131#endif
    3232
     33#ifndef __MINIVCRT__
     34
    3335#include "wine/port.h"
    3436
     
    4951
    5052WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
     53
     54#else /* !__MINIVCRT__ */
     55
     56#include "minivcrt.h"
     57#include "minivcrt_internal.h"
     58
     59#include "winternl.h"
     60#include "wine/unicode.h"
     61
     62#include <errno.h>
     63#include <stdlib.h>
     64
     65#endif /* !__MINIVCRT__ */
     66
     67#ifndef __MINIVCRT__
    5168
    5269/* INTERNAL: Translate finddata_t to PWIN32_FIND_DATAA */
     
    7087}
    7188
     89#endif /* !__MINIVCRT__ */
     90
    7291/* INTERNAL: Translate wfinddata_t to PWIN32_FIND_DATAA */
    7392static void msvcrt_wfttofd(LPWIN32_FIND_DATAW fd, struct _wfinddata_t* ft)
     
    90109}
    91110
     111#ifndef __MINIVCRT__
     112
    92113/*********************************************************************
    93114 *              _chdir (MSVCRT.@)
     
    103124}
    104125
     126#endif /* !__MINIVCRT__ */
     127
    105128/*********************************************************************
    106129 *              _wchdir (MSVCRT.@)
     
    115138  return 0;
    116139}
     140
     141#ifndef __MINIVCRT__
    117142
    118143/*********************************************************************
     
    166191}
    167192
     193#endif /* !__MINIVCRT__ */
     194
    168195/*********************************************************************
    169196 *              _wfindfirst (MSVCRT.@)
     
    185212}
    186213
     214#ifndef __MINIVCRT__
     215
    187216/*********************************************************************
    188217 *              _findnext (MSVCRT.@)
     
    194223  if (!FindNextFileA((HANDLE)hand, &find_data))
    195224  {
    196     *MSVCRT__errno() = MSVCRT_ENOENT;
     225    *MSVCRT__errno() = MSVCRT(ENOENT);
    197226    return -1;
    198227  }
     
    202231}
    203232
     233#endif /* !__MINIVCRT__ */
     234
    204235/*********************************************************************
    205236 *              _wfindnext (MSVCRT.@)
     
    211242  if (!FindNextFileW((HANDLE)hand, &find_data))
    212243  {
    213     *MSVCRT__errno() = MSVCRT_ENOENT;
     244    *MSVCRT__errno() = MSVCRT(ENOENT);
    214245    return -1;
    215246  }
     
    218249  return 0;
    219250}
     251
     252#ifndef __MINIVCRT__
    220253
    221254/*********************************************************************
     
    245278}
    246279
     280#endif /* !__MINIVCRT__ */
     281
    247282/*********************************************************************
    248283 *              _wgetcwd (MSVCRT.@)
     
    264299  if (dir_len >= size)
    265300  {
    266     *MSVCRT__errno() = MSVCRT_ERANGE;
     301    *MSVCRT__errno() = MSVCRT(ERANGE);
    267302    return NULL; /* buf too small */
    268303  }
     
    270305  return buf;
    271306}
     307
     308#ifndef __MINIVCRT__
    272309
    273310/*********************************************************************
     
    322359}
    323360
     361#endif /* !__MINIVCRT__ */
     362
    324363/*********************************************************************
    325364 *              _wgetdcwd (MSVCRT.@)
     
    342381    if (GetDriveTypeW(drivespec) < DRIVE_REMOVABLE)
    343382    {
    344       *MSVCRT__errno() = MSVCRT_EACCES;
     383      *MSVCRT__errno() = MSVCRT(EACCES);
    345384      return NULL;
    346385    }
     
    349388    if (dir_len >= size || dir_len < 1)
    350389    {
    351       *MSVCRT__errno() = MSVCRT_ERANGE;
     390      *MSVCRT__errno() = MSVCRT(ERANGE);
    352391      return NULL; /* buf too small */
    353392    }
     
    360399  return buf;
    361400}
     401
     402#ifndef __MINIVCRT__
    362403
    363404/*********************************************************************
     
    399440}
    400441
     442#endif /* !__MINIVCRT__ */
     443
    401444/*********************************************************************
    402445 *              _wmkdir (MSVCRT.@)
     
    410453}
    411454
     455#ifndef __MINIVCRT__
     456
    412457/*********************************************************************
    413458 *              _rmdir (MSVCRT.@)
     
    420465  return -1;
    421466}
     467
     468#endif /* !__MINIVCRT__ */
    422469
    423470/*********************************************************************
     
    519566  }
    520567}
     568
     569#ifndef __MINIVCRT__
    521570
    522571/* INTERNAL: Helper for _fullpath. Modified PD code from 'snippets'. */
     
    720769}
    721770
     771#endif /* !__MINIVCRT__ */
     772
    722773/*********************************************************************
    723774 *              _wmakepath (MSVCRT.@)
     
    767818}
    768819
     820#ifndef __MINIVCRT__
     821
    769822/*********************************************************************
    770823 *              _searchenv (MSVCRT.@)
     
    828881}
    829882
     883#endif /* !__MINIVCRT__ */
     884
    830885MSVCRT_wchar_t* _wfullpath(MSVCRT_wchar_t* absPath,const MSVCRT_wchar_t* relPath,MSVCRT(size_t) size)
    831886{
     
    836891
    837892   WideCharToMultiByte(CP_ACP, 0, relPath, -1, (LPSTR)asciirelPath, 280, NULL, NULL);
    838    
     893
    839894   MSVCRT__fullpath(asciiabsPath, asciirelPath, size);
    840    
     895
    841896   MultiByteToWideChar(CP_ACP, 0, asciiabsPath, -1, absPath, size);
    842897
    843    return absPath; 
    844 }
     898   return absPath;
     899}
  • trunk/src/msvcrt/environ.c

    r21395 r21398  
    2626#endif
    2727
     28#ifndef __MINIVCRT__
     29
    2830#include "wine/unicode.h"
    2931#include "msvcrt.h"
     
    3234#include "msvcrt/stdlib.h"
    3335
    34 
    3536#include "wine/debug.h"
    3637
    3738WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
     39
     40#else /* !__MINIVCRT__ */
     41
     42#include "minivcrt.h"
     43#include "minivcrt_internal.h"
     44
     45#include "winternl.h"
     46#include "wine/unicode.h"
     47
     48#endif /* !__MINIVCRT__ */
     49
     50#ifndef __MINIVCRT__
    3851
    3952/*********************************************************************
     
    6780}
    6881
     82#endif /* !__MINIVCRT__ */
     83
    6984/*********************************************************************
    7085 *              _wgetenv (MSVCRT.@)
     
    97112  return NULL;
    98113}
     114
     115#ifndef __MINIVCRT__
    99116
    100117/*********************************************************************
     
    130147}
    131148
     149#endif /* !__MINIVCRT__ */
     150
    132151/*********************************************************************
    133152 *              _wputenv (MSVCRT.@)
     
    154173
    155174 ret = !SetEnvironmentVariableW(name, value[0] ? value : NULL);
     175#ifndef __MINIVCRT__
    156176 /* Update the __p__environ array only when already initialized */
    157177 if (MSVCRT__environ)
     
    159179 if (MSVCRT__wenviron)
    160180   MSVCRT__wenviron = msvcrt_SnapshotOfEnvironmentW(MSVCRT__wenviron);
     181#endif /* !__MINIVCRT__ */
    161182 return ret;
    162183}
  • trunk/src/msvcrt/errno.c

    r10005 r21398  
    1919 */
    2020
     21#ifndef __MINIVCRT__
     22
    2123#include "msvcrt.h"
    2224#include "msvcrt/errno.h"
     
    2931#include "msvcrt/string.h"
    3032
    31 
    3233#include "wine/debug.h"
    3334
    3435WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
    3536
     37#else /* !__MINIVCRT__ */
     38
     39#include <winbase.h>
     40#include <winerror.h>
     41
     42#include "minivcrt.h"
     43#include "minivcrt_internal.h"
     44
     45#include <errno.h>
     46
     47#endif /* !__MINIVCRT__ */
    3648
    3749/* INTERNAL: Set the crt and dos errno's from the OS error given. */
    3850void MSVCRT__set_errno(int err)
    3951{
    40   int *msv_errno = MSVCRT__errno();
     52#ifndef __MINIVCRT__
     53
     54  int *__errno = MSVCRT__errno();
    4155  unsigned long *doserrno = MSVCRT_doserrno();
    42  
     56
    4357  *doserrno = err;
     58
     59#define ERR_CASE(oserr) case oserr:
     60#define ERR_MAPS(oserr,crterr) case oserr:*__errno = MSVCRT_##crterr;break;
     61
     62#else /* !__MINIVCRT__ */
     63
     64  int *__errno = _errno();
     65
     66#define ERR_CASE(oserr) case oserr:
     67#define ERR_MAPS(oserr,crterr) case oserr:*__errno = crterr;break;
     68
     69#endif /* !__MINIVCRT__ */
    4470
    4571  switch(err)
    4672  {
    47 #define ERR_CASE(oserr) case oserr:
    48 #define ERR_MAPS(oserr,crterr) case oserr:*msv_errno = crterr;break;
    4973    ERR_CASE(ERROR_ACCESS_DENIED)
    5074    ERR_CASE(ERROR_NETWORK_ACCESS_DENIED)
     
    5781    ERR_CASE(ERROR_NOT_LOCKED)
    5882    ERR_CASE(ERROR_INVALID_ACCESS)
    59     ERR_MAPS(ERROR_LOCK_VIOLATION,       MSVCRT_EACCES);
     83    ERR_MAPS(ERROR_LOCK_VIOLATION,       EACCES);
    6084    ERR_CASE(ERROR_FILE_NOT_FOUND)
    6185    ERR_CASE(ERROR_NO_MORE_FILES)
     
    6589    ERR_CASE(ERROR_BAD_NET_NAME)
    6690    ERR_CASE(ERROR_FILENAME_EXCED_RANGE)
    67     ERR_MAPS(ERROR_PATH_NOT_FOUND,       MSVCRT_ENOENT);
    68     ERR_MAPS(ERROR_IO_DEVICE,            MSVCRT_EIO);
    69     ERR_MAPS(ERROR_BAD_FORMAT,           MSVCRT_ENOEXEC);
    70     ERR_MAPS(ERROR_INVALID_HANDLE,       MSVCRT_EBADF);
     91    ERR_MAPS(ERROR_PATH_NOT_FOUND,       ENOENT);
     92    ERR_MAPS(ERROR_IO_DEVICE,            EIO);
     93    ERR_MAPS(ERROR_BAD_FORMAT,           ENOEXEC);
     94    ERR_MAPS(ERROR_INVALID_HANDLE,       EBADF);
    7195    ERR_CASE(ERROR_OUTOFMEMORY)
    7296    ERR_CASE(ERROR_INVALID_BLOCK)
    7397    ERR_CASE(ERROR_NOT_ENOUGH_QUOTA);
    74     ERR_MAPS(ERROR_ARENA_TRASHED,        MSVCRT_ENOMEM);
    75     ERR_MAPS(ERROR_BUSY,                 MSVCRT_EBUSY);
     98    ERR_MAPS(ERROR_ARENA_TRASHED,        ENOMEM);
     99    ERR_MAPS(ERROR_BUSY,                 EBUSY);
    76100    ERR_CASE(ERROR_ALREADY_EXISTS)
    77     ERR_MAPS(ERROR_FILE_EXISTS,          MSVCRT_EEXIST);
    78     ERR_MAPS(ERROR_BAD_DEVICE,           MSVCRT_ENODEV);
    79     ERR_MAPS(ERROR_TOO_MANY_OPEN_FILES,  MSVCRT_EMFILE);
    80     ERR_MAPS(ERROR_DISK_FULL,            MSVCRT_ENOSPC);
    81     ERR_MAPS(ERROR_BROKEN_PIPE,          MSVCRT_EPIPE);
    82     ERR_MAPS(ERROR_POSSIBLE_DEADLOCK,    MSVCRT_EDEADLK);
    83     ERR_MAPS(ERROR_DIR_NOT_EMPTY,        MSVCRT_ENOTEMPTY);
    84     ERR_MAPS(ERROR_BAD_ENVIRONMENT,      MSVCRT_E2BIG);
     101    ERR_MAPS(ERROR_FILE_EXISTS,          EEXIST);
     102    ERR_MAPS(ERROR_BAD_DEVICE,           ENODEV);
     103    ERR_MAPS(ERROR_TOO_MANY_OPEN_FILES,  EMFILE);
     104    ERR_MAPS(ERROR_DISK_FULL,            ENOSPC);
     105    ERR_MAPS(ERROR_BROKEN_PIPE,          EPIPE);
     106    ERR_MAPS(ERROR_POSSIBLE_DEADLOCK,    EDEADLK);
     107    ERR_MAPS(ERROR_DIR_NOT_EMPTY,        ENOTEMPTY);
     108    ERR_MAPS(ERROR_BAD_ENVIRONMENT,      E2BIG);
    85109    ERR_CASE(ERROR_WAIT_NO_CHILDREN)
    86     ERR_MAPS(ERROR_CHILD_NOT_COMPLETE,   MSVCRT_ECHILD);
     110    ERR_MAPS(ERROR_CHILD_NOT_COMPLETE,   ECHILD);
    87111    ERR_CASE(ERROR_NO_PROC_SLOTS)
    88112    ERR_CASE(ERROR_MAX_THRDS_REACHED)
    89     ERR_MAPS(ERROR_NESTING_NOT_ALLOWED,  MSVCRT_EAGAIN);
     113    ERR_MAPS(ERROR_NESTING_NOT_ALLOWED,  EAGAIN);
    90114  default:
    91115    /*  Remaining cases map to EINVAL */
    92116    /* FIXME: may be missing some errors above */
    93     *msv_errno = MSVCRT_EINVAL;
     117    *__errno = MSVCRT(EINVAL);
    94118  }
    95119}
     120
     121#ifndef __MINIVCRT__
    96122
    97123/*********************************************************************
     
    100126int* MSVCRT__errno(void)
    101127{
    102     dprintf(("MSVCRT: __errno %d",msvcrt_get_thread_data()->msv_errno)); 
     128    dprintf(("MSVCRT: __errno %d",msvcrt_get_thread_data()->msv_errno));
    103129    return &msvcrt_get_thread_data()->msv_errno;
    104130}
     
    109135unsigned long* MSVCRT_doserrno(void)
    110136{
    111     dprintf(("MSVCRT: _doserrno %d",msvcrt_get_thread_data()->doserrno)); 
     137    dprintf(("MSVCRT: _doserrno %d",msvcrt_get_thread_data()->doserrno));
    112138    return &msvcrt_get_thread_data()->doserrno;
    113139}
     
    138164  MSVCRT__cprintf("%s: %s\n",str,MSVCRT_strerror(msvcrt_get_thread_data()->msv_errno));
    139165}
     166
     167#endif /* !__MINIVCRT__ */
  • trunk/src/msvcrt/makefile

    r9655 r21398  
    2323
    2424all clean lib:  # add all common rules here
     25!ifdef BUILD_MSVCRT   
    2526    $(MAKE_CMD) -f msvcrt.mak $@
    2627    $(MAKE_CMD) -f msvcrt20.mak $@
    2728    $(MAKE_CMD) -f msvcrt40.mak $@
     29!endif
     30    $(MAKE_CMD) -f minivcrt.mak $@
    2831
    2932# don't have to make deps more than once.
  • trunk/src/msvcrt/wcs.c

    r10005 r21398  
    1919 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2020 */
     21
     22#ifndef __MINIVCRT__
     23
    2124#include <limits.h>
    2225#include <stdlib.h>
     
    3841WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
    3942
     43#else /* !__MINIVCRT__ */
     44
     45#include <string.h>
     46#include <sys/limits.h>
     47
     48#include <winbase.h>
     49
     50#include "minivcrt.h"
     51#include "minivcrt_internal.h"
     52
     53#include "winternl.h"
     54#include "wine/unicode.h"
     55
     56#endif /* !__MINIVCRT__ */
    4057
    4158/* INTERNAL: MSVCRT_malloc() based wstrndup */
Note: See TracChangeset for help on using the changeset viewer.