1// Copyright 2016 The Fuchsia Authors
2// Copyright (c) 2008-2014 Travis Geiselbrecht
3//
4// Use of this source code is governed by a MIT-style
5// license that can be found in the LICENSE file or at
6// https://opensource.org/licenses/MIT
7
8#pragma once
9
10#include <zircon/compiler.h>
11#include <sys/types.h>
12#include <stddef.h>
13#include <malloc.h>
14#include <endian.h>
15#include <rand.h>
16#include <arch/defines.h>
17
18__BEGIN_CDECLS
19
20int atoi(const char *num);
21unsigned int atoui(const char *num);
22long atol(const char *num);
23unsigned long atoul(const char *num);
24unsigned long long atoull(const char *num);
25
26long strtol(const char *nptr, char **endptr, int base);
27long long strtoll(const char *nptr, char **endptr, int base);
28
29#define MIN(a, b) (((a) < (b)) ? (a) : (b))
30#define MAX(a, b) (((a) > (b)) ? (a) : (b))
31
32#define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1))
33#define ROUNDDOWN(a, b) ((a) & ~((b)-1))
34
35#define ALIGN(a, b) ROUNDUP(a, b)
36#define IS_ALIGNED(a, b) (!(((uintptr_t)(a)) & (((uintptr_t)(b))-1)))
37
38void abort(void) __attribute__((noreturn));
39void qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *));
40void *bsearch(const void *key, const void *base, size_t num_elems, size_t size,
41              int (*compare)(const void *, const void *));
42unsigned long int strtoul(const char *nptr, char **endptr, int base);
43char *getenv(const char *name);
44
45__END_CDECLS
46