LibGd
2.4.0-dev
GD Graphics library
Loading...
Searching...
No Matches
src
gdhelpers.h
1
#ifndef GDHELPERS_H
2
#define GDHELPERS_H 1
3
4
#ifdef __cplusplus
5
extern
"C"
{
6
#endif
7
8
/* sys/types.h is needed for size_t on Sparc-SunOS-4.1 */
9
#ifndef _WIN32_WCE
10
#include <sys/types.h>
11
#else
12
#include <stdlib.h>
13
#endif
/* _WIN32_WCE */
14
15
/* TBB: strtok_r is not universal; provide an implementation of it. */
16
17
char
*gd_strtok_r(
char
*s,
const
char
*sep,
char
**state);
18
19
/* These functions wrap memory management. gdFree is
20
in gd.h, where callers can utilize it to correctly
21
free memory allocated by these functions with the
22
right version of free(). */
23
void
*gdCalloc(
size_t
nmemb,
size_t
size) BGD_MALLOC;
24
void
*gdMalloc(
size_t
size) BGD_MALLOC;
25
void
*gdRealloc(
void
*ptr,
size_t
size);
26
/* The extended version of gdReallocEx will free *ptr if the
27
* realloc fails */
28
void
*gdReallocEx(
void
*ptr,
size_t
size);
29
30
/* Returns nonzero if multiplying the two quantities will
31
result in integer overflow. Also returns nonzero if
32
either quantity is negative. By Phil Knirsch based on
33
netpbm fixes by Alan Cox. */
34
35
int
overflow2(
int
a,
int
b);
36
int
overflowMul3(
int
a,
int
b,
int
c);
37
38
/* 2.0.16: portable mutex support for thread safety. */
39
#if defined(CPP_SHARP)
40
#define gdMutexDeclare(x)
41
#define gdMutexSetup(x)
42
#define gdMutexShutdown(x)
43
#define gdMutexLock(x)
44
#define gdMutexUnlock(x)
45
#elif defined(_WIN32)
46
/* 2.0.18: must include windows.h to get CRITICAL_SECTION. */
47
#include <windows.h>
48
#define gdMutexDeclare(x) CRITICAL_SECTION x
49
#define gdMutexSetup(x) InitializeCriticalSection(&x)
50
#define gdMutexShutdown(x) DeleteCriticalSection(&x)
51
#define gdMutexLock(x) EnterCriticalSection(&x)
52
#define gdMutexUnlock(x) LeaveCriticalSection(&x)
53
#elif defined(HAVE_PTHREAD)
54
#include <pthread.h>
55
#define gdMutexDeclare(x) pthread_mutex_t x
56
#define gdMutexSetup(x) pthread_mutex_init(&x, 0)
57
#define gdMutexShutdown(x) pthread_mutex_destroy(&x)
58
#define gdMutexLock(x) pthread_mutex_lock(&x)
59
#define gdMutexUnlock(x) pthread_mutex_unlock(&x)
60
#else
61
#define gdMutexDeclare(x)
62
#define gdMutexSetup(x)
63
#define gdMutexShutdown(x)
64
#define gdMutexLock(x)
65
#define gdMutexUnlock(x)
66
#endif
/* _WIN32 || HAVE_PTHREAD */
67
68
#define DPCM2DPI(dpcm) (unsigned int)((dpcm) * 2.54 + 0.5)
69
#define DPM2DPI(dpm) (unsigned int)((dpm) * 0.0254 + 0.5)
70
#define DPI2DPCM(dpi) (unsigned int)((dpi) / 2.54 + 0.5)
71
#define DPI2DPM(dpi) (unsigned int)((dpi) / 0.0254 + 0.5)
72
73
#ifdef __cplusplus
74
}
75
#endif
76
77
#endif
/* GDHELPERS_H */
Generated by
1.9.8