Andrew Top | 2a79646 | 2018-06-29 09:04:04 -0700 | [diff] [blame] | 1 | // Copyright 2016 The Cobalt Authors. All Rights Reserved. |
David Ghandehari | ace1352 | 2016-09-02 22:40:01 -0700 | [diff] [blame] | 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // A poem (POsix EMulation) for functions in stdio.h |
| 16 | |
| 17 | #ifndef STARBOARD_CLIENT_PORTING_POEM_STDIO_POEM_H_ |
| 18 | #define STARBOARD_CLIENT_PORTING_POEM_STDIO_POEM_H_ |
| 19 | |
David Ghandehari | 74e3cb6 | 2016-09-15 07:47:48 -0700 | [diff] [blame] | 20 | #if defined(STARBOARD) |
| 21 | |
| 22 | #if !defined(POEM_NO_EMULATION) |
David Ghandehari | ace1352 | 2016-09-02 22:40:01 -0700 | [diff] [blame] | 23 | |
David Ghandehari | 74e3cb6 | 2016-09-15 07:47:48 -0700 | [diff] [blame] | 24 | #include "starboard/memory.h" |
David Ghandehari | 06a3c23 | 2016-10-07 13:54:30 -0700 | [diff] [blame] | 25 | #include "starboard/string.h" |
David Ghandehari | ace1352 | 2016-09-02 22:40:01 -0700 | [diff] [blame] | 26 | |
| 27 | #define wcsncmp(s1, s2, c) SbStringCompareWide(s1, s2, c) |
| 28 | |
| 29 | // the following functions can have variable number of arguments |
| 30 | // and, out of compatibility concerns, we chose to not use |
| 31 | // __VA_ARGS__ functionality. |
Andrew Top | 2a8c847 | 2018-06-13 17:27:01 -0700 | [diff] [blame] | 32 | #undef vsnprintf |
David Ghandehari | ace1352 | 2016-09-02 22:40:01 -0700 | [diff] [blame] | 33 | #define vsnprintf SbStringFormat |
Andrew Top | 2a8c847 | 2018-06-13 17:27:01 -0700 | [diff] [blame] | 34 | #undef snprintf |
David Ghandehari | ace1352 | 2016-09-02 22:40:01 -0700 | [diff] [blame] | 35 | #define snprintf SbStringFormatF |
Andrew Top | 2a8c847 | 2018-06-13 17:27:01 -0700 | [diff] [blame] | 36 | #undef sprintf |
David Ghandehari | ace1352 | 2016-09-02 22:40:01 -0700 | [diff] [blame] | 37 | #define sprintf SbStringFormatUnsafeF |
Andrew Top | 2a8c847 | 2018-06-13 17:27:01 -0700 | [diff] [blame] | 38 | #undef vsscanf |
David Ghandehari | ace1352 | 2016-09-02 22:40:01 -0700 | [diff] [blame] | 39 | #define vsscanf SbStringScan |
Andrew Top | 2a8c847 | 2018-06-13 17:27:01 -0700 | [diff] [blame] | 40 | #undef sscanf |
David Ghandehari | ace1352 | 2016-09-02 22:40:01 -0700 | [diff] [blame] | 41 | #define sscanf SbStringScanF |
Andrew Top | 2a8c847 | 2018-06-13 17:27:01 -0700 | [diff] [blame] | 42 | #undef malloc |
David Ghandehari | 8c0a79f | 2016-10-26 10:51:48 -0700 | [diff] [blame] | 43 | #define malloc(sz) SbMemoryAllocate(sz) |
Andrew Top | 2a8c847 | 2018-06-13 17:27:01 -0700 | [diff] [blame] | 44 | #undef calloc |
David Ghandehari | 06a3c23 | 2016-10-07 13:54:30 -0700 | [diff] [blame] | 45 | #define calloc(c, s) SbMemoryCalloc(c, s) |
Andrew Top | 2a8c847 | 2018-06-13 17:27:01 -0700 | [diff] [blame] | 46 | #undef free |
David Ghandehari | 8c0a79f | 2016-10-26 10:51:48 -0700 | [diff] [blame] | 47 | #define free(a) SbMemoryDeallocate(a) |
Andrew Top | 2a8c847 | 2018-06-13 17:27:01 -0700 | [diff] [blame] | 48 | #undef realloc |
David Ghandehari | 8c0a79f | 2016-10-26 10:51:48 -0700 | [diff] [blame] | 49 | #define realloc(m, sz) SbMemoryReallocate(m, sz) |
David Ghandehari | ace1352 | 2016-09-02 22:40:01 -0700 | [diff] [blame] | 50 | |
David Ghandehari | 74e3cb6 | 2016-09-15 07:47:48 -0700 | [diff] [blame] | 51 | #endif // POEM_NO_EMULATION |
| 52 | |
| 53 | #endif // STARBOARD |
David Ghandehari | ace1352 | 2016-09-02 22:40:01 -0700 | [diff] [blame] | 54 | |
| 55 | #endif // STARBOARD_CLIENT_PORTING_POEM_STDIO_POEM_H_ |