Changeset 3943 for trunk


Ignore:
Timestamp:
Dec 29, 2014, 12:31:07 AM (11 years ago)
Author:
bird
Message:

os2safe.h: Wrap DosCreateQueue, DosOpenQueue, DosPeekQueue, DosQueryQueue and DosReadQueue, but NOT DosWriteQueue (see comment).

Location:
trunk/libc
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/include/os2safe.h

    r3942 r3943  
    5555#define WinUpper                SafeWinUpper
    5656
     57/*
     58 * Note! The DOS queue API does not work with data, but with addresses, request
     59 * numbers, priorities and process IDs.  I.e. the data address you give
     60 * DosWriteQueue is NOT used to memcpy() what it points to into some internal
     61 * buffer that is then queued.  Instead that address is converted to 16-bit and
     62 * placed on the queue.
     63 *
     64 * This means that the data pointer passed to DosWriteQueue CANNOT be a high
     65 * address!  (The wrappers below makes sure all the other pointer parameters
     66 * can be pointing to high memory, though.)
     67 */
     68#define DosCreateQueue          SafeDosCreateQueue
     69#define DosOpenQueue            SafeDosOpenQueue
     70#define DosPeekQueue            SafeDosPeekQueue
     71#define DosQueryQueue           SafeDosQueryQueue
     72#define DosReadQueue            SafeDosReadQueue
     73
    5774#endif
    5875
  • trunk/libc/src/libos2/safe/safe.h

    r3942 r3943  
    11/* $Id$ */
    22/** @file
    3  *
    43 * Macros, prototypes and inline helpers.
    54 *
    6  * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net>
    7  *
    8  *
    9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  *
    19  * You should have received a copy of the GNU General Public License
    20  * along with This program; if not, write to the Free Software
    21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *
     5 * @copyright   Copyright (C) 2003-2015 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
     6 * @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3, LGPLvFuture.
    237 */
     8
    249#ifndef __safe_h__
    2510#define __safe_h__
     
    4631            memcpy(arg##_safe, (arg), cch); \
    4732        } else do {} while (0)
    48 
    4933/** Use the const string. */
    5034#define SAFE_PCSZ_USE(arg) arg##_safe
    51 
    5235/** Cleanup a const string. */
    5336#define SAFE_PCSZ_DONE(arg) \
     
    5639    } \
    5740    l_##arg##_failed: do {} while (0)
     41
     42
     43
     44/** Wrap an input only buffer. */
     45#define SAFE_INBUF(arg, len, type) \
     46    { \
     47        type *arg##_safe = arg; \
     48        if (SAFE_IS_HIGH(arg)) \
     49        { \
     50            arg##_safe = (type *)_lmalloc(len); \
     51            if (!arg##_safe) { rc = 8; goto l_##arg##_failed; } \
     52            memcpy(arg##_safe, (arg), len); \
     53        } else do {} while (0)
     54/** Use the safe input only buffer. */
     55#define SAFE_INBUF_USE(arg) arg##_safe
     56/** Cleanup an input only buffer. */
     57#define SAFE_INBUF_DONE(arg, len) \
     58        if (arg##_safe != arg) \
     59           free(arg##_safe); \
     60    } \
     61    l_##arg##_failed: do {} while (0)
     62
     63
    5864
    5965/** Wrap an input/output buffer. */
     
    6773            memcpy(arg##_safe, (arg), len);\
    6874        } else do {} while (0)
    69 
    7075/** Use the safe input/output buffer. */
    7176#define SAFE_INOUTBUF_USE(arg) arg##_safe
    72 
    7377/** Cleanup an input/output buffer. */
    7478#define SAFE_INOUTBUF_DONE(arg, len) \
     
    8084    } \
    8185    l_##arg##_failed: do {} while (0)
     86
     87
    8288
    8389/** Wrap the pointer to an input only type/struct. */
     
    95101            *arg##_safe = *(arg); \
    96102        } else do {} while (0)
    97 
    98103/** Use the safe pointer to an input only type/struct. */
    99104#define SAFE_INTYPE_USE(arg) arg##_safe
    100 
    101105/** Cleanup after wrapping an input only type/struct. */
    102106#define SAFE_INTYPE_DONE(arg) \
     
    105109    } \
    106110    l_##arg##_failed: do {} while (0)
     111
     112
    107113
    108114/** Wrap the pointer to an input/output type/struct. */
     
    120126            *arg##_safe = *(arg); \
    121127        } else do {} while (0)
    122 
    123128/** Use the safe pointer to an input/output type/struct. */
    124129#define SAFE_INOUTTYPE_USE(arg) arg##_safe
    125 
    126130/** Cleanup after wrapping an input/output type/struct. */
    127131#define SAFE_INOUTTYPE_DONE(arg) \
     
    134138
    135139
     140#endif
    136141
    137 /** Generic failure label for Dos API wappers.
    138  * It'll just return out of memory error.
    139  * @obsolete  */
    140 #define SAFE_DOS_FAILURE() do { } while (0)
    141 
    142 
    143 #endif
Note: See TracChangeset for help on using the changeset viewer.