- Timestamp:
- Dec 29, 2014, 12:31:07 AM (11 years ago)
- Location:
- trunk/libc
- Files:
-
- 5 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/include/os2safe.h
r3942 r3943 55 55 #define WinUpper SafeWinUpper 56 56 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 57 74 #endif 58 75 -
trunk/libc/src/libos2/safe/safe.h
r3942 r3943 1 1 /* $Id$ */ 2 2 /** @file 3 *4 3 * Macros, prototypes and inline helpers. 5 4 * 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. 23 7 */ 8 24 9 #ifndef __safe_h__ 25 10 #define __safe_h__ … … 46 31 memcpy(arg##_safe, (arg), cch); \ 47 32 } else do {} while (0) 48 49 33 /** Use the const string. */ 50 34 #define SAFE_PCSZ_USE(arg) arg##_safe 51 52 35 /** Cleanup a const string. */ 53 36 #define SAFE_PCSZ_DONE(arg) \ … … 56 39 } \ 57 40 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 58 64 59 65 /** Wrap an input/output buffer. */ … … 67 73 memcpy(arg##_safe, (arg), len);\ 68 74 } else do {} while (0) 69 70 75 /** Use the safe input/output buffer. */ 71 76 #define SAFE_INOUTBUF_USE(arg) arg##_safe 72 73 77 /** Cleanup an input/output buffer. */ 74 78 #define SAFE_INOUTBUF_DONE(arg, len) \ … … 80 84 } \ 81 85 l_##arg##_failed: do {} while (0) 86 87 82 88 83 89 /** Wrap the pointer to an input only type/struct. */ … … 95 101 *arg##_safe = *(arg); \ 96 102 } else do {} while (0) 97 98 103 /** Use the safe pointer to an input only type/struct. */ 99 104 #define SAFE_INTYPE_USE(arg) arg##_safe 100 101 105 /** Cleanup after wrapping an input only type/struct. */ 102 106 #define SAFE_INTYPE_DONE(arg) \ … … 105 109 } \ 106 110 l_##arg##_failed: do {} while (0) 111 112 107 113 108 114 /** Wrap the pointer to an input/output type/struct. */ … … 120 126 *arg##_safe = *(arg); \ 121 127 } else do {} while (0) 122 123 128 /** Use the safe pointer to an input/output type/struct. */ 124 129 #define SAFE_INOUTTYPE_USE(arg) arg##_safe 125 126 130 /** Cleanup after wrapping an input/output type/struct. */ 127 131 #define SAFE_INOUTTYPE_DONE(arg) \ … … 134 138 135 139 140 #endif 136 141 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.