1// Copyright 2010 Google Inc. All Rights Reserved.
2//
3// Use of this source code is governed by a BSD-style license
4// that can be found in the COPYING file in the root of the source
5// tree. An additional intellectual property rights grant can be found
6// in the file PATENTS. All contributing project authors may
7// be found in the AUTHORS file in the root of the source tree.
8// -----------------------------------------------------------------------------
9//
10// Common types + memory wrappers
11//
12// Author: Skal (pascal.massimino@gmail.com)
13
14#ifndef WEBP_WEBP_TYPES_H_
15#define WEBP_WEBP_TYPES_H_
16
17#include <stddef.h> // for size_t
18
19#ifndef _MSC_VER
20#include <inttypes.h>
21#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
22 (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
23#define WEBP_INLINE inline
24#else
25#define WEBP_INLINE
26#endif
27#else
28typedef signed char int8_t;
29typedef unsigned char uint8_t;
30typedef signed short int16_t;
31typedef unsigned short uint16_t;
32typedef signed int int32_t;
33typedef unsigned int uint32_t;
34typedef unsigned long long int uint64_t;
35typedef long long int int64_t;
36#define WEBP_INLINE __forceinline
37#endif /* _MSC_VER */
38
39#ifndef WEBP_EXTERN
40// This explicitly marks library functions and allows for changing the
41// signature for e.g., Windows DLL builds.
42# if defined(__GNUC__) && __GNUC__ >= 4
43# define WEBP_EXTERN extern __attribute__ ((visibility ("default")))
44# else
45# if defined(_MSC_VER) && defined(WEBP_DLL)
46# define WEBP_EXTERN __declspec(dllexport)
47# else
48# define WEBP_EXTERN extern
49# endif
50# endif /* __GNUC__ >= 4 */
51#endif /* WEBP_EXTERN */
52
53// Macro to check ABI compatibility (same major revision number)
54#define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8))
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
60// Allocates 'size' bytes of memory. Returns NULL upon error. Memory
61// must be deallocated by calling WebPFree(). This function is made available
62// by the core 'libwebp' library.
63WEBP_EXTERN void* WebPMalloc(size_t size);
64
65// Releases memory returned by the WebPDecode*() functions (from decode.h).
66WEBP_EXTERN void WebPFree(void* ptr);
67
68#ifdef __cplusplus
69} // extern "C"
70#endif
71
72#endif // WEBP_WEBP_TYPES_H_
73