~ubuntu-branches/ubuntu/trusty/libsoxr/trusty

« back to all changes in this revision

Viewing changes to examples/examples-common.h

  • Committer: Package Import Robot
  • Author(s): Benjamin Drung
  • Date: 2013-01-19 13:59:15 UTC
  • Revision ID: package-import@ubuntu.com-20130119135915-ig85015j5zwtf0rp
Tags: upstream-0.1.0
ImportĀ upstreamĀ versionĀ 0.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* SoX Resampler Library      Copyright (c) 2007-13 robs@users.sourceforge.net
 
2
 * Licence for this file: LGPL v2.1                  See LICENCE for details. */
 
3
 
 
4
/* Common includes etc. for the examples.  */
 
5
 
 
6
#include <assert.h>
 
7
#include <errno.h>
 
8
#include <limits.h>
 
9
#include <math.h>
 
10
#include <stddef.h>
 
11
#include <stdio.h>
 
12
#include <stdlib.h>
 
13
#include <string.h>
 
14
 
 
15
#ifdef _WIN32
 
16
  /* Work-around for broken file-I/O on MS-Windows: */
 
17
  #include <io.h>
 
18
  #include <fcntl.h>
 
19
  #define USE_STD_STDIO _setmode(_fileno(stdout), _O_BINARY), \
 
20
                        _setmode(_fileno(stdin ), _O_BINARY);
 
21
  /* Sometimes missing, so ensure that it is defined: */
 
22
  #undef M_PI
 
23
  #define M_PI 3.14159265358979323846
 
24
#else
 
25
  #define USE_STD_STDIO
 
26
#endif
 
27
 
 
28
#undef int16_t
 
29
#define int16_t short
 
30
 
 
31
#undef int32_t
 
32
#if LONG_MAX > 2147483647L
 
33
  #define int32_t int
 
34
#elif LONG_MAX < 2147483647L
 
35
  #error this programme requires that 'long int' has at least 32-bits
 
36
#else
 
37
  #define int32_t long
 
38
#endif
 
39
 
 
40
#undef min
 
41
#undef max
 
42
#define min(x,y) ((x)<(y)?(x):(y))
 
43
#define max(x,y) ((x)>(y)?(x):(y))
 
44
 
 
45
#define AL(a) (sizeof(a)/sizeof((a)[0]))  /* Array Length */