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 20 int atoi(const char *num); 21 unsigned int atoui(const char *num); 22 long atol(const char *num); 23 unsigned long atoul(const char *num); 24 unsigned long long atoull(const char *num); 25 26 long strtol(const char *nptr, char **endptr, int base); 27 long 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 38 void abort(void) __attribute__((noreturn)); 39 void qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *)); 40 void *bsearch(const void *key, const void *base, size_t num_elems, size_t size, 41 int (*compare)(const void *, const void *)); 42 unsigned long int strtoul(const char *nptr, char **endptr, int base); 43 char *getenv(const char *name); 44 45 __END_CDECLS 46