robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 1 | /* |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 2 | * |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 3 | * honggfuzz - utilities |
| 4 | * ----------------------------------------- |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 5 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 6 | * Author: Robert Swiecki <swiecki@google.com> |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 7 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 8 | * Copyright 2010-2015 by Google Inc. All Rights Reserved. |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 9 | * |
| 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 11 | * not use this file except in compliance with the License. You may obtain |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 12 | * a copy of the License at |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 13 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 15 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 16 | * Unless required by applicable law or agreed to in writing, software |
| 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 19 | * implied. See the License for the specific language governing |
| 20 | * permissions and limitations under the License. |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 21 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 22 | */ |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 23 | |
| 24 | #ifndef _UTIL_H_ |
| 25 | #define _UTIL_H_ |
| 26 | |
robert.swiecki@gmail.com | 36700b5 | 2015-02-22 05:03:16 +0000 | [diff] [blame] | 27 | #include <stdarg.h> |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 28 | #include <stdint.h> |
| 29 | |
robert.swiecki@gmail.com | 90e9911 | 2015-02-15 02:05:14 +0000 | [diff] [blame] | 30 | extern uint64_t util_rndGet(uint64_t min, uint64_t max); |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 31 | |
robert.swiecki@gmail.com | 89cc38c | 2015-02-23 02:52:08 +0000 | [diff] [blame] | 32 | extern void util_rndBuf(uint8_t * buf, size_t sz); |
| 33 | |
robert.swiecki@gmail.com | 9e2d43d | 2015-02-16 12:17:39 +0000 | [diff] [blame] | 34 | extern int util_ssnprintf(char *str, size_t size, const char *format, ...); |
| 35 | |
| 36 | extern int util_vssnprintf(char *str, size_t size, const char *format, va_list ap); |
robert.swiecki@gmail.com | e7190b9 | 2015-02-14 23:05:42 +0000 | [diff] [blame] | 37 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 38 | extern void util_getLocalTime(const char *fmt, char *buf, size_t len); |
| 39 | |
robert.swiecki | aac72e0 | 2010-12-13 19:49:15 +0000 | [diff] [blame] | 40 | extern void util_nullifyStdio(void); |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 41 | |
| 42 | extern bool util_redirectStdin(char *inputFile); |
| 43 | |
robert.swiecki | aac72e0 | 2010-12-13 19:49:15 +0000 | [diff] [blame] | 44 | extern void util_recoverStdio(void); |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 45 | |
groebert@google.com | 1bd4c21 | 2013-06-19 11:13:56 +0000 | [diff] [blame] | 46 | extern uint64_t util_hash(const char *buf, size_t len); |
| 47 | |
robert.swiecki@gmail.com | 3213a11 | 2015-03-12 01:42:02 +0000 | [diff] [blame] | 48 | extern int64_t util_timeNowMillis(void); |
| 49 | |
robert.swiecki@gmail.com | 549ff18 | 2015-02-28 22:38:00 +0000 | [diff] [blame] | 50 | extern uint16_t util_ToFromBE16(uint16_t val); |
| 51 | extern uint16_t util_ToFromLE16(uint16_t val); |
| 52 | extern uint32_t util_ToFromBE32(uint32_t val); |
| 53 | extern uint32_t util_ToFromLE32(uint32_t val); |
| 54 | |
Jagger | 421aca8 | 2015-09-05 14:09:47 +0200 | [diff] [blame] | 55 | extern void MX_LOCK(pthread_mutex_t * mutex); |
| 56 | extern void MX_UNLOCK(pthread_mutex_t * mutex); |
| 57 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 58 | #endif |