aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Paul2016-02-03 09:52:15 -0600
committerSean Paul2016-02-03 09:52:15 -0600
commit870942e56aac024da5e0a621275f6561a4ddab1b (patch)
treef50e065f5088a40e2a34ae83e2e3ff6ab2e6f625 /libdrm_macros.h
parentbd4d0d244019a72be9ca51ac3e8f35201b271f1b (diff)
parentb38a4b2326c1be5702f5cb73a53c0ed74c12d510 (diff)
downloadexternal-libdrm-870942e56aac024da5e0a621275f6561a4ddab1b.tar.gz
external-libdrm-870942e56aac024da5e0a621275f6561a4ddab1b.tar.xz
external-libdrm-870942e56aac024da5e0a621275f6561a4ddab1b.zip
Merge tag 'tags/libdrm-2.4.66' into master
Tag libdrm-2.4.66 from git://anongit.freedesktop.org/mesa/drm Signed-off-by: Sean Paul <seanpaul@chromium.org> Conflicts: Android.mk Makefile.am configure.ac freedreno/Android.mk include/drm/drm_mode.h intel/Android.mk libkms/Android.mk nouveau/Android.mk radeon/Android.mk tegra/tegra.c tests/Makefile.am xf86drmMode.c xf86drmMode.h Change-Id: I3186bde7f196d2f3438c4334591ee2a0c1371c96
Diffstat (limited to 'libdrm_macros.h')
-rw-r--r--libdrm_macros.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/libdrm_macros.h b/libdrm_macros.h
new file mode 100644
index 00000000..b88fdcef
--- /dev/null
+++ b/libdrm_macros.h
@@ -0,0 +1,85 @@
1/*
2 * Copyright © 2014 NVIDIA Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef LIBDRM_LIBDRM_H
24#define LIBDRM_LIBDRM_H
25
26#if defined(HAVE_VISIBILITY)
27# define drm_private __attribute__((visibility("hidden")))
28#else
29# define drm_private
30#endif
31
32
33/**
34 * Static (compile-time) assertion.
35 * Basically, use COND to dimension an array. If COND is false/zero the
36 * array size will be -1 and we'll get a compilation error.
37 */
38#define STATIC_ASSERT(COND) \
39 do { \
40 (void) sizeof(char [1 - 2*!(COND)]); \
41 } while (0)
42
43
44#include <sys/mman.h>
45
46#if defined(ANDROID) && !defined(__LP64__)
47#include <errno.h> /* for EINVAL */
48
49static inline void *drm_mmap(void *addr, size_t length, int prot, int flags,
50 int fd, loff_t offset)
51{
52 /* offset must be aligned to 4096 (not necessarily the page size) */
53 if (offset & 4095) {
54 errno = EINVAL;
55 return MAP_FAILED;
56 }
57
58 return mmap64(addr, length, prot, flags, fd, offset);
59}
60
61# define drm_munmap(addr, length) \
62 munmap(addr, length)
63
64
65#else
66
67/* assume large file support exists */
68# define drm_mmap(addr, length, prot, flags, fd, offset) \
69 mmap(addr, length, prot, flags, fd, offset)
70
71
72static inline int drm_munmap(void *addr, size_t length)
73{
74 /* Copied from configure code generated by AC_SYS_LARGEFILE */
75#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + \
76 (((off_t) 1 << 31) << 31))
77 STATIC_ASSERT(LARGE_OFF_T % 2147483629 == 721 &&
78 LARGE_OFF_T % 2147483647 == 1);
79#undef LARGE_OFF_T
80
81 return munmap(addr, length);
82}
83#endif
84
85#endif