blob: ed613b365c910448a3bcb0aa8332ac83c343e4ac [file] [log] [blame]
robert.swiecki3bb518c2010-10-14 00:48:24 +00001/*
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +00002 *
robert.swiecki@gmail.com97c77332015-02-14 23:06:58 +00003 * honggfuzz - utilities
4 * -----------------------------------------
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +00005 *
robert.swiecki@gmail.com772b33d2015-02-14 20:35:00 +00006 * Author: Robert Swiecki <swiecki@google.com>
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +00007 *
robert.swiecki@gmail.com772b33d2015-02-14 20:35:00 +00008 * Copyright 2010-2015 by Google Inc. All Rights Reserved.
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +00009 *
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.com772b33d2015-02-14 20:35:00 +000012 * a copy of the License at
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +000013 *
robert.swiecki@gmail.com772b33d2015-02-14 20:35:00 +000014 * http://www.apache.org/licenses/LICENSE-2.0
robert.swiecki@gmail.com3b630b42015-02-16 10:53:53 +000015 *
robert.swiecki@gmail.com772b33d2015-02-14 20:35:00 +000016 * 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.com3b630b42015-02-16 10:53:53 +000021 *
robert.swiecki@gmail.com772b33d2015-02-14 20:35:00 +000022 */
robert.swiecki3bb518c2010-10-14 00:48:24 +000023
24#ifndef _UTIL_H_
25#define _UTIL_H_
26
robert.swiecki@gmail.com36700b52015-02-22 05:03:16 +000027#include <stdarg.h>
robert.swiecki3bb518c2010-10-14 00:48:24 +000028#include <stdint.h>
29
robert.swiecki@gmail.com90e99112015-02-15 02:05:14 +000030extern uint64_t util_rndGet(uint64_t min, uint64_t max);
robert.swiecki3bb518c2010-10-14 00:48:24 +000031
robert.swiecki@gmail.com89cc38c2015-02-23 02:52:08 +000032extern void util_rndBuf(uint8_t * buf, size_t sz);
33
robert.swiecki@gmail.com9e2d43d2015-02-16 12:17:39 +000034extern int util_ssnprintf(char *str, size_t size, const char *format, ...);
35
36extern int util_vssnprintf(char *str, size_t size, const char *format, va_list ap);
robert.swiecki@gmail.come7190b92015-02-14 23:05:42 +000037
robert.swiecki3bb518c2010-10-14 00:48:24 +000038extern void util_getLocalTime(const char *fmt, char *buf, size_t len);
39
robert.swieckiaac72e02010-12-13 19:49:15 +000040extern void util_nullifyStdio(void);
robert.swiecki3bb518c2010-10-14 00:48:24 +000041
42extern bool util_redirectStdin(char *inputFile);
43
robert.swieckiaac72e02010-12-13 19:49:15 +000044extern void util_recoverStdio(void);
robert.swiecki3bb518c2010-10-14 00:48:24 +000045
groebert@google.com1bd4c212013-06-19 11:13:56 +000046extern uint64_t util_hash(const char *buf, size_t len);
47
robert.swiecki@gmail.com3213a112015-03-12 01:42:02 +000048extern int64_t util_timeNowMillis(void);
49
robert.swiecki@gmail.com549ff182015-02-28 22:38:00 +000050extern uint16_t util_ToFromBE16(uint16_t val);
51extern uint16_t util_ToFromLE16(uint16_t val);
52extern uint32_t util_ToFromBE32(uint32_t val);
53extern uint32_t util_ToFromLE32(uint32_t val);
54
Jagger421aca82015-09-05 14:09:47 +020055extern void MX_LOCK(pthread_mutex_t * mutex);
56extern void MX_UNLOCK(pthread_mutex_t * mutex);
57
robert.swiecki3bb518c2010-10-14 00:48:24 +000058#endif