| 1 |
|
| 2 |
/* |
| 3 |
* Copyright (c) 2018 Chris Jones <[email protected]> |
| 4 |
* |
| 5 |
* Permission to use, copy, modify, and distribute this software for any |
| 6 |
* purpose with or without fee is hereby granted, provided that the above |
| 7 |
* copyright notice and this permission notice appear in all copies. |
| 8 |
* |
| 9 |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef _MACPORTS_STDLIB_H_ |
| 19 |
#define _MACPORTS_STDLIB_H_ |
| 20 |
|
| 21 |
/* MP support header */ |
| 22 |
#include "MacportsLegacySupport.h" |
| 23 |
|
| 24 |
/* Include the primary system stdlib.h */ |
| 25 |
#include_next <stdlib.h> |
| 26 |
|
| 27 |
/* posix_memalign */ |
| 28 |
#if __MP_LEGACY_SUPPORT_POSIX_MEMALIGN__ |
| 29 |
|
| 30 |
/* |
| 31 |
* [XSI] The ssize_t and size_t types shall be defined as described |
| 32 |
* in <sys/types.h>. |
| 33 |
*/ |
| 34 |
#ifndef _SIZE_T |
| 35 |
#define _SIZE_T |
| 36 |
typedef __darwin_size_t size_t; |
| 37 |
#endif |
| 38 |
|
| 39 |
#ifndef _SSIZE_T |
| 40 |
#define _SSIZE_T |
| 41 |
typedef __darwin_ssize_t ssize_t; |
| 42 |
#endif |
| 43 |
|
| 44 |
__MP__BEGIN_DECLS |
| 45 |
extern int posix_memalign(void **memptr, size_t alignment, size_t size); |
| 46 |
__MP__END_DECLS |
| 47 |
|
| 48 |
#endif /* __MP_LEGACY_SUPPORT_POSIX_MEMALIGN__ */ |
| 49 |
|
| 50 |
/* arc4random */ |
| 51 |
#if __MP_LEGACY_SUPPORT_ARC4RANDOM__ |
| 52 |
|
| 53 |
#ifndef _SIZE_T |
| 54 |
#define _SIZE_T |
| 55 |
typedef __darwin_size_t size_t; |
| 56 |
#endif |
| 57 |
#ifndef _UINT32_T |
| 58 |
#define _UINT32_T |
| 59 |
typedef unsigned int uint32_t; |
| 60 |
#endif |
| 61 |
|
| 62 |
/* |
| 63 |
* Generate and return a uniformly random 32-bit quantity with an |
| 64 |
* upper bound of 'upper_bound' |
| 65 |
*/ |
| 66 |
__MP__BEGIN_DECLS |
| 67 |
extern uint32_t arc4random_uniform( uint32_t upper_bound ); |
| 68 |
__MP__END_DECLS |
| 69 |
|
| 70 |
/* |
| 71 |
* Generate 'n' random bytes and put them in 'buf'. |
| 72 |
*/ |
| 73 |
__MP__BEGIN_DECLS |
| 74 |
extern void arc4random_buf( void* buf, size_t n ); |
| 75 |
__MP__END_DECLS |
| 76 |
|
| 77 |
#endif /* __MP_LEGACY_SUPPORT_ARC4RANDOM__ */ |
| 78 |
|
| 79 |
#endif /* _MACPORTS_STDLIB_H_ */ |