~ubuntu-branches/ubuntu/trusty/python3.4/trusty-proposed

« back to all changes in this revision

Viewing changes to Modules/_ctypes/libffi/include/ffi_common.h

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-11-25 09:44:27 UTC
  • Revision ID: package-import@ubuntu.com-20131125094427-lzxj8ap5w01lmo7f
Tags: upstream-3.4~b1
ImportĀ upstreamĀ versionĀ 3.4~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -----------------------------------------------------------------------
 
2
   ffi_common.h - Copyright (C) 2011, 2012  Anthony Green
 
3
                  Copyright (C) 2007  Free Software Foundation, Inc
 
4
                  Copyright (c) 1996  Red Hat, Inc.
 
5
                  
 
6
   Common internal definitions and macros. Only necessary for building
 
7
   libffi.
 
8
   ----------------------------------------------------------------------- */
 
9
 
 
10
#ifndef FFI_COMMON_H
 
11
#define FFI_COMMON_H
 
12
 
 
13
#ifdef __cplusplus
 
14
extern "C" {
 
15
#endif
 
16
 
 
17
#include <fficonfig.h>
 
18
 
 
19
/* Do not move this. Some versions of AIX are very picky about where
 
20
   this is positioned. */
 
21
#ifdef __GNUC__
 
22
/* mingw64 defines this already in malloc.h. */
 
23
#ifndef alloca
 
24
# define alloca __builtin_alloca
 
25
#endif
 
26
# define MAYBE_UNUSED __attribute__((__unused__))
 
27
#else
 
28
# define MAYBE_UNUSED
 
29
# if HAVE_ALLOCA_H
 
30
#  include <alloca.h>
 
31
# else
 
32
#  ifdef _AIX
 
33
 #pragma alloca
 
34
#  else
 
35
#   ifndef alloca /* predefined by HP cc +Olibcalls */
 
36
#    ifdef _MSC_VER
 
37
#     define alloca _alloca
 
38
#    else
 
39
char *alloca ();
 
40
#    endif
 
41
#   endif
 
42
#  endif
 
43
# endif
 
44
#endif
 
45
 
 
46
/* Check for the existence of memcpy. */
 
47
#if STDC_HEADERS
 
48
# include <string.h>
 
49
#else
 
50
# ifndef HAVE_MEMCPY
 
51
#  define memcpy(d, s, n) bcopy ((s), (d), (n))
 
52
# endif
 
53
#endif
 
54
 
 
55
#if defined(FFI_DEBUG)
 
56
#include <stdio.h>
 
57
#endif
 
58
 
 
59
#ifdef FFI_DEBUG
 
60
void ffi_assert(char *expr, char *file, int line);
 
61
void ffi_stop_here(void);
 
62
void ffi_type_test(ffi_type *a, char *file, int line);
 
63
 
 
64
#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
 
65
#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
 
66
#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
 
67
#else
 
68
#define FFI_ASSERT(x)
 
69
#define FFI_ASSERT_AT(x, f, l)
 
70
#define FFI_ASSERT_VALID_TYPE(x)
 
71
#endif
 
72
 
 
73
#define ALIGN(v, a)  (((((size_t) (v))-1) | ((a)-1))+1)
 
74
#define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)
 
75
 
 
76
/* Perform machine dependent cif processing */
 
77
ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
 
78
ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
 
79
         unsigned int nfixedargs, unsigned int ntotalargs);
 
80
 
 
81
/* Extended cif, used in callback from assembly routine */
 
82
typedef struct
 
83
{
 
84
  ffi_cif *cif;
 
85
  void *rvalue;
 
86
  void **avalue;
 
87
} extended_cif;
 
88
 
 
89
/* Terse sized type definitions.  */
 
90
#if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C)
 
91
typedef unsigned char UINT8;
 
92
typedef signed char   SINT8;
 
93
typedef unsigned short UINT16;
 
94
typedef signed short   SINT16;
 
95
typedef unsigned int UINT32;
 
96
typedef signed int   SINT32;
 
97
# ifdef _MSC_VER
 
98
typedef unsigned __int64 UINT64;
 
99
typedef signed __int64   SINT64;
 
100
# else
 
101
# include <inttypes.h>
 
102
typedef uint64_t UINT64;
 
103
typedef int64_t  SINT64;
 
104
# endif
 
105
#else
 
106
typedef unsigned int UINT8  __attribute__((__mode__(__QI__)));
 
107
typedef signed int   SINT8  __attribute__((__mode__(__QI__)));
 
108
typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
 
109
typedef signed int   SINT16 __attribute__((__mode__(__HI__)));
 
110
typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
 
111
typedef signed int   SINT32 __attribute__((__mode__(__SI__)));
 
112
typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
 
113
typedef signed int   SINT64 __attribute__((__mode__(__DI__)));
 
114
#endif
 
115
 
 
116
typedef float FLOAT32;
 
117
 
 
118
#ifndef __GNUC__
 
119
#define __builtin_expect(x, expected_value) (x)
 
120
#endif
 
121
#define LIKELY(x)    __builtin_expect(!!(x),1)
 
122
#define UNLIKELY(x)  __builtin_expect((x)!=0,0)
 
123
 
 
124
#ifdef __cplusplus
 
125
}
 
126
#endif
 
127
 
 
128
#endif