Ignore:
Timestamp:
Jul 17, 2005, 2:25:44 PM (20 years ago)
Author:
bird
Message:

o LIBC_ASSERT*() are for internal libc errors, LIBCLOG_ERROR*() are

for user related error. Big code adjustements.

o Fixed a few smaller issues.
o Started fixing exec() backend.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/InnoTekLIBC/logstrict.h

    • Property cvs2svn:cvs-rev changed from 1.13 to 1.14
    r2253 r2254  
    77 *
    88 * Copyright (c) 2004 InnoTek Systemberatung GmbH
     9 * Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@anduin.net>
    910 * Author: knut st. osmundsen <bird-srcspam@anduin.net>
    1011 *
     
    7677    unsigned __libclog_uEnterTS__ = __libc_LogEnter(__LIBC_LOG_INSTANCE, __LIBC_LOG_GROUP, __PRETTY_FUNCTION__, __VA_ARGS__)
    7778#else
    78 #define LIBCLOG_ENTER(...)  //hmm
     79#define LIBCLOG_ENTER(...)      //...
    7980#endif
    8081
     
    8485    __libc_LogMsg(__libclog_uEnterTS__, __LIBC_LOG_INSTANCE, __LIBC_LOG_GROUP, __PRETTY_FUNCTION__, __VA_ARGS__)
    8586#else
    86 #define LIBCLOG_MSG(...)    do {} while (0)
    87 #endif
    88 
    89 /** Macro to log a generic message within a functionw. */
     87#define LIBCLOG_MSG(...)        ((void)0)
     88#endif
     89
     90/** Macro to log a generic message within a function. */
    9091#ifdef DEBUG_LOGGING
    9192#define LIBCLOG_MSG2(...) \
    9293    __libc_LogMsg(~0, __LIBC_LOG_INSTANCE, __LIBC_LOG_GROUP, __PRETTY_FUNCTION__, __VA_ARGS__)
    9394#else
    94 #define LIBCLOG_MSG2(...)   do {} while (0)
     95#define LIBCLOG_MSG2(...)       ((void)0)
     96#endif
     97
     98/** Macro to log an user error within a function entered by LIBCLOG_ENTER(). */
     99#ifdef DEBUG_LOGGING
     100#define LIBCLOG_ERROR(...) \
     101    __libc_LogError(__libclog_uEnterTS__, __LIBC_LOG_INSTANCE, __LIBC_LOG_GROUP, __PRETTY_FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
     102#else
     103#define LIBCLOG_ERROR(...)      ((void)0)
     104#endif
     105
     106/** Macro to log an user error within a function. */
     107#ifdef DEBUG_LOGGING
     108#define LIBCLOG_ERROR2(...) \
     109    __libc_LogError(~0, __LIBC_LOG_INSTANCE, __LIBC_LOG_GROUP, __PRETTY_FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
     110#else
     111#define LIBCLOG_ERROR2(...)     ((void)0)
     112#endif
     113
     114/** Macro to check for and log an user error within a function entered by LIBCLOG_ENTER(). */
     115#ifdef DEBUG_LOGGING
     116#define LIBCLOG_ERROR_CHECK(expr, ...) \
     117    (!(expr) ? __libc_LogError(__libclog_uEnterTS__, __LIBC_LOG_INSTANCE, __LIBC_LOG_GROUP, __PRETTY_FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) : ((void)0) )
     118#else
     119#define LIBCLOG_ERROR_CHECK(expr, ...) ((void)0)
     120#endif
     121
     122/** Macro to check for and log an user error within a function. */
     123#ifdef DEBUG_LOGGING
     124#define LIBCLOG_ERROR2_CHECK(expr, ...) \
     125    (!(expr) ? __libc_LogError(~0, __LIBC_LOG_INSTANCE, __LIBC_LOG_GROUP, __PRETTY_FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) : ((void)0) )
     126#else
     127#define LIBCLOG_ERROR2_CHECK(expr, ...) ((void)0)
    95128#endif
    96129
     
    100133    __libc_LogRaw(__LIBC_LOG_INSTANCE, __LIBC_LOG_GROUP, string, maxlen)
    101134#else
    102 #define LIBCLOG_RAW(...)    do {} while (0)
    103 #endif
    104 
    105 /** Macro to log a function exit. */
     135#define LIBCLOG_RAW(...)        ((void)0)
     136#endif
     137
     138/** Macro to leave a function entered by LIBCLOG_ENTER(). */
    106139#ifdef DEBUG_LOGGING
    107140#define LIBCLOG_LEAVE(...) \
    108141    __libc_LogLeave(__libclog_uEnterTS__, __LIBC_LOG_INSTANCE, __LIBC_LOG_GROUP, __PRETTY_FUNCTION__, __VA_ARGS__)
    109142#else
    110 #define LIBCLOG_LEAVE(...)  do {} while (0)
     143#define LIBCLOG_LEAVE(...)      ((void)0)
    111144#endif
    112145
    113146/** Macro to log a custom message and return. */
    114 #define LIBCLOG_RETURN_MSG(rc,...)      do { LIBCLOG_LEAVE(__VA_ARGS__);                       return (rc); } while (0)
     147#define LIBCLOG_RETURN_MSG(rc,...)      do { LIBCLOG_LEAVE(__VA_ARGS__); return (rc); } while (0)
    115148/** Macro to log a custom message and return. */
    116 #define LIBCLOG_RETURN_MSG_VOID(...)    do { LIBCLOG_LEAVE(__VA_ARGS__);                       return; } while (0)
     149#define LIBCLOG_RETURN_MSG_VOID(...)    do { LIBCLOG_LEAVE(__VA_ARGS__); return; } while (0)
    117150
    118151/** Macro to log a void return and do the return. */
     
    128161/** Macro to log a pointer return and do the return. */
    129162#define LIBCLOG_RETURN_P(rc)            LIBCLOG_RETURN_MSG((rc), "ret %p\n", (void*)(rc));
     163
     164
     165/** Macro to leave a function entered by LIBCLOG_ENTER() on user error. */
     166#ifdef DEBUG_LOGGING
     167#define LIBCLOG_ERROR_LEAVE(...) \
     168    __libc_LogErrorLeave(__libclog_uEnterTS__, __LIBC_LOG_INSTANCE, __LIBC_LOG_GROUP, __PRETTY_FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
     169#else
     170#define LIBCLOG_ERROR_LEAVE(...)      ((void)0)
     171#endif
     172
     173/** Macro to log a user error and return. */
     174#define LIBCLOG_ERROR_RETURN(rc,...)          do { LIBCLOG_ERROR_LEAVE(__VA_ARGS__); return (rc); } while (0)
     175#define LIBCLOG_ERROR_RETURN_MSG              LIBCLOG_ERROR_RETURN
     176/** Macro to log a user error and return. */
     177#define LIBCLOG_ERROR_RETURN_MSG_VOID(...)    do { LIBCLOG_ERROR_LEAVE(__VA_ARGS__); return; } while (0)
     178
     179/** Macro to log a void return user error and do the return. */
     180#define LIBCLOG_ERROR_RETURN_VOID()           LIBCLOG_ERROR_RETURN_MSG_VOID( "ret void\n")
     181/** Macro to log an int return user error and do the return. */
     182#define LIBCLOG_ERROR_RETURN_INT(rc)          LIBCLOG_ERROR_RETURN_MSG((rc), "ret %d (%#x)\n", (rc), (rc))
     183/** Macro to log an unsigned int return user error and do the return. */
     184#define LIBCLOG_ERROR_RETURN_UINT(rc)         LIBCLOG_ERROR_RETURN_MSG((rc), "ret %u (%#x)\n", (rc), (rc));
     185/** Macro to log an long int return user error and do the return. */
     186#define LIBCLOG_ERROR_RETURN_LONG(rc)         LIBCLOG_ERROR_RETURN_MSG((rc), "ret %ld (%#lx)\n", (rc), (rc));
     187/** Macro to log an unsigned long int return user error and do the return. */
     188#define LIBCLOG_ERROR_RETURN_ULONG(rc)        LIBCLOG_ERROR_RETURN_MSG((rc), "ret %lu (%#lx)\n", (rc), (rc));
     189/** Macro to log a pointer return user error and do the return. */
     190#define LIBCLOG_ERROR_RETURN_P(rc)            LIBCLOG_ERROR_RETURN_MSG((rc), "ret %p\n", (void*)(rc));
     191
    130192
    131193/** @defgroup   __libc_log_flags    Message Flags (to be combined with group)
     
    183245/** Memory Manager APIs. */
    184246#define __LIBC_LOG_GRP_MMAN         16
     247/** Load APIs. */
     248#define __LIBC_LOG_GRP_LDR          1 /** @todo fix me */
    185249
    186250/** Backend SysV IPC APIs. */
     
    467531/**
    468532 * Output a leave function log message.
     533 *
    469534 * A leave message is considered to be one line and is appended a newline if
    470535 * none was given.
     
    481546
    482547/**
     548 * Output a leave function log message upon a user error.
     549 *
     550 * The function may breakpoint if configured to do so. A leave message is
     551 * considered to be one line and is appended a newline if none was given.
     552 *
     553 * @param   uEnterTS        The timestamp returned by LogEnter.
     554 * @param   pvInstance      Logger instance. If NULL the message goes to the
     555 *                          default log instance.
     556 * @param   fGroupAndFlags  Logging group and logging flags.
     557 * @param   pszFunction     Name of the function which was entered.
     558 * @param   pszFile         Source filename.
     559 * @param   uLine           Line number.
     560 * @param   pszFormat       Format string to display the result.
     561 * @param   ...             Arguments to the format string.
     562 */
     563extern void     __libc_LogErrorLeave(unsigned uEnterTS, void *pvInstance, unsigned fGroupAndFlags, const char *pszFunction, const char *pszFile, unsigned uLine, const char *pszFormat, ...) __printflike(7, 8);
     564
     565/**
    483566 * Output a log message.
     567 *
    484568 * A log message is considered to be one line and is appended a newline if
    485569 * none was given.
     
    494578 */
    495579extern void     __libc_LogMsg(unsigned uEnterTS, void *pvInstance, unsigned fGroupAndFlags, const char *pszFunction, const char *pszFormat, ...) __printflike(5, 6);
     580
     581/**
     582 * Output a log user error message.
     583 *
     584 * This may raise a breakpoint exception if configured so. A log message is
     585 * considered to be one line and is appended a newline if none was given.
     586 *
     587 * @param   uEnterTS        The timestamp returned by LogEnter.
     588 * @param   pvInstance      Logger instance. If NULL the message goes to the
     589 *                          default log instance.
     590 * @param   fGroupAndFlags  Logging group and logging flags.
     591 * @param   pszFunction     Name of the function which was entered.
     592 * @param   pszFile         Source filename.
     593 * @param   uLine           Line number.
     594 * @param   pszFormat       Format string for the message to log.
     595 * @param   ...             Arguments to the format string.
     596 */
     597extern void     __libc_LogError(unsigned uEnterTS, void *pvInstance, unsigned fGroupAndFlags, const char *pszFunction, const char *pszFile, unsigned uLine, const char *pszFormat, ...) __printflike(7, 8);
    496598
    497599/**
Note: See TracChangeset for help on using the changeset viewer.