Ignore:
Timestamp:
Aug 27, 2007, 6:06:17 AM (18 years ago)
Author:
bird
Message:

Use kStuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kStuff/kProfile/kPrf2Read.cpp

    r3537 r3565  
    11/* $Id: $ */
    22/** @file
    3  *
    4  * kProfiler Mark 2 - The reader and statistics producer.
    5  *
    6  * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de>
    7  *
    8  *
    9  * This file is part of kLIBC.
    10  *
    11  * kLIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
    14  * (at your option) any later version.
    15  *
    16  * kLIBC is distributed in the hope that it will be useful,
     3 * kProfiler Mark 2 - The reader and producer of statistics.
     4 */
     5
     6/*
     7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
     8 *
     9 * This file is part of kProfiler.
     10 *
     11 * kProfiler is free software; you can redistribute it and/or
     12 * modify it under the terms of the GNU Lesser General Public
     13 * License as published by the Free Software Foundation; either
     14 * version 2.1 of the License, or (at your option) any later version.
     15 *
     16 * kProfiler is distributed in the hope that it will be useful,
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
    22  * along with kLIBC; if not, write to the Free Software
    23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24  *
    25  */
    26 
     18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     19 * Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public
     22 * License along with kProfiler; if not, write to the Free Software
     23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     24 *
     25 */
    2726
    2827
     
    3433#include <string.h>
    3534#include <stdarg.h>
    36 #if 0
    37 # ifdef KPRF_OS_WINDOWS
    38 #  include <malloc.h>
    39 typedef unsigned char uint8_t;
    40 typedef signed char int8_t;
    41 typedef unsigned short uint16_t;
    42 typedef signed short int16_t;
    43 typedef unsigned int uint32_t;
    44 typedef signed int int32_t;
    45 typedef unsigned _int64 uint64_t;
    46 typedef signed _int64 int64_t;
    47 typedef size_t uintptr_t;
    48 # else
    49 #  include <stdint.h>
    50 # endif
    51 #else
    52     /* iprt mode */
    53 #include <iprt/types.h>
    54 #include <iprt/err.h>
    55 #include <iprt/avl.h>
    56 #if 1
    57 # include <iprt/alloc.h>
    58 # define malloc(cb) RTMemAlloc(cb)
    59 # define free(pv) RTMemFree(pv)
    60 #endif
    61 #endif
    62 
    63 #include "dbg.h"
     35#include <k/kDbg.h>
    6436
    6537
     
    6941 */
    7042#define KPRF_OFF2PTR(TypePrefix, TypeName, off, pHdr) \
    71     ( (KPRF_TYPE(TypePrefix, TypeName)) ((off) + (uintptr_t)pHdr) )
     43    ( (KPRF_TYPE(TypePrefix, TypeName)) ((off) + (KUPTR)pHdr) )
    7244
    7345/** @def KPRF_ALIGN
     
    7850
    7951/** @def KPRF_OFFSETOF
    80  * My usual extended OFFSETOF macro, except this returns uint32_t and mangles the type name.
     52 * My usual extended offsetof macro, except this returns KU32 and mangles the type name.
    8153 * @internal
    8254 */
    83 #define KPRF_OFFSETOF(kPrfType, Member) ( (uint32_t)(uintptr_t)&((KPRF_TYPE(P,kPrfType))0)->Member )
     55#define KPRF_OFFSETOF(kPrfType, Member) ( (KU32)(KUPTR)&((KPRF_TYPE(P,kPrfType))0)->Member )
    8456
    8557/** @def PRF_SIZEOF
     
    161133 * @param   pOut                Where to write errors.
    162134 */
    163 PKPRFHDR kPrfLoad(const char *pszFilename, uint32_t *pcb, FILE *pOut)
     135PKPRFHDR kPrfLoad(const char *pszFilename, KU32 *pcb, FILE *pOut)
    164136{
    165137    FILE *pFile = fopen(pszFilename, "rb");
     
    215187 * @param   pOut        Where to write error messages.
    216188 */
    217 static bool kPrfIsValidate(PCKPRFHDR pHdr, uint32_t cb, FILE *pOut)
     189static bool kPrfIsValidate(PCKPRFHDR pHdr, KU32 cb, FILE *pOut)
    218190{
    219191    /*
     
    254226    KPRF_VALIDATE_SIZE(Thread, sizeof(KPRF32THREAD), sizeof(KPRF64THREAD));
    255227    KPRF_VALIDATE_SIZE(Stack,
    256                        (uint32_t)&((PKPRF32STACK)0)->aFrames[pHdr->Hdr32.cMaxStackFrames],
    257                        (uint32_t)&((PKPRF64STACK)0)->aFrames[pHdr->Hdr32.cMaxStackFrames]);
    258 
    259     uintptr_t cbHeader = (uintptr_t)&pHdr->Hdr32.aiFunctions[pHdr->Hdr32.cFunctions] - (uintptr_t)pHdr;
    260     if (    cbHeader != (uint32_t)cbHeader
     228                       (KU32)&((PKPRF32STACK)0)->aFrames[pHdr->Hdr32.cMaxStackFrames],
     229                       (KU32)&((PKPRF64STACK)0)->aFrames[pHdr->Hdr32.cMaxStackFrames]);
     230
     231    KUPTR cbHeader = (KUPTR)&pHdr->Hdr32.aiFunctions[pHdr->Hdr32.cFunctions] - (KUPTR)pHdr;
     232    if (    cbHeader != (KU32)cbHeader
    261233        ||  cbHeader >= cb)
    262234    {
     
    267239
    268240    /* The space assignment is hereby required to be equal to the member order in the header. */
    269     uint32_t offMin = cbHeader;
     241    KU32 offMin = cbHeader;
    270242#define KPRF_VALIDATE_OFF(off, name) do {\
    271243        if (    off > 0 \
     
    322294     * Validate the function lookup table
    323295     */
    324     for (uint32_t i = 0; i < pHdr->Hdr32.cFunctions; i++)
     296    for (KU32 i = 0; i < pHdr->Hdr32.cFunctions; i++)
    325297        if (pHdr->Hdr32.aiFunctions[i] >= pHdr->Hdr32.cFunctions)
    326298        {
     
    362334     * Load and validate the data set.
    363335     */
    364     uint32_t cb;
     336    KU32 cb;
    365337    PKPRFHDR pHdr = kPrfLoad(pszFilename, &cb, pOut);
    366338    if (!pHdr)
     
    407379     * Load and validate the data set.
    408380     */
    409     uint32_t cb;
     381    KU32 cb;
    410382    PKPRFHDR pHdr = kPrfLoad(pszFilename, &cb, pOut);
    411383    if (!pHdr)
Note: See TracChangeset for help on using the changeset viewer.