Changeset 1271 for trunk/src


Ignore:
Timestamp:
Oct 14, 1999, 3:19:22 AM (26 years ago)
Author:
bird
Message:

Changes during Pe2Lx rewrite.

Location:
trunk/src/win32k/misc
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/misc/malloc.c

    r847 r1271  
    1 /* $Id: malloc.c,v 1.1 1999-09-06 02:20:02 bird Exp $
     1/* $Id: malloc.c,v 1.2 1999-10-14 01:19:21 bird Exp $
    22 *
    33 * Heap.
     
    1919
    2020#define SIGNATURE 0xBEEFFEEB
    21 #define CB_HDR (sizeof(MEMBLOCK) - 1) /* size of MEMBLOCK header (in bytes) */
     21/*#define CB_HDR (sizeof(MEMBLOCK) - 1) /* size of MEMBLOCK header (in bytes) */
     22#define CB_HDR (int)&(((PMEMBLOCK)0)->achUserData[0])
    2223#define PNEXT_BLOCK(a) ((PMEMBLOCK)((unsigned)(a) + CB_HDR + (a)->cbSize))
    2324
     
    2526#define INCL_DOSERRORS
    2627#ifdef RING0
    27 #define INCL_NOAPI
     28    #define INCL_NOAPI
    2829#else
    29 #define INCL_DOSMEMMGR
     30    #define INCL_DOSMEMMGR
    3031#endif
     32
    3133
    3234/******************************************************************************
     
    3436******************************************************************************/
    3537#include <os2.h>
    36 
     38#ifdef RING0
     39    #include "dev32hlp.h"
     40    #include "asmutils.h"
     41#else
     42    #include <builtin.h>
     43    #define Int3() __interrupt(3)
     44#endif
    3745#include "log.h"
    38 #include "dev32hlp.h"
    39 #include "asmutils.h"
    4046#include "malloc.h"
    41 #include "memory.h"
     47#include <memory.h>
    4248
    4349
     
    4551*  Structs and Typedefs
    4652******************************************************************************/
     53#pragma pack(1)
    4754typedef struct _MEMBLOCK /* MB */
    4855{
     
    5461   unsigned char     achUserData[1];
    5562} MEMBLOCK, *PMEMBLOCK;
    56 
     63#pragma pack()
    5764
    5865/******************************************************************************
    5966*  Global data
    6067******************************************************************************/
     68/*#pragma info(nogen, nouni, noext)*/
    6169static PMEMBLOCK   pUsed;         /* pointer to the used memblock chain. */
    6270static PMEMBLOCK   pFree;         /* pointer to the free memblock chain. */
    6371static unsigned    cbFree;        /* bytes of free user memory in the heap.*/
    64 unsigned           _uHeapMinPtr; /* heap pointers are greater or equal to this.*/
    65 unsigned           _uHeapMaxPtr; /* heap pointers are less than this. */
     72unsigned           _uHeapMinPtr;  /* heap pointers are greater or equal to this.*/
     73unsigned           _uHeapMaxPtr;  /* heap pointers are less than this. */
     74#ifndef RING0
     75    char           fInited;       /* init flag */
     76#endif
    6677
    6778/******************************************************************************
     
    277288    pUsed = NULL;
    278289
    279     #if RING0
     290    #ifdef RING0
    280291        pFree = D32Hlp_VMAlloc(VMDHA_SWAP | VMDHA_USEHIGHMEM, cbSize, ~0UL);
    281292    #else
    282         if (DosAllocMem(&pFree, cbSize, PAG_COMMIT | PAG_READ | PAG_WRITE) != 0)
    283             pFree = NULL
     293        if (DosAllocMem((void*)&pFree, cbSize, PAG_COMMIT | PAG_READ | PAG_WRITE) != 0)
     294            pFree = NULL;
    284295    #endif
    285296    if (pFree == NULL)
     
    308319            return -2;
    309320        }
     321    #endif
     322    #ifdef RING3
     323        fInited = TRUE;
    310324    #endif
    311325    return 0;
     
    323337{
    324338    void *pvRet = NULL;
     339
    325340    #ifdef DEBUG_ALLOC
    326341        if (!_heap_check())
     
    384399            pvRet = malloc(cbNew);
    385400            if (pvRet != NULL)
     401            {
    386402                memcpy(pvRet, pv, pMemblock->cbSize);
    387         }
    388 
     403                free(pv);
     404            }
     405        }
     406        return pvRet;
    389407    }
    390408    return NULL;
     
    598616
    599617
     618#if !defined(RING0) && defined(__IBMC__)
     619
     620/**
     621 * Initialize Memory Functions
     622 * Called from _exeentry.
     623 */
     624int _rmem_init(void)
     625{
     626    int rc = heapInit(HEAP_SIZE);
     627    return rc;
     628}
     629
     630/**
     631 * Initialize Memory Functions
     632 * Called from _exeentry.
     633 */
     634int _rmem_term(void)
     635{
     636    return 0;
     637}
     638
     639#endif
  • trunk/src/win32k/misc/new.cpp

    r847 r1271  
    1 /* $Id: new.cpp,v 1.1 1999-09-06 02:20:02 bird Exp $
     1/* $Id: new.cpp,v 1.2 1999-10-14 01:19:21 bird Exp $
    22 *
    33 * new - new and delete operators.
     
    2020
    2121#include "new.h"
    22 #include "cout.h"
    2322#include "malloc.h"
     23#include "log.h"
    2424
    2525
     26#pragma info(none)
    2627/**
    2728 * New.
     
    4041void *operator new(size_t size, void *location)
    4142{
    42     cout << "operator new(size,location) not implemented"<< endl;
     43    dprintf(("operator new(size,location) not implemented\n"));
    4344    return NULL;
    4445}
     
    5051void *operator new[](size_t size)
    5152{
    52     cout << "operator new[](size) not implemented"<< endl;
     53    dprintf(("operator new[](size) not implemented\n"));
    5354    return NULL;
    5455}
     
    6061void *operator new[](size_t size, void *location)
    6162{
    62     cout << "operator new[](size,location) not implemented"<< endl;
     63    dprintf(("operator new[](size,location) not implemented\n"));
    6364    return NULL;
    6465}
    6566
    66 
     67#ifndef __DEBUG_ALLOC__
    6768/**
    6869 * Delete.
     
    8081void operator delete[](void *location)
    8182{
    82     cout << "operator delete[](location) - not implemented" << endl;
     83    dprintf(("operator delete[](location) - not implemented\n"));
     84}
     85#endif
     86
     87/***
     88 *  debug!
     89 ***/
     90
     91/**
     92 * New.
     93 * @returns   pointer to allocated memory.
     94 * @param     Size  Size requested.
     95 */
     96void *operator new(size_t size, const char *filename, size_t lineno)
     97{
     98    return malloc(size);
    8399}
    84100
     101
     102/**
     103 * stub
     104 */
     105void *operator new(size_t size, const char *filename, size_t lineno, void *location)
     106{
     107    dprintf(("operator new(size,location) not implemented\n"));
     108    return NULL;
     109}
     110
     111
     112/**
     113 * stub
     114 */
     115void *operator new[](size_t size, const char *filename, size_t lineno)
     116{
     117    dprintf(("operator new[](size) not implemented\n"));
     118    return NULL;
     119}
     120
     121
     122/**
     123 * stub
     124 */
     125void *operator new[](size_t size, const char *filename, size_t lineno, void *location)
     126{
     127    dprintf(("operator new[](size,location) not implemented\n"));
     128    return NULL;
     129}
     130
     131#ifdef __DEBUG_ALLOC__
     132/**
     133 * Delete.
     134 * @param     location  Pointer to memory block which are to be freed.
     135 */
     136void operator delete(void *location, const char *filename, size_t lineno)
     137{
     138    free(location);
     139}
     140
     141
     142/**
     143 * stub
     144 */
     145void operator delete[](void *location, const char *filename, size_t lineno)
     146{
     147    dprintf(("operator delete[](location) - not implemented\n"));
     148}
     149#endif
  • trunk/src/win32k/misc/stricmp.c

    r847 r1271  
    1 /* $Id: stricmp.c,v 1.1 1999-09-06 02:20:02 bird Exp $
     1/* $Id: stricmp.c,v 1.2 1999-10-14 01:19:21 bird Exp $
    22 *
    33 * stricmp - Case insensitive string compare.
     
    1818*******************************************************************************/
    1919#include <string.h>
    20 
     20#pragma info(nogen, noext, nouni)
    2121
    2222/**
    23  * strcmpi - case insensitive string compare. Not i subsys library.
     23 * stricmp - case insensitive string compare.
     24 * Not i subsys library.
    2425 * @param   psz1   String 1
    25  * @parma   psz2   String 2
     26 * @param   psz2   String 2
    2627 * @return  0 if equal
    2728 *          != 0 if not equal
     
    3738}
    3839
     40
     41
     42/**
     43 * strnicmp - case insensitive string compare for up to cch chars of the strings.
     44 * Not i subsys library.
     45 * @param   psz1   String 1
     46 * @param   psz2   String 2
     47 * @return  0 if equal
     48 *          != 0 if not equal
     49 */
     50int strnicmp(const char *psz1, const char *psz2, size_t cch)
     51{
     52    int iRet;
     53
     54    while (cch > 0 && (iRet = upcase(*psz1) - upcase(*psz2)) == 0 && *psz1 != '\0')
     55        psz1++, psz2++, cch--;
     56
     57    return iRet;
     58}
     59
  • trunk/src/win32k/misc/vsprintf.c

    r847 r1271  
    1 /* $Id: vsprintf.c,v 1.1 1999-09-06 02:20:02 bird Exp $
     1/* $Id: vsprintf.c,v 1.2 1999-10-14 01:19:22 bird Exp $
    22 *
    33 * vsprintf and sprintf
     
    3131#include <stdarg.h>
    3232
    33 #include "dev32.h"
     33#ifdef RING0
     34    #include "dev32.h"
     35#else
     36    #define SSToDS(a) (a)
     37#endif
    3438#include "sprintf.h"
    3539
     
    128132        }
    129133        else if (fFlags & (NTSF_PLUS | NTSF_BLANK))
    130             psz[i++] = fFlags & NTSF_PLUS ? '+' : ' ';
     134            psz[i++] = (char)(fFlags & NTSF_PLUS ? '+' : ' ');
    131135    }
    132136
     
    135139        psz[i++] = '0';
    136140        if (uiBase == 16)
    137             psz[i++] = fFlags & NTSF_CAPITAL ? 'X' : 'x';
     141            psz[i++] = (char)(fFlags & NTSF_CAPITAL ? 'X' : 'x');
    138142    }
    139143
     
    181185
    182186
     187#pragma info(notrd)
    183188/**
    184189 * Partial vsprintf implementation.
     
    295300                        char *pszStr = va_arg(args, char*);
    296301
    297                         if (pszStr > (char*)0x10000)
     302                        if (pszStr < (char*)0x10000)
    298303                            pszStr = "<NULL>";
    299304                        cchStr = _strnlen(pszStr, (unsigned)cchPrecision);
Note: See TracChangeset for help on using the changeset viewer.