· 9 years ago · Jun 21, 2017, 02:22 PM
1# 1 "<built-in>"
2# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
3
4/*!
5 ***************************************************************************
6 * \file rdopt.c
7 *
8 * \brief
9 * Rate-Distortion optimized mode decision
10 *
11 * \author
12 * - Heiko Schwarz <hschwarz@hhi.de>
13 * - Valeri George <george@hhi.de>
14 * - Lowell Winger <lwinger@lsil.com>
15 * - Alexis Michael Tourapis <alexismt@ieee.org>
16 * \date
17 * 12. April 2001
18 **************************************************************************
19 */
20
21#if 0 /* expanded by -frewrite-includes */
22#include <stdlib.h>
23#endif /* expanded by -frewrite-includes */
24# 19 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
25# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 1 3 4
26/*-
27 * Copyright (c) 1990, 1993
28 * The Regents of the University of California. All rights reserved.
29 *
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
32 * are met:
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. Neither the name of the University nor the names of its contributors
39 * may be used to endorse or promote products derived from this software
40 * without specific prior written permission.
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
43 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
46 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 * SUCH DAMAGE.
53 *
54 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
55 * $FreeBSD$
56 */
57
58#ifndef _STDLIB_H_
59#define _STDLIB_H_
60
61#if 0 /* expanded by -frewrite-includes */
62#include <sys/cdefs.h>
63#endif /* expanded by -frewrite-includes */
64# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
65# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 1 3 4
66/*-
67 * Copyright (c) 1991, 1993
68 * The Regents of the University of California. All rights reserved.
69 *
70 * This code is derived from software contributed to Berkeley by
71 * Berkeley Software Design, Inc.
72 *
73 * Redistribution and use in source and binary forms, with or without
74 * modification, are permitted provided that the following conditions
75 * are met:
76 * 1. Redistributions of source code must retain the above copyright
77 * notice, this list of conditions and the following disclaimer.
78 * 2. Redistributions in binary form must reproduce the above copyright
79 * notice, this list of conditions and the following disclaimer in the
80 * documentation and/or other materials provided with the distribution.
81 * 3. Neither the name of the University nor the names of its contributors
82 * may be used to endorse or promote products derived from this software
83 * without specific prior written permission.
84 *
85 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
86 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
87 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
88 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
89 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
90 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
91 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
92 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
93 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
94 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
95 * SUCH DAMAGE.
96 *
97 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
98 * $FreeBSD$
99 */
100
101#ifndef _SYS_CDEFS_H_
102#define _SYS_CDEFS_H_
103
104/*
105 * Testing against Clang-specific extensions.
106 */
107#ifndef __has_attribute
108#define __has_attribute(x) 0
109#endif
110# 45 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
111#ifndef __has_extension
112#define __has_extension __has_feature
113#endif
114# 48 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
115#ifndef __has_feature
116#define __has_feature(x) 0
117#endif
118# 51 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
119#ifndef __has_include
120#define __has_include(x) 0
121#endif
122# 54 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
123#ifndef __has_builtin
124#define __has_builtin(x) 0
125#endif
126# 57 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
127
128#if defined(__cplusplus)
129#define __BEGIN_DECLS extern "C" {
130#define __END_DECLS }
131#else
132# 62 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
133#define __BEGIN_DECLS
134#define __END_DECLS
135#endif
136# 65 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
137
138/*
139 * This code has been put in place to help reduce the addition of
140 * compiler specific defines in FreeBSD code. It helps to aid in
141 * having a compiler-agnostic source tree.
142 */
143
144#if defined(__GNUC__) || defined(__INTEL_COMPILER)
145
146#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
147#define __GNUCLIKE_ASM 3
148#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
149#else
150# 78 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
151#define __GNUCLIKE_ASM 2
152#endif
153# 80 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
154#define __GNUCLIKE___TYPEOF 1
155#define __GNUCLIKE___OFFSETOF 1
156#define __GNUCLIKE___SECTION 1
157
158#ifndef __INTEL_COMPILER
159#define __GNUCLIKE_CTOR_SECTION_HANDLING 1
160#endif
161# 87 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
162
163#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
164#if defined(__INTEL_COMPILER) && defined(__cplusplus) && \
165 __INTEL_COMPILER < 800
166#undef __GNUCLIKE_BUILTIN_CONSTANT_P
167#endif
168# 93 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
169
170#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
171#define __GNUCLIKE_BUILTIN_VARARGS 1
172#define __GNUCLIKE_BUILTIN_STDARG 1
173#define __GNUCLIKE_BUILTIN_VAALIST 1
174#endif
175# 99 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
176
177#if defined(__GNUC__)
178#define __GNUC_VA_LIST_COMPATIBILITY 1
179#endif
180# 103 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
181
182/*
183 * Compiler memory barriers, specific to gcc and clang.
184 */
185#if defined(__GNUC__)
186#define __compiler_membar() __asm __volatile(" " : : : "memory")
187#endif
188# 110 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
189
190#ifndef __INTEL_COMPILER
191#define __GNUCLIKE_BUILTIN_NEXT_ARG 1
192#define __GNUCLIKE_MATH_BUILTIN_RELOPS
193#endif
194# 115 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
195
196#define __GNUCLIKE_BUILTIN_MEMCPY 1
197
198/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
199#define __CC_SUPPORTS_INLINE 1
200#define __CC_SUPPORTS___INLINE 1
201#define __CC_SUPPORTS___INLINE__ 1
202
203#define __CC_SUPPORTS___FUNC__ 1
204#define __CC_SUPPORTS_WARNING 1
205
206#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
207
208#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
209
210#endif /* __GNUC__ || __INTEL_COMPILER */
211# 131 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
212
213/*
214 * Macro to test if we're using a specific version of gcc or later.
215 */
216#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
217#define __GNUC_PREREQ__(ma, mi) \
218 (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
219#else
220# 139 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
221#define __GNUC_PREREQ__(ma, mi) 0
222#endif
223# 141 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
224
225/*
226 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
227 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
228 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
229 * mode -- there must be no spaces between its arguments, and for nested
230 * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
231 * concatenate double-quoted strings produced by the __STRING macro, but
232 * this only works with ANSI C.
233 *
234 * __XSTRING is like __STRING, but it expands any macros in its argument
235 * first. It is only available with ANSI C.
236 */
237#if defined(__STDC__) || defined(__cplusplus)
238#define __P(protos) protos /* full-blown ANSI C */
239#define __CONCAT1(x,y) x ## y
240#define __CONCAT(x,y) __CONCAT1(x,y)
241#define __STRING(x) #x /* stringify without expanding x */
242#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
243
244#define __const const /* define reserved names to standard */
245#define __signed signed
246#define __volatile volatile
247#if defined(__cplusplus)
248#define __inline inline /* convert to C++ keyword */
249#else
250# 167 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
251#if !(defined(__CC_SUPPORTS___INLINE))
252#define __inline /* delete GCC keyword */
253#endif /* ! __CC_SUPPORTS___INLINE */
254# 170 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
255#endif /* !__cplusplus */
256# 171 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
257
258#else /* !(__STDC__ || __cplusplus) */
259# 173 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
260#define __P(protos) () /* traditional C preprocessor */
261#define __CONCAT(x,y) x/**/y
262#define __STRING(x) "x"
263
264#if !defined(__CC_SUPPORTS___INLINE)
265#define __const /* delete pseudo-ANSI C keywords */
266#define __inline
267#define __signed
268#define __volatile
269/*
270 * In non-ANSI C environments, new programs will want ANSI-only C keywords
271 * deleted from the program and old programs will want them left alone.
272 * When using a compiler other than gcc, programs using the ANSI C keywords
273 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
274 * When using "gcc -traditional", we assume that this is the intent; if
275 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
276 */
277#ifndef NO_ANSI_KEYWORDS
278#define const /* delete ANSI C keywords */
279#define inline
280#define signed
281#define volatile
282#endif /* !NO_ANSI_KEYWORDS */
283# 196 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
284#endif /* !__CC_SUPPORTS___INLINE */
285# 197 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
286#endif /* !(__STDC__ || __cplusplus) */
287# 198 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
288
289/*
290 * Compiler-dependent macros to help declare dead (non-returning) and
291 * pure (no side effects) functions, and unused variables. They are
292 * null except for versions of gcc that are known to support the features
293 * properly (old versions of gcc-2 supported the dead and pure features
294 * in a different (wrong) way). If we do not provide an implementation
295 * for a given compiler, let the compile fail if it is told to use
296 * a feature that we cannot live without.
297 */
298#ifdef lint
299#define __dead2
300#define __pure2
301#define __unused
302#define __packed
303#define __aligned(x)
304#define __alloc_align(x)
305#define __alloc_size(x)
306#define __section(x)
307#define __weak_symbol
308#else
309# 219 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
310#define __weak_symbol __attribute__((__weak__))
311#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
312#define __dead2
313#define __pure2
314#define __unused
315#endif
316# 225 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
317#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
318#define __dead2 __attribute__((__noreturn__))
319#define __pure2 __attribute__((__const__))
320#define __unused
321/* XXX Find out what to do for __packed, __aligned and __section */
322#endif
323# 231 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
324#if __GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER)
325#define __dead2 __attribute__((__noreturn__))
326#define __pure2 __attribute__((__const__))
327#define __unused __attribute__((__unused__))
328#define __used __attribute__((__used__))
329#define __packed __attribute__((__packed__))
330#define __aligned(x) __attribute__((__aligned__(x)))
331#define __section(x) __attribute__((__section__(x)))
332#endif
333# 240 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
334#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
335#define __alloc_size(x) __attribute__((__alloc_size__(x)))
336#else
337# 243 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
338#define __alloc_size(x)
339#endif
340# 245 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
341#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__)
342#define __alloc_align(x) __attribute__((__alloc_align__(x)))
343#else
344# 248 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
345#define __alloc_align(x)
346#endif
347# 250 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
348#endif /* lint */
349# 251 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
350
351#if !__GNUC_PREREQ__(2, 95)
352#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
353#endif
354# 255 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
355
356/*
357 * Keywords added in C11.
358 */
359
360#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
361
362#if !__has_extension(c_alignas)
363#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
364 __has_extension(cxx_alignas)
365#define _Alignas(x) alignas(x)
366#else
367# 267 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
368/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */
369#define _Alignas(x) __aligned(x)
370#endif
371# 270 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
372#endif
373# 271 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
374
375#if defined(__cplusplus) && __cplusplus >= 201103L
376#define _Alignof(x) alignof(x)
377#else
378# 275 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
379#define _Alignof(x) __alignof(x)
380#endif
381# 277 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
382
383#if !defined(__cplusplus) && !__has_extension(c_atomic) && \
384 !__has_extension(cxx_atomic)
385/*
386 * No native support for _Atomic(). Place object in structure to prevent
387 * most forms of direct non-atomic access.
388 */
389#define _Atomic(T) struct { T volatile __val; }
390#endif
391# 286 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
392
393#if defined(__cplusplus) && __cplusplus >= 201103L
394#define _Noreturn [[noreturn]]
395#else
396# 290 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
397#define _Noreturn __dead2
398#endif
399# 292 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
400
401#if !__has_extension(c_static_assert)
402#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
403 __has_extension(cxx_static_assert)
404#define _Static_assert(x, y) static_assert(x, y)
405#elif __GNUC_PREREQ__(4,6)
406# 298 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
407/* Nothing, gcc 4.6 and higher has _Static_assert built-in */
408#elif defined(__COUNTER__)
409# 300 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
410#define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
411#define __Static_assert(x, y) ___Static_assert(x, y)
412#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \
413 __unused
414#else
415# 305 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
416#define _Static_assert(x, y) struct __hack
417#endif
418# 307 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
419#endif
420# 308 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
421
422#if !__has_extension(c_thread_local)
423/*
424 * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
425 * without actually supporting the thread_local keyword. Don't check for
426 * the presence of C++11 when defining _Thread_local.
427 */
428#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
429 __has_extension(cxx_thread_local)
430#define _Thread_local thread_local
431#else
432# 319 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
433#define _Thread_local __thread
434#endif
435# 321 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
436#endif
437# 322 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
438
439#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
440# 324 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
441
442/*
443 * Emulation of C11 _Generic(). Unlike the previously defined C11
444 * keywords, it is not possible to implement this using exactly the same
445 * syntax. Therefore implement something similar under the name
446 * __generic(). Unlike _Generic(), this macro can only distinguish
447 * between a single type, so it requires nested invocations to
448 * distinguish multiple cases.
449 */
450
451#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
452 __has_extension(c_generic_selections)
453#define __generic(expr, t, yes, no) \
454 _Generic(expr, t: yes, default: no)
455#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
456# 339 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
457#define __generic(expr, t, yes, no) \
458 __builtin_choose_expr( \
459 __builtin_types_compatible_p(__typeof(expr), t), yes, no)
460#endif
461# 343 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
462
463/*
464 * C99 Static array indices in function parameter declarations. Syntax such as:
465 * void bar(int myArray[static 10]);
466 * is allowed in C99 but not in C++. Define __min_size appropriately so
467 * headers using it can be compiled in either language. Use like this:
468 * void bar(int myArray[__min_size(10)]);
469 */
470#if !defined(__cplusplus) && \
471 (defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \
472 (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901))
473#define __min_size(x) static (x)
474#else
475# 356 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
476#define __min_size(x) (x)
477#endif
478# 358 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
479
480#if __GNUC_PREREQ__(2, 96)
481#define __malloc_like __attribute__((__malloc__))
482#define __pure __attribute__((__pure__))
483#else
484# 363 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
485#define __malloc_like
486#define __pure
487#endif
488# 366 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
489
490#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
491#define __always_inline __attribute__((__always_inline__))
492#else
493# 370 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
494#define __always_inline
495#endif
496# 372 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
497
498#if __GNUC_PREREQ__(3, 1)
499#define __noinline __attribute__ ((__noinline__))
500#else
501# 376 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
502#define __noinline
503#endif
504# 378 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
505
506#if __GNUC_PREREQ__(3, 4)
507#define __fastcall __attribute__((__fastcall__))
508#define __result_use_check __attribute__((__warn_unused_result__))
509#else
510# 383 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
511#define __fastcall
512#define __result_use_check
513#endif
514# 386 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
515
516#if __GNUC_PREREQ__(4, 1)
517#define __returns_twice __attribute__((__returns_twice__))
518#else
519# 390 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
520#define __returns_twice
521#endif
522# 392 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
523
524#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable)
525#define __unreachable() __builtin_unreachable()
526#else
527# 396 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
528#define __unreachable() ((void)0)
529#endif
530# 398 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
531
532/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
533#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
534#define __func__ NULL
535#endif
536# 403 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
537
538#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
539#define __LONG_LONG_SUPPORTED
540#endif
541# 407 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
542
543/* C++11 exposes a load of C99 stuff */
544#if defined(__cplusplus) && __cplusplus >= 201103L
545#define __LONG_LONG_SUPPORTED
546#ifndef __STDC_LIMIT_MACROS
547#define __STDC_LIMIT_MACROS
548#endif
549# 414 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
550#ifndef __STDC_CONSTANT_MACROS
551#define __STDC_CONSTANT_MACROS
552#endif
553# 417 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
554#endif
555# 418 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
556
557/*
558 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
559 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
560 * a way to define the `restrict' type qualifier without disturbing older
561 * software that is unaware of C99 keywords.
562 */
563#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
564#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
565#define __restrict
566#else
567# 429 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
568#define __restrict restrict
569#endif
570# 431 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
571#endif
572# 432 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
573
574/*
575 * GNU C version 2.96 adds explicit branch prediction so that
576 * the CPU back-end can hint the processor and also so that
577 * code blocks can be reordered such that the predicted path
578 * sees a more linear flow, thus improving cache behavior, etc.
579 *
580 * The following two macros provide us with a way to utilize this
581 * compiler feature. Use __predict_true() if you expect the expression
582 * to evaluate to true, and __predict_false() if you expect the
583 * expression to evaluate to false.
584 *
585 * A few notes about usage:
586 *
587 * * Generally, __predict_false() error condition checks (unless
588 * you have some _strong_ reason to do otherwise, in which case
589 * document it), and/or __predict_true() `no-error' condition
590 * checks, assuming you want to optimize for the no-error case.
591 *
592 * * Other than that, if you don't know the likelihood of a test
593 * succeeding from empirical or other `hard' evidence, don't
594 * make predictions.
595 *
596 * * These are meant to be used in places that are run `a lot'.
597 * It is wasteful to make predictions in code that is run
598 * seldomly (e.g. at subsystem initialization time) as the
599 * basic block reordering that this affects can often generate
600 * larger code.
601 */
602#if __GNUC_PREREQ__(2, 96)
603#define __predict_true(exp) __builtin_expect((exp), 1)
604#define __predict_false(exp) __builtin_expect((exp), 0)
605#else
606# 465 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
607#define __predict_true(exp) (exp)
608#define __predict_false(exp) (exp)
609#endif
610# 468 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
611
612#if __GNUC_PREREQ__(4, 0)
613#define __null_sentinel __attribute__((__sentinel__))
614#define __exported __attribute__((__visibility__("default")))
615#define __hidden __attribute__((__visibility__("hidden")))
616#else
617# 474 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
618#define __null_sentinel
619#define __exported
620#define __hidden
621#endif
622# 478 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
623
624/*
625 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
626 * require it.
627 */
628#if __GNUC_PREREQ__(4, 1)
629#define __offsetof(type, field) __builtin_offsetof(type, field)
630#else
631# 486 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
632#ifndef __cplusplus
633#define __offsetof(type, field) \
634 ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
635#else
636# 490 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
637#define __offsetof(type, field) \
638 (__offsetof__ (reinterpret_cast <__size_t> \
639 (&reinterpret_cast <const volatile char &> \
640 (static_cast<type *> (0)->field))))
641#endif
642# 495 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
643#endif
644# 496 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
645#define __rangeof(type, start, end) \
646 (__offsetof(type, end) - __offsetof(type, start))
647
648/*
649 * Given the pointer x to the member m of the struct s, return
650 * a pointer to the containing structure. When using GCC, we first
651 * assign pointer x to a local variable, to check that its type is
652 * compatible with member m.
653 */
654#if __GNUC_PREREQ__(3, 1)
655#define __containerof(x, s, m) ({ \
656 const volatile __typeof(((s *)0)->m) *__x = (x); \
657 __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
658})
659#else
660# 511 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
661#define __containerof(x, s, m) \
662 __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
663#endif
664# 514 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
665
666/*
667 * Compiler-dependent macros to declare that functions take printf-like
668 * or scanf-like arguments. They are null except for versions of gcc
669 * that are known to support the features properly (old versions of gcc-2
670 * didn't permit keeping the keywords out of the application namespace).
671 */
672#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
673#define __printflike(fmtarg, firstvararg)
674#define __scanflike(fmtarg, firstvararg)
675#define __format_arg(fmtarg)
676#define __strfmonlike(fmtarg, firstvararg)
677#define __strftimelike(fmtarg, firstvararg)
678#else
679# 528 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
680#define __printflike(fmtarg, firstvararg) \
681 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
682#define __scanflike(fmtarg, firstvararg) \
683 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
684#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
685#define __strfmonlike(fmtarg, firstvararg) \
686 __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
687#define __strftimelike(fmtarg, firstvararg) \
688 __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
689#endif
690# 538 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
691
692/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
693#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
694 defined(__GNUC__) && !defined(__INTEL_COMPILER)
695#define __printf0like(fmtarg, firstvararg) \
696 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
697#else
698# 545 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
699#define __printf0like(fmtarg, firstvararg)
700#endif
701# 547 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
702
703#if defined(__GNUC__) || defined(__INTEL_COMPILER)
704#ifndef __INTEL_COMPILER
705#define __strong_reference(sym,aliassym) \
706 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
707#endif
708# 553 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
709#ifdef __STDC__
710#define __weak_reference(sym,alias) \
711 __asm__(".weak " #alias); \
712 __asm__(".equ " #alias ", " #sym)
713#define __warn_references(sym,msg) \
714 __asm__(".section .gnu.warning." #sym); \
715 __asm__(".asciz \"" msg "\""); \
716 __asm__(".previous")
717#define __sym_compat(sym,impl,verid) \
718 __asm__(".symver " #impl ", " #sym "@" #verid)
719#define __sym_default(sym,impl,verid) \
720 __asm__(".symver " #impl ", " #sym "@@" #verid)
721#else
722# 566 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
723#define __weak_reference(sym,alias) \
724 __asm__(".weak alias"); \
725 __asm__(".equ alias, sym")
726#define __warn_references(sym,msg) \
727 __asm__(".section .gnu.warning.sym"); \
728 __asm__(".asciz \"msg\""); \
729 __asm__(".previous")
730#define __sym_compat(sym,impl,verid) \
731 __asm__(".symver impl, sym@verid")
732#define __sym_default(impl,sym,verid) \
733 __asm__(".symver impl, sym@@verid")
734#endif /* __STDC__ */
735# 578 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
736#endif /* __GNUC__ || __INTEL_COMPILER */
737# 579 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
738
739#define __GLOBL1(sym) __asm__(".globl " #sym)
740#define __GLOBL(sym) __GLOBL1(sym)
741
742#if defined(__GNUC__) || defined(__INTEL_COMPILER)
743#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
744#else
745# 586 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
746/*
747 * The following definition might not work well if used in header files,
748 * but it should be better than nothing. If you want a "do nothing"
749 * version, then it should generate some harmless declaration, such as:
750 * #define __IDSTRING(name,string) struct __hack
751 */
752#define __IDSTRING(name,string) static const char name[] __unused = string
753#endif
754# 594 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
755
756/*
757 * Embed the rcs id of a source file in the resulting library. Note that in
758 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
759 * Usage:
760 * __FBSDID("$FreeBSD$");
761 */
762#ifndef __FBSDID
763#if !defined(lint) && !defined(STRIP_FBSDID)
764#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
765#else
766# 605 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
767#define __FBSDID(s) struct __hack
768#endif
769# 607 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
770#endif
771# 608 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
772
773#ifndef __RCSID
774#ifndef NO__RCSID
775#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
776#else
777# 613 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
778#define __RCSID(s) struct __hack
779#endif
780# 615 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
781#endif
782# 616 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
783
784#ifndef __RCSID_SOURCE
785#ifndef NO__RCSID_SOURCE
786#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
787#else
788# 621 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
789#define __RCSID_SOURCE(s) struct __hack
790#endif
791# 623 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
792#endif
793# 624 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
794
795#ifndef __SCCSID
796#ifndef NO__SCCSID
797#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
798#else
799# 629 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
800#define __SCCSID(s) struct __hack
801#endif
802# 631 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
803#endif
804# 632 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
805
806#ifndef __COPYRIGHT
807#ifndef NO__COPYRIGHT
808#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
809#else
810# 637 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
811#define __COPYRIGHT(s) struct __hack
812#endif
813# 639 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
814#endif
815# 640 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
816
817#ifndef __DECONST
818#if !__has_feature(capabilities)
819#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
820#else
821# 645 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
822#define __DECONST(type, var) ((type)(__intcap_t)(__capability const void *)(var))
823#endif
824# 647 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
825#endif
826# 648 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
827
828#ifndef __DEVOLATILE
829#if !__has_feature(capabilities)
830#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
831#else
832# 653 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
833#define __DEVOLATILE(type, var) ((type)(__intcap_t)(__capability volatile void *)(var))
834#endif
835# 655 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
836#endif
837# 656 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
838
839#ifndef __DEQUALIFY
840#if !__has_feature(capabilities)
841#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
842#else
843# 661 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
844#define __DEQUALIFY(type, var) ((type)(__intcap_t)(__capability const volatile void *)(var))
845#endif
846# 663 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
847#endif
848# 664 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
849
850/*-
851 * The following definitions are an extension of the behavior originally
852 * implemented in <sys/_posix.h>, but with a different level of granularity.
853 * POSIX.1 requires that the macros we test be defined before any standard
854 * header file is included.
855 *
856 * Here's a quick run-down of the versions:
857 * defined(_POSIX_SOURCE) 1003.1-1988
858 * _POSIX_C_SOURCE == 1 1003.1-1990
859 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
860 * _POSIX_C_SOURCE == 199309 1003.1b-1993
861 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
862 * and the omnibus ISO/IEC 9945-1: 1996
863 * _POSIX_C_SOURCE == 200112 1003.1-2001
864 * _POSIX_C_SOURCE == 200809 1003.1-2008
865 *
866 * In addition, the X/Open Portability Guide, which is now the Single UNIX
867 * Specification, defines a feature-test macro which indicates the version of
868 * that specification, and which subsumes _POSIX_C_SOURCE.
869 *
870 * Our macros begin with two underscores to avoid namespace screwage.
871 */
872
873/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
874#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
875#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
876#define _POSIX_C_SOURCE 199009
877#endif
878# 693 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
879
880/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
881#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
882#undef _POSIX_C_SOURCE
883#define _POSIX_C_SOURCE 199209
884#endif
885# 699 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
886
887/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
888#ifdef _XOPEN_SOURCE
889#if _XOPEN_SOURCE - 0 >= 700
890#define __XSI_VISIBLE 700
891#undef _POSIX_C_SOURCE
892#define _POSIX_C_SOURCE 200809
893#elif _XOPEN_SOURCE - 0 >= 600
894# 707 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
895#define __XSI_VISIBLE 600
896#undef _POSIX_C_SOURCE
897#define _POSIX_C_SOURCE 200112
898#elif _XOPEN_SOURCE - 0 >= 500
899# 711 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
900#define __XSI_VISIBLE 500
901#undef _POSIX_C_SOURCE
902#define _POSIX_C_SOURCE 199506
903#endif
904# 715 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
905#endif
906# 716 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
907
908/*
909 * Deal with all versions of POSIX. The ordering relative to the tests above is
910 * important.
911 */
912#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
913#define _POSIX_C_SOURCE 198808
914#endif
915# 724 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
916#ifdef _POSIX_C_SOURCE
917#if _POSIX_C_SOURCE >= 200809
918#define __POSIX_VISIBLE 200809
919#define __ISO_C_VISIBLE 1999
920#elif _POSIX_C_SOURCE >= 200112
921# 729 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
922#define __POSIX_VISIBLE 200112
923#define __ISO_C_VISIBLE 1999
924#elif _POSIX_C_SOURCE >= 199506
925# 732 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
926#define __POSIX_VISIBLE 199506
927#define __ISO_C_VISIBLE 1990
928#elif _POSIX_C_SOURCE >= 199309
929# 735 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
930#define __POSIX_VISIBLE 199309
931#define __ISO_C_VISIBLE 1990
932#elif _POSIX_C_SOURCE >= 199209
933# 738 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
934#define __POSIX_VISIBLE 199209
935#define __ISO_C_VISIBLE 1990
936#elif _POSIX_C_SOURCE >= 199009
937# 741 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
938#define __POSIX_VISIBLE 199009
939#define __ISO_C_VISIBLE 1990
940#else
941# 744 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
942#define __POSIX_VISIBLE 198808
943#define __ISO_C_VISIBLE 0
944#endif /* _POSIX_C_SOURCE */
945# 747 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
946#else
947# 748 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
948/*-
949 * Deal with _ANSI_SOURCE:
950 * If it is defined, and no other compilation environment is explicitly
951 * requested, then define our internal feature-test macros to zero. This
952 * makes no difference to the preprocessor (undefined symbols in preprocessing
953 * expressions are defined to have value zero), but makes it more convenient for
954 * a test program to print out the values.
955 *
956 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
957 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
958 * environment (and in fact we will never get here).
959 */
960#if defined(_ANSI_SOURCE) /* Hide almost everything. */
961#define __POSIX_VISIBLE 0
962#define __XSI_VISIBLE 0
963#define __BSD_VISIBLE 0
964#define __ISO_C_VISIBLE 1990
965#define __EXT1_VISIBLE 0
966#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
967# 767 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
968#define __POSIX_VISIBLE 0
969#define __XSI_VISIBLE 0
970#define __BSD_VISIBLE 0
971#define __ISO_C_VISIBLE 1999
972#define __EXT1_VISIBLE 0
973#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */
974# 773 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
975#define __POSIX_VISIBLE 0
976#define __XSI_VISIBLE 0
977#define __BSD_VISIBLE 0
978#define __ISO_C_VISIBLE 2011
979#define __EXT1_VISIBLE 0
980#else /* Default environment: show everything. */
981# 779 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
982#define __POSIX_VISIBLE 200809
983#define __XSI_VISIBLE 700
984#define __BSD_VISIBLE 1
985#define __ISO_C_VISIBLE 2011
986#define __EXT1_VISIBLE 1
987#endif
988# 785 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
989#endif
990# 786 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
991
992/* User override __EXT1_VISIBLE */
993#if defined(__STDC_WANT_LIB_EXT1__)
994#undef __EXT1_VISIBLE
995#if __STDC_WANT_LIB_EXT1__
996#define __EXT1_VISIBLE 1
997#else
998# 793 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
999#define __EXT1_VISIBLE 0
1000#endif
1001# 795 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1002#endif /* __STDC_WANT_LIB_EXT1__ */
1003# 796 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1004
1005#if defined(__mips) || defined(__powerpc64__) || defined(__riscv__)
1006#define __NO_TLS 1
1007#endif
1008# 800 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1009
1010/*
1011 * Old versions of GCC use non-standard ARM arch symbols; acle-compat.h
1012 * translates them to __ARM_ARCH and the modern feature symbols defined by ARM.
1013 */
1014#if defined(__arm__) && !defined(__ARM_ARCH)
1015#if 0 /* expanded by -frewrite-includes */
1016#include <machine/acle-compat.h>
1017#endif /* expanded by -frewrite-includes */
1018# 806 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1019# 807 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1020#endif
1021# 808 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1022
1023/*
1024 * Nullability qualifiers: currently only supported by Clang.
1025 */
1026#if !(defined(__clang__) && __has_feature(nullability))
1027#define _Nonnull
1028#define _Nullable
1029#define _Null_unspecified
1030#define __NULLABILITY_PRAGMA_PUSH
1031#define __NULLABILITY_PRAGMA_POP
1032#else
1033# 819 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1034#define __NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push") \
1035 _Pragma("clang diagnostic ignored \"-Wnullability-completeness\"")
1036#define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop")
1037#endif
1038# 823 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1039
1040/*
1041 * Type Safety Checking
1042 *
1043 * Clang provides additional attributes to enable checking type safety
1044 * properties that cannot be enforced by the C type system.
1045 */
1046
1047#if __has_attribute(__argument_with_type_tag__) && \
1048 __has_attribute(__type_tag_for_datatype__) && !defined(lint)
1049#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
1050 __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
1051#define __datatype_type_tag(kind, type) \
1052 __attribute__((__type_tag_for_datatype__(kind, type)))
1053#else
1054# 838 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1055#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx)
1056#define __datatype_type_tag(kind, type)
1057#endif
1058# 841 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1059
1060/*
1061 * Lock annotations.
1062 *
1063 * Clang provides support for doing basic thread-safety tests at
1064 * compile-time, by marking which locks will/should be held when
1065 * entering/leaving a functions.
1066 *
1067 * Furthermore, it is also possible to annotate variables and structure
1068 * members to enforce that they are only accessed when certain locks are
1069 * held.
1070 */
1071
1072#if __has_extension(c_thread_safety_attributes)
1073#define __lock_annotate(x) __attribute__((x))
1074#else
1075# 857 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1076#define __lock_annotate(x)
1077#endif
1078# 859 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1079
1080/* Structure implements a lock. */
1081#define __lockable __lock_annotate(lockable)
1082
1083/* Function acquires an exclusive or shared lock. */
1084#define __locks_exclusive(...) \
1085 __lock_annotate(exclusive_lock_function(__VA_ARGS__))
1086#define __locks_shared(...) \
1087 __lock_annotate(shared_lock_function(__VA_ARGS__))
1088
1089/* Function attempts to acquire an exclusive or shared lock. */
1090#define __trylocks_exclusive(...) \
1091 __lock_annotate(exclusive_trylock_function(__VA_ARGS__))
1092#define __trylocks_shared(...) \
1093 __lock_annotate(shared_trylock_function(__VA_ARGS__))
1094
1095/* Function releases a lock. */
1096#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
1097
1098/* Function asserts that an exclusive or shared lock is held. */
1099#define __asserts_exclusive(...) \
1100 __lock_annotate(assert_exclusive_lock(__VA_ARGS__))
1101#define __asserts_shared(...) \
1102 __lock_annotate(assert_shared_lock(__VA_ARGS__))
1103
1104/* Function requires that an exclusive or shared lock is or is not held. */
1105#define __requires_exclusive(...) \
1106 __lock_annotate(exclusive_locks_required(__VA_ARGS__))
1107#define __requires_shared(...) \
1108 __lock_annotate(shared_locks_required(__VA_ARGS__))
1109#define __requires_unlocked(...) \
1110 __lock_annotate(locks_excluded(__VA_ARGS__))
1111
1112/* Function should not be analyzed. */
1113#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
1114
1115/* Guard variables and structure members by lock. */
1116#define __guarded_by(x) __lock_annotate(guarded_by(x))
1117#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
1118
1119/* Specify that a file requires capabilities */
1120#if __has_feature(capabilities)
1121#define __REQUIRE_CAPABILITIES
1122#else
1123# 903 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1124#define __REQUIRE_CAPABILITIES \
1125 _Pragma("GCC error \"This file requires a capability-aware compiler\"")
1126#endif
1127# 906 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1128
1129#endif /* !_SYS_CDEFS_H_ */
1130# 908 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/cdefs.h" 3 4
1131# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 2 3 4
1132#if 0 /* expanded by -frewrite-includes */
1133#include <sys/_null.h>
1134#endif /* expanded by -frewrite-includes */
1135# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1136# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_null.h" 1 3 4
1137/*-
1138 * Copyright (c) 2003 Marcel Moolenaar
1139 * All rights reserved.
1140 *
1141 * Redistribution and use in source and binary forms, with or without
1142 * modification, are permitted provided that the following conditions
1143 * are met:
1144 *
1145 * 1. Redistributions of source code must retain the above copyright
1146 * notice, this list of conditions and the following disclaimer.
1147 * 2. Redistributions in binary form must reproduce the above copyright
1148 * notice, this list of conditions and the following disclaimer in the
1149 * documentation and/or other materials provided with the distribution.
1150 *
1151 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1152 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1153 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1154 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1155 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1156 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1157 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1158 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1159 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1160 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1161 *
1162 * $FreeBSD$
1163 */
1164
1165#ifndef NULL
1166
1167#if !defined(__cplusplus)
1168#define NULL ((void *)0)
1169#else
1170# 34 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_null.h" 3 4
1171#if __cplusplus >= 201103L
1172#define NULL nullptr
1173#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
1174# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_null.h" 3 4
1175#define NULL __null
1176#else
1177# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_null.h" 3 4
1178#if defined(__LP64__)
1179#define NULL (0L)
1180#else
1181# 42 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_null.h" 3 4
1182#define NULL 0
1183#endif /* __LP64__ */
1184# 44 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_null.h" 3 4
1185#endif /* __GNUG__ */
1186# 45 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_null.h" 3 4
1187#endif /* !__cplusplus */
1188# 46 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_null.h" 3 4
1189
1190#endif
1191# 48 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_null.h" 3 4
1192# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 2 3 4
1193#if 0 /* expanded by -frewrite-includes */
1194#include <sys/_types.h>
1195#endif /* expanded by -frewrite-includes */
1196# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1197# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_types.h" 1 3 4
1198/*-
1199 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
1200 * All rights reserved.
1201 *
1202 * Redistribution and use in source and binary forms, with or without
1203 * modification, are permitted provided that the following conditions
1204 * are met:
1205 * 1. Redistributions of source code must retain the above copyright
1206 * notice, this list of conditions and the following disclaimer.
1207 * 2. Redistributions in binary form must reproduce the above copyright
1208 * notice, this list of conditions and the following disclaimer in the
1209 * documentation and/or other materials provided with the distribution.
1210 *
1211 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1212 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1213 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1214 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1215 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1216 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1217 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1218 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1219 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1220 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1221 * SUCH DAMAGE.
1222 *
1223 * $FreeBSD$
1224 */
1225
1226#ifndef _SYS__TYPES_H_
1227#define _SYS__TYPES_H_
1228
1229#if 0 /* expanded by -frewrite-includes */
1230#include <sys/cdefs.h>
1231#endif /* expanded by -frewrite-includes */
1232# 32 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_types.h" 3 4
1233# 33 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_types.h" 3 4
1234#if 0 /* expanded by -frewrite-includes */
1235#include <machine/_types.h>
1236#endif /* expanded by -frewrite-includes */
1237# 33 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_types.h" 3 4
1238# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 1 3 4
1239/*-
1240 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
1241 * Copyright (c) 1990, 1993
1242 * The Regents of the University of California. All rights reserved.
1243 *
1244 * Redistribution and use in source and binary forms, with or without
1245 * modification, are permitted provided that the following conditions
1246 * are met:
1247 * 1. Redistributions of source code must retain the above copyright
1248 * notice, this list of conditions and the following disclaimer.
1249 * 2. Redistributions in binary form must reproduce the above copyright
1250 * notice, this list of conditions and the following disclaimer in the
1251 * documentation and/or other materials provided with the distribution.
1252 * 3. All advertising materials mentioning features or use of this software
1253 * must display the following acknowledgement:
1254 * This product includes software developed by the University of
1255 * California, Berkeley and its contributors.
1256 * 4. Neither the name of the University nor the names of its contributors
1257 * may be used to endorse or promote products derived from this software
1258 * without specific prior written permission.
1259 *
1260 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1261 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1262 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1263 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1264 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1265 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1266 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1267 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1268 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1269 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1270 * SUCH DAMAGE.
1271 *
1272 * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
1273 * From: @(#)types.h 8.3 (Berkeley) 1/5/94
1274 * from: src/sys/i386/include/_types.h,v 1.12 2005/07/02 23:13:31 thompsa
1275 * $FreeBSD$
1276 */
1277
1278#ifndef _MACHINE__TYPES_H_
1279#define _MACHINE__TYPES_H_
1280
1281#ifndef _SYS_CDEFS_H_
1282#error this file needs sys/cdefs.h as a prerequisite
1283#endif
1284# 46 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1285
1286/*
1287 * Basic types upon which most other types are built.
1288 */
1289typedef signed char __int8_t;
1290typedef unsigned char __uint8_t;
1291typedef short __int16_t;
1292typedef unsigned short __uint16_t;
1293typedef int __int32_t;
1294typedef unsigned int __uint32_t;
1295#ifdef __mips_n64
1296typedef long __int64_t;
1297typedef unsigned long __uint64_t;
1298#else
1299# 60 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1300#ifndef lint
1301__extension__
1302#endif
1303# 63 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1304/* LONGLONG */
1305typedef long long __int64_t;
1306#ifndef lint
1307__extension__
1308#endif
1309# 68 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1310/* LONGLONG */
1311typedef unsigned long long __uint64_t;
1312#endif
1313# 71 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1314
1315/*
1316 * Standard type definitions.
1317 */
1318typedef __int32_t __clock_t; /* clock()... */
1319typedef double __double_t;
1320typedef float __float_t;
1321#ifdef __mips_n64
1322#ifndef __CHERI_PURE_CAPABILITY__
1323typedef __int64_t __critical_t;
1324typedef __int64_t __intfptr_t;
1325typedef __int64_t __intptr_t;
1326#else
1327# 84 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1328typedef __intcap_t __critical_t;
1329typedef __intcap_t __intfptr_t;
1330typedef __intcap_t __intptr_t;
1331#endif
1332# 88 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1333#else
1334# 89 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1335typedef __int32_t __critical_t;
1336typedef __int32_t __intfptr_t;
1337typedef __int32_t __intptr_t;
1338#endif
1339# 93 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1340typedef __int64_t __intmax_t;
1341typedef __int32_t __int_fast8_t;
1342typedef __int32_t __int_fast16_t;
1343typedef __int32_t __int_fast32_t;
1344typedef __int64_t __int_fast64_t;
1345typedef __int8_t __int_least8_t;
1346typedef __int16_t __int_least16_t;
1347typedef __int32_t __int_least32_t;
1348typedef __int64_t __int_least64_t;
1349#if defined(__mips_n64) || defined(__mips_n32)
1350typedef __int64_t __register_t;
1351typedef __int64_t f_register_t;
1352#else
1353# 106 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1354typedef __int32_t __register_t;
1355typedef __int32_t f_register_t;
1356#endif
1357# 109 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1358#ifdef __mips_n64
1359typedef __int64_t __ptrdiff_t;
1360typedef __int64_t __segsz_t;
1361typedef __uint64_t __size_t;
1362typedef __int64_t __ssize_t;
1363#ifndef __CHERI_PURE_CAPABILITY__
1364typedef __uint64_t __uintfptr_t;
1365typedef __uint64_t __uintptr_t;
1366#else
1367# 118 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1368typedef __uintcap_t __uintfptr_t;
1369typedef __uintcap_t __uintptr_t;
1370#endif
1371# 121 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1372#else
1373# 122 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1374typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
1375typedef __int32_t __segsz_t; /* segment size (in pages) */
1376typedef __uint32_t __size_t; /* sizeof() */
1377typedef __int32_t __ssize_t; /* byte count or error */
1378typedef __uint32_t __uintfptr_t;
1379typedef __uint32_t __uintptr_t;
1380#endif
1381# 129 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1382typedef __int64_t __time_t; /* time()... */
1383typedef __uint64_t __uintmax_t;
1384typedef __uint32_t __uint_fast8_t;
1385typedef __uint32_t __uint_fast16_t;
1386typedef __uint32_t __uint_fast32_t;
1387typedef __uint64_t __uint_fast64_t;
1388typedef __uint8_t __uint_least8_t;
1389typedef __uint16_t __uint_least16_t;
1390typedef __uint32_t __uint_least32_t;
1391typedef __uint64_t __uint_least64_t;
1392#if defined(__mips_n64) || defined(__mips_n32)
1393typedef __uint64_t __u_register_t;
1394#else
1395# 142 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1396typedef __uint32_t __u_register_t;
1397#endif
1398# 144 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1399#ifdef __mips_n64
1400typedef __uint64_t __vm_offset_t;
1401typedef __uint64_t __vm_size_t;
1402#else
1403# 148 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1404typedef __uint32_t __vm_offset_t;
1405typedef __uint32_t __vm_size_t;
1406#endif
1407# 151 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1408#if defined(__mips_n64) || defined(__mips_n32) /* PHYSADDR_64_BIT */
1409typedef __uint64_t __vm_paddr_t;
1410#else
1411# 154 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1412typedef __uint32_t __vm_paddr_t;
1413#endif
1414# 156 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1415
1416typedef int ___wchar_t;
1417
1418#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */
1419#define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */
1420
1421/*
1422 * Unusual type definitions.
1423 */
1424#ifdef __GNUCLIKE_BUILTIN_VARARGS
1425typedef __builtin_va_list __va_list; /* internally known to gcc */
1426#else
1427# 168 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1428typedef char * __va_list;
1429#endif /* __GNUCLIKE_BUILTIN_VARARGS */
1430# 170 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1431#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
1432 && !defined(__NO_GNUC_VA_LIST)
1433#define __GNUC_VA_LIST
1434typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
1435#endif
1436# 175 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1437
1438#endif /* !_MACHINE__TYPES_H_ */
1439# 177 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_types.h" 3 4
1440# 34 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_types.h" 2 3 4
1441
1442/*
1443 * Standard type definitions.
1444 */
1445typedef __int32_t __blksize_t; /* file block size */
1446typedef __int64_t __blkcnt_t; /* file block count */
1447typedef __int32_t __clockid_t; /* clock_gettime()... */
1448typedef __uint32_t __fflags_t; /* file flags */
1449typedef __uint64_t __fsblkcnt_t;
1450typedef __uint64_t __fsfilcnt_t;
1451typedef __uint32_t __gid_t;
1452typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */
1453typedef __uint64_t __ino_t; /* inode number */
1454typedef long __key_t; /* IPC key (for Sys V IPC) */
1455typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */
1456typedef __uint16_t __mode_t; /* permissions */
1457typedef int __accmode_t; /* access permissions */
1458typedef int __nl_item;
1459typedef __uint64_t __nlink_t; /* link count */
1460typedef __int64_t __off_t; /* file offset */
1461typedef __int64_t __off64_t; /* file offset (alias) */
1462typedef __int32_t __pid_t; /* process [group] */
1463typedef __int64_t __rlim_t; /* resource limit - intentionally */
1464 /* signed, because of legacy code */
1465 /* that uses -1 for RLIM_INFINITY */
1466typedef __uint8_t __sa_family_t;
1467typedef __uint32_t __socklen_t;
1468typedef long __suseconds_t; /* microseconds (signed) */
1469typedef struct __timer *__timer_t; /* timer_gettime()... */
1470typedef struct __mq *__mqd_t; /* mq_open()... */
1471typedef __uint32_t __uid_t;
1472typedef unsigned int __useconds_t; /* microseconds (unsigned) */
1473typedef int __cpuwhich_t; /* which parameter for cpuset. */
1474typedef int __cpulevel_t; /* level parameter for cpuset. */
1475typedef int __cpusetid_t; /* cpuset identifier. */
1476
1477/*
1478 * Unusual type definitions.
1479 */
1480/*
1481 * rune_t is declared to be an ``int'' instead of the more natural
1482 * ``unsigned long'' or ``long''. Two things are happening here. It is not
1483 * unsigned so that EOF (-1) can be naturally assigned to it and used. Also,
1484 * it looks like 10646 will be a 31 bit standard. This means that if your
1485 * ints cannot hold 32 bits, you will be in trouble. The reason an int was
1486 * chosen over a long is that the is*() and to*() routines take ints (says
1487 * ANSI C), but they use __ct_rune_t instead of int.
1488 *
1489 * NOTE: rune_t is not covered by ANSI nor other standards, and should not
1490 * be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and
1491 * rune_t must be the same type. Also, wint_t should be able to hold all
1492 * members of the largest character set plus one extra value (WEOF), and
1493 * must be at least 16 bits.
1494 */
1495typedef int __ct_rune_t; /* arg type for ctype funcs */
1496typedef __ct_rune_t __rune_t; /* rune_t (see above) */
1497typedef __ct_rune_t __wint_t; /* wint_t (see above) */
1498
1499/* Clang already provides these types as built-ins, but only in C++ mode. */
1500#if !defined(__clang__) || !defined(__cplusplus)
1501typedef __uint_least16_t __char16_t;
1502typedef __uint_least32_t __char32_t;
1503#endif
1504# 97 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_types.h" 3 4
1505/* In C++11, char16_t and char32_t are built-in types. */
1506#if defined(__cplusplus) && __cplusplus >= 201103L
1507#define _CHAR16_T_DECLARED
1508#define _CHAR32_T_DECLARED
1509#endif
1510# 102 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_types.h" 3 4
1511
1512typedef struct {
1513 long long __max_align1 __aligned(_Alignof(long long));
1514 long double __max_align2 __aligned(_Alignof(long double));
1515} __max_align_t;
1516
1517typedef __uint64_t __dev_t; /* device number */
1518
1519typedef __uint32_t __fixpt_t; /* fixed point number */
1520
1521/*
1522 * mbstate_t is an opaque object to keep conversion state during multibyte
1523 * stream conversions.
1524 */
1525typedef union {
1526 char __mbstate8[128];
1527 __int64_t _mbstateL; /* for alignment */
1528} __mbstate_t;
1529
1530typedef __uintmax_t __rman_res_t;
1531
1532/*
1533 * When the following macro is defined, the system uses 64-bit inode numbers.
1534 * Programs can use this to avoid including <sys/param.h>, with its associated
1535 * namespace pollution.
1536 */
1537#define __INO64
1538
1539#endif /* !_SYS__TYPES_H_ */
1540# 131 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_types.h" 3 4
1541# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 2 3 4
1542
1543__NULLABILITY_PRAGMA_PUSH
1544
1545#if __BSD_VISIBLE
1546#ifndef _RUNE_T_DECLARED
1547typedef __rune_t rune_t;
1548#define _RUNE_T_DECLARED
1549#endif
1550# 47 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1551#endif
1552# 48 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1553
1554#ifndef _SIZE_T_DECLARED
1555typedef __size_t size_t;
1556#define _SIZE_T_DECLARED
1557#endif
1558# 53 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1559
1560#ifndef __cplusplus
1561#ifndef _WCHAR_T_DECLARED
1562typedef ___wchar_t wchar_t;
1563#define _WCHAR_T_DECLARED
1564#endif
1565# 59 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1566#endif
1567# 60 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1568
1569typedef struct {
1570 int quot; /* quotient */
1571 int rem; /* remainder */
1572} div_t;
1573
1574typedef struct {
1575 long quot;
1576 long rem;
1577} ldiv_t;
1578
1579#define EXIT_FAILURE 1
1580#define EXIT_SUCCESS 0
1581
1582#define RAND_MAX 0x7ffffffd
1583
1584__BEGIN_DECLS
1585#ifdef _XLOCALE_H_
1586#if 0 /* expanded by -frewrite-includes */
1587#include <xlocale/_stdlib.h>
1588#endif /* expanded by -frewrite-includes */
1589# 78 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1590# 79 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1591#endif
1592# 80 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1593extern int __mb_cur_max;
1594extern int ___mb_cur_max(void);
1595#define MB_CUR_MAX ((size_t)___mb_cur_max())
1596
1597_Noreturn void abort(void);
1598int abs(int) __pure2;
1599int atexit(void (* _Nonnull)(void));
1600double atof(const char *);
1601int atoi(const char *);
1602long atol(const char *);
1603void *bsearch(const void *, const void *, size_t,
1604 size_t, int (*)(const void * _Nonnull, const void *));
1605void *calloc(size_t, size_t) __malloc_like __result_use_check
1606 __alloc_size(1) __alloc_size(2);
1607div_t div(int, int) __pure2;
1608_Noreturn void exit(int);
1609void free(void *);
1610char *getenv(const char *);
1611long labs(long) __pure2;
1612ldiv_t ldiv(long, long) __pure2;
1613void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1);
1614int mblen(const char *, size_t);
1615size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
1616int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
1617void qsort(void *, size_t, size_t,
1618 int (* _Nonnull)(const void *, const void *));
1619int rand(void);
1620void *realloc(void *, size_t) __result_use_check __alloc_size(2);
1621void srand(unsigned);
1622double strtod(const char * __restrict, char ** __restrict);
1623float strtof(const char * __restrict, char ** __restrict);
1624long strtol(const char * __restrict, char ** __restrict, int);
1625long double
1626 strtold(const char * __restrict, char ** __restrict);
1627unsigned long
1628 strtoul(const char * __restrict, char ** __restrict, int);
1629int system(const char *);
1630int wctomb(char *, wchar_t);
1631size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
1632
1633/*
1634 * Functions added in C99 which we make conditionally available in the
1635 * BSD^C89 namespace if the compiler supports `long long'.
1636 * The #if test is more complicated than it ought to be because
1637 * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long'
1638 * is not supported in the compilation environment (which therefore means
1639 * that it can't really be ISO C99).
1640 *
1641 * (The only other extension made by C99 in thie header is _Exit().)
1642 */
1643#if __ISO_C_VISIBLE >= 1999 || defined(__cplusplus)
1644#ifdef __LONG_LONG_SUPPORTED
1645/* LONGLONG */
1646typedef struct {
1647 long long quot;
1648 long long rem;
1649} lldiv_t;
1650
1651/* LONGLONG */
1652long long
1653 atoll(const char *);
1654/* LONGLONG */
1655long long
1656 llabs(long long) __pure2;
1657/* LONGLONG */
1658lldiv_t lldiv(long long, long long) __pure2;
1659/* LONGLONG */
1660long long
1661 strtoll(const char * __restrict, char ** __restrict, int);
1662/* LONGLONG */
1663unsigned long long
1664 strtoull(const char * __restrict, char ** __restrict, int);
1665#endif /* __LONG_LONG_SUPPORTED */
1666# 153 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1667
1668_Noreturn void _Exit(int);
1669#endif /* __ISO_C_VISIBLE >= 1999 */
1670# 156 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1671
1672/*
1673 * If we're in a mode greater than C99, expose C11 functions.
1674 */
1675#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
1676void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
1677 __alloc_size(2);
1678int at_quick_exit(void (*)(void));
1679_Noreturn void
1680 quick_exit(int);
1681#endif /* __ISO_C_VISIBLE >= 2011 */
1682# 167 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1683/*
1684 * Extensions made by POSIX relative to C.
1685 */
1686#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
1687char *realpath(const char * __restrict, char * __restrict);
1688#endif
1689# 173 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1690#if __POSIX_VISIBLE >= 199506
1691int rand_r(unsigned *); /* (TSF) */
1692#endif
1693# 176 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1694#if __POSIX_VISIBLE >= 200112
1695int posix_memalign(void **, size_t, size_t); /* (ADV) */
1696int setenv(const char *, const char *, int);
1697int unsetenv(const char *);
1698#endif
1699# 181 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1700
1701#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
1702int getsubopt(char **, char *const *, char **);
1703#ifndef _MKDTEMP_DECLARED
1704char *mkdtemp(char *);
1705#define _MKDTEMP_DECLARED
1706#endif
1707# 188 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1708#ifndef _MKSTEMP_DECLARED
1709int mkstemp(char *);
1710#define _MKSTEMP_DECLARED
1711#endif
1712# 192 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1713#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
1714# 193 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1715
1716/*
1717 * The only changes to the XSI namespace in revision 6 were the deletion
1718 * of the ttyslot() and valloc() functions, which FreeBSD never declared
1719 * in this header. For revision 7, ecvt(), fcvt(), and gcvt(), which
1720 * FreeBSD also does not have, and mktemp(), are to be deleted.
1721 */
1722#if __XSI_VISIBLE
1723/* XXX XSI requires pollution from <sys/wait.h> here. We'd rather not. */
1724long a64l(const char *);
1725double drand48(void);
1726/* char *ecvt(double, int, int * __restrict, int * __restrict); */
1727double erand48(unsigned short[3]);
1728/* char *fcvt(double, int, int * __restrict, int * __restrict); */
1729/* char *gcvt(double, int, int * __restrict, int * __restrict); */
1730int grantpt(int);
1731char *initstate(unsigned int, char *, size_t);
1732long jrand48(unsigned short[3]);
1733char *l64a(long);
1734void lcong48(unsigned short[7]);
1735long lrand48(void);
1736#if !defined(_MKTEMP_DECLARED) && (__BSD_VISIBLE || __XSI_VISIBLE <= 600)
1737char *mktemp(char *);
1738#define _MKTEMP_DECLARED
1739#endif
1740# 218 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1741long mrand48(void);
1742long nrand48(unsigned short[3]);
1743int posix_openpt(int);
1744char *ptsname(int);
1745int putenv(char *);
1746long random(void);
1747unsigned short
1748 *seed48(unsigned short[3]);
1749char *setstate(/* const */ char *);
1750void srand48(long);
1751void srandom(unsigned int);
1752int unlockpt(int);
1753#endif /* __XSI_VISIBLE */
1754# 231 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1755
1756#if __BSD_VISIBLE
1757extern const char *malloc_conf;
1758extern void (*malloc_message)(void *, const char *);
1759
1760/*
1761 * The alloca() function can't be implemented in C, and on some
1762 * platforms it can't be implemented at all as a callable function.
1763 * The GNU C compiler provides a built-in alloca() which we can use;
1764 * in all other cases, provide a prototype, mainly to pacify various
1765 * incarnations of lint. On platforms where alloca() is not in libc,
1766 * programs which use it will fail to link when compiled with non-GNU
1767 * compilers.
1768 */
1769#if __GNUC__ >= 2 || defined(__INTEL_COMPILER)
1770#undef alloca /* some GNU bits try to get cute and define this on their own */
1771#define alloca(sz) __builtin_alloca(sz)
1772#elif defined(lint)
1773# 249 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1774void *alloca(size_t);
1775#endif
1776# 251 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1777
1778void abort2(const char *, int, void **) __dead2;
1779__uint32_t
1780 arc4random(void);
1781void arc4random_addrandom(unsigned char *, int);
1782void arc4random_buf(void *, size_t);
1783void arc4random_stir(void);
1784__uint32_t
1785 arc4random_uniform(__uint32_t);
1786#ifdef __BLOCKS__
1787int atexit_b(void (^ _Nonnull)(void));
1788void *bsearch_b(const void *, const void *, size_t,
1789 size_t, int (^ _Nonnull)(const void *, const void *));
1790#endif
1791# 265 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1792char *getbsize(int *, long *);
1793 /* getcap(3) functions */
1794char *cgetcap(char *, const char *, int);
1795int cgetclose(void);
1796int cgetent(char **, char **, const char *);
1797int cgetfirst(char **, char **);
1798int cgetmatch(const char *, const char *);
1799int cgetnext(char **, char **);
1800int cgetnum(char *, const char *, long *);
1801int cgetset(const char *);
1802int cgetstr(char *, const char *, char **);
1803int cgetustr(char *, const char *, char **);
1804
1805int daemon(int, int);
1806char *devname(__dev_t, __mode_t);
1807char *devname_r(__dev_t, __mode_t, char *, int);
1808char *fdevname(int);
1809char *fdevname_r(int, char *, int);
1810int getloadavg(double [], int);
1811const char *
1812 getprogname(void);
1813
1814int heapsort(void *, size_t, size_t,
1815 int (* _Nonnull)(const void *, const void *));
1816#ifdef __BLOCKS__
1817int heapsort_b(void *, size_t, size_t,
1818 int (^ _Nonnull)(const void *, const void *));
1819void qsort_b(void *, size_t, size_t,
1820 int (^ _Nonnull)(const void *, const void *));
1821#endif
1822# 295 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1823int l64a_r(long, char *, int);
1824int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
1825#ifdef __BLOCKS__
1826int mergesort_b(void *, size_t, size_t, int (^)(const void *, const void *));
1827#endif
1828# 300 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1829int mkostemp(char *, int);
1830int mkostemps(char *, int, int);
1831void qsort_r(void *, size_t, size_t, void *,
1832 int (*)(void *, const void *, const void *));
1833int radixsort(const unsigned char **, int, const unsigned char *,
1834 unsigned);
1835void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
1836 __alloc_size(3);
1837void *reallocf(void *, size_t) __alloc_size(2);
1838int rpmatch(const char *);
1839void setprogname(const char *);
1840int sradixsort(const unsigned char **, int, const unsigned char *,
1841 unsigned);
1842void sranddev(void);
1843void srandomdev(void);
1844long long
1845 strtonum(const char *, long long, long long, const char **);
1846
1847/* Deprecated interfaces, to be removed. */
1848__int64_t
1849 strtoq(const char *, char **, int);
1850__uint64_t
1851 strtouq(const char *, char **, int);
1852
1853#if __has_feature(capabilities)
1854long strtol_c(__capability const char * __restrict,
1855 char * __capability * __capability __restrict, int);
1856long double
1857 strtold_c(__capability const char * __restrict,
1858 char * __capability * __restrict);
1859#endif
1860# 331 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1861
1862int timsort(void *base, size_t nel, size_t width,
1863 int (*compar) (const void *, const void *));
1864
1865extern char *suboptarg; /* getsubopt(3) external variable */
1866#endif /* __BSD_VISIBLE */
1867# 337 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1868
1869#if __EXT1_VISIBLE
1870
1871#ifndef _ERRNO_T_DEFINED
1872#define _ERRNO_T_DEFINED
1873typedef int errno_t;
1874#endif
1875# 344 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1876
1877/* K.3.6 */
1878typedef void (*constraint_handler_t)(const char * __restrict,
1879 void * __restrict, errno_t);
1880/* K.3.6.1.1 */
1881constraint_handler_t set_constraint_handler_s(constraint_handler_t handler);
1882/* K.3.6.1.2 */
1883_Noreturn void abort_handler_s(const char * __restrict, void * __restrict,
1884 errno_t);
1885/* K3.6.1.3 */
1886void ignore_handler_s(const char * __restrict, void * __restrict, errno_t);
1887#endif /* __EXT1_VISIBLE */
1888# 356 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1889
1890__END_DECLS
1891__NULLABILITY_PRAGMA_POP
1892
1893#endif /* !_STDLIB_H_ */
1894# 361 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdlib.h" 3 4
1895# 20 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
1896#if 0 /* expanded by -frewrite-includes */
1897#include <math.h>
1898#endif /* expanded by -frewrite-includes */
1899# 20 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
1900# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 1 3 4
1901/*
1902 * ====================================================
1903 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
1904 *
1905 * Developed at SunPro, a Sun Microsystems, Inc. business.
1906 * Permission to use, copy, modify, and distribute this
1907 * software is freely granted, provided that this notice
1908 * is preserved.
1909 * ====================================================
1910 */
1911
1912/*
1913 * from: @(#)fdlibm.h 5.1 93/09/24
1914 * $FreeBSD$
1915 */
1916
1917#ifndef _MATH_H_
1918#define _MATH_H_
1919
1920#if 0 /* expanded by -frewrite-includes */
1921#include <sys/cdefs.h>
1922#endif /* expanded by -frewrite-includes */
1923# 20 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
1924# 21 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
1925#if 0 /* expanded by -frewrite-includes */
1926#include <sys/_types.h>
1927#endif /* expanded by -frewrite-includes */
1928# 21 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
1929# 22 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
1930#if 0 /* expanded by -frewrite-includes */
1931#include <machine/_limits.h>
1932#endif /* expanded by -frewrite-includes */
1933# 22 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
1934# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_limits.h" 1 3 4
1935/*-
1936 * Copyright (c) 1988, 1993
1937 * The Regents of the University of California. All rights reserved.
1938 *
1939 * Redistribution and use in source and binary forms, with or without
1940 * modification, are permitted provided that the following conditions
1941 * are met:
1942 * 1. Redistributions of source code must retain the above copyright
1943 * notice, this list of conditions and the following disclaimer.
1944 * 2. Redistributions in binary form must reproduce the above copyright
1945 * notice, this list of conditions and the following disclaimer in the
1946 * documentation and/or other materials provided with the distribution.
1947 * 3. Neither the name of the University nor the names of its contributors
1948 * may be used to endorse or promote products derived from this software
1949 * without specific prior written permission.
1950 *
1951 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1952 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1953 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1954 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1955 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1956 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1957 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1958 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1959 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1960 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1961 * SUCH DAMAGE.
1962 *
1963 * @(#)limits.h 8.3 (Berkeley) 1/4/94
1964 * from: src/sys/i386/include/_limits.h,v 1.27 2005/01/06 22:18:15 imp
1965 * $FreeBSD$
1966 */
1967
1968#ifndef _MACHINE__LIMITS_H_
1969#define _MACHINE__LIMITS_H_
1970
1971/*
1972 * According to ANSI (section 2.2.4.2), the values below must be usable by
1973 * #if preprocessing directives. Additionally, the expression must have the
1974 * same type as would an expression that is an object of the corresponding
1975 * type converted according to the integral promotions. The subtraction for
1976 * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
1977 * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
1978 */
1979
1980#define __CHAR_BIT 8 /* number of bits in a char */
1981
1982#define __SCHAR_MAX 0x7f /* max value for a signed char */
1983#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
1984
1985#define __UCHAR_MAX 0xff /* max value for an unsigned char */
1986
1987#define __USHRT_MAX 0xffff /* max value for an unsigned short */
1988#define __SHRT_MAX 0x7fff /* max value for a short */
1989#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */
1990
1991#define __UINT_MAX 0xffffffff /* max value for an unsigned int */
1992#define __INT_MAX 0x7fffffff /* max value for an int */
1993#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */
1994
1995#ifdef __mips_n64
1996#define __ULONG_MAX 0xffffffffffffffff
1997#define __LONG_MAX 0x7fffffffffffffff
1998#define __LONG_MIN (-0x7fffffffffffffff - 1)
1999#define __LONG_BIT 64
2000#else
2001# 67 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_limits.h" 3 4
2002#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
2003#define __LONG_MAX 0x7fffffffL /* max value for a long */
2004#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
2005#define __LONG_BIT 32
2006#endif
2007# 72 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_limits.h" 3 4
2008
2009 /* max value for an unsigned long long */
2010#define __ULLONG_MAX 0xffffffffffffffffULL
2011#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */
2012#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */
2013
2014#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */
2015
2016#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */
2017
2018#define __OFF_MAX __LLONG_MAX /* max value for an off_t */
2019#define __OFF_MIN __LLONG_MIN /* min value for an off_t */
2020
2021/* Quads and long longs are the same size. Ensure they stay in sync. */
2022#define __UQUAD_MAX __ULLONG_MAX /* max value for a uquad_t */
2023#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */
2024#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */
2025
2026#define __WORD_BIT 32
2027
2028#define __MINSIGSTKSZ (512 * 4)
2029
2030#endif /* !_MACHINE__LIMITS_H_ */
2031# 95 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/_limits.h" 3 4
2032# 23 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 2 3 4
2033
2034/*
2035 * ANSI/POSIX
2036 */
2037extern const union __infinity_un {
2038 unsigned char __uc[8];
2039 double __ud;
2040} __infinity;
2041
2042extern const union __nan_un {
2043 unsigned char __uc[sizeof(float)];
2044 float __uf;
2045} __nan;
2046
2047#if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
2048#define __MATH_BUILTIN_CONSTANTS
2049#endif
2050# 40 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2051
2052#if __GNUC_PREREQ__(3, 0) && !defined(__INTEL_COMPILER)
2053#define __MATH_BUILTIN_RELOPS
2054#endif
2055# 44 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2056
2057#ifdef __MATH_BUILTIN_CONSTANTS
2058#define HUGE_VAL __builtin_huge_val()
2059#else
2060# 48 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2061#define HUGE_VAL (__infinity.__ud)
2062#endif
2063# 50 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2064
2065#if __ISO_C_VISIBLE >= 1999
2066#define FP_ILOGB0 (-__INT_MAX)
2067#define FP_ILOGBNAN __INT_MAX
2068
2069#ifdef __MATH_BUILTIN_CONSTANTS
2070#define HUGE_VALF __builtin_huge_valf()
2071#define HUGE_VALL __builtin_huge_vall()
2072#define INFINITY __builtin_inff()
2073#define NAN __builtin_nanf("")
2074#else
2075# 61 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2076#define HUGE_VALF (float)HUGE_VAL
2077#define HUGE_VALL (long double)HUGE_VAL
2078#define INFINITY HUGE_VALF
2079#define NAN (__nan.__uf)
2080#endif /* __MATH_BUILTIN_CONSTANTS */
2081# 66 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2082
2083#define MATH_ERRNO 1
2084#define MATH_ERREXCEPT 2
2085#define math_errhandling MATH_ERREXCEPT
2086
2087#define FP_FAST_FMAF 1
2088
2089/* Symbolic constants to classify floating point numbers. */
2090#define FP_INFINITE 0x01
2091#define FP_NAN 0x02
2092#define FP_NORMAL 0x04
2093#define FP_SUBNORMAL 0x08
2094#define FP_ZERO 0x10
2095
2096#if (__STDC_VERSION__ >= 201112L && defined(__clang__)) || \
2097 __has_extension(c_generic_selections)
2098#define __fp_type_select(x, f, d, ld) _Generic((x), \
2099 float: f(x), \
2100 double: d(x), \
2101 long double: ld(x), \
2102 volatile float: f(x), \
2103 volatile double: d(x), \
2104 volatile long double: ld(x), \
2105 volatile const float: f(x), \
2106 volatile const double: d(x), \
2107 volatile const long double: ld(x), \
2108 const float: f(x), \
2109 const double: d(x), \
2110 const long double: ld(x))
2111#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
2112# 96 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2113#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
2114 __builtin_types_compatible_p(__typeof(x), long double), ld(x), \
2115 __builtin_choose_expr( \
2116 __builtin_types_compatible_p(__typeof(x), double), d(x), \
2117 __builtin_choose_expr( \
2118 __builtin_types_compatible_p(__typeof(x), float), f(x), (void)0)))
2119#else
2120# 103 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2121#define __fp_type_select(x, f, d, ld) \
2122 ((sizeof(x) == sizeof(float)) ? f(x) \
2123 : (sizeof(x) == sizeof(double)) ? d(x) \
2124 : ld(x))
2125#endif
2126# 108 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2127
2128#define fpclassify(x) \
2129 __fp_type_select(x, __fpclassifyf, __fpclassifyd, __fpclassifyl)
2130#define isfinite(x) __fp_type_select(x, __isfinitef, __isfinite, __isfinitel)
2131#define isinf(x) __fp_type_select(x, __isinff, __isinf, __isinfl)
2132#define isnan(x) \
2133 __fp_type_select(x, __inline_isnanf, __inline_isnan, __inline_isnanl)
2134#define isnormal(x) __fp_type_select(x, __isnormalf, __isnormal, __isnormall)
2135
2136#ifdef __MATH_BUILTIN_RELOPS
2137#define isgreater(x, y) __builtin_isgreater((x), (y))
2138#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
2139#define isless(x, y) __builtin_isless((x), (y))
2140#define islessequal(x, y) __builtin_islessequal((x), (y))
2141#define islessgreater(x, y) __builtin_islessgreater((x), (y))
2142#define isunordered(x, y) __builtin_isunordered((x), (y))
2143#else
2144# 125 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2145#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
2146#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
2147#define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
2148#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
2149#define islessgreater(x, y) (!isunordered((x), (y)) && \
2150 ((x) > (y) || (y) > (x)))
2151#define isunordered(x, y) (isnan(x) || isnan(y))
2152#endif /* __MATH_BUILTIN_RELOPS */
2153# 133 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2154
2155#define signbit(x) __fp_type_select(x, __signbitf, __signbit, __signbitl)
2156
2157typedef __double_t double_t;
2158typedef __float_t float_t;
2159#endif /* __ISO_C_VISIBLE >= 1999 */
2160# 139 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2161
2162/*
2163 * XOPEN/SVID
2164 */
2165#if __BSD_VISIBLE || __XSI_VISIBLE
2166#define M_E 2.7182818284590452354 /* e */
2167#define M_LOG2E 1.4426950408889634074 /* log 2e */
2168#define M_LOG10E 0.43429448190325182765 /* log 10e */
2169#define M_LN2 0.69314718055994530942 /* log e2 */
2170#define M_LN10 2.30258509299404568402 /* log e10 */
2171#define M_PI 3.14159265358979323846 /* pi */
2172#define M_PI_2 1.57079632679489661923 /* pi/2 */
2173#define M_PI_4 0.78539816339744830962 /* pi/4 */
2174#define M_1_PI 0.31830988618379067154 /* 1/pi */
2175#define M_2_PI 0.63661977236758134308 /* 2/pi */
2176#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
2177#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
2178#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
2179
2180#define MAXFLOAT ((float)3.40282346638528860e+38)
2181extern int signgam;
2182#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
2183# 161 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2184
2185#if __BSD_VISIBLE
2186#if 0
2187/* Old value from 4.4BSD-Lite math.h; this is probably better. */
2188#define HUGE HUGE_VAL
2189#else
2190# 167 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2191#define HUGE MAXFLOAT
2192#endif
2193# 169 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2194#endif /* __BSD_VISIBLE */
2195# 170 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2196
2197/*
2198 * Most of these functions depend on the rounding mode and have the side
2199 * effect of raising floating-point exceptions, so they are not declared
2200 * as __pure2. In C99, FENV_ACCESS affects the purity of these functions.
2201 */
2202__BEGIN_DECLS
2203/*
2204 * ANSI/POSIX
2205 */
2206int __fpclassifyd(double) __pure2;
2207int __fpclassifyf(float) __pure2;
2208int __fpclassifyl(long double) __pure2;
2209int __isfinitef(float) __pure2;
2210int __isfinite(double) __pure2;
2211int __isfinitel(long double) __pure2;
2212int __isinff(float) __pure2;
2213int __isinf(double) __pure2;
2214int __isinfl(long double) __pure2;
2215int __isnormalf(float) __pure2;
2216int __isnormal(double) __pure2;
2217int __isnormall(long double) __pure2;
2218int __signbit(double) __pure2;
2219int __signbitf(float) __pure2;
2220int __signbitl(long double) __pure2;
2221
2222static __inline int
2223__inline_isnan(__const double __x)
2224{
2225
2226 return (__x != __x);
2227}
2228
2229static __inline int
2230__inline_isnanf(__const float __x)
2231{
2232
2233 return (__x != __x);
2234}
2235
2236static __inline int
2237__inline_isnanl(__const long double __x)
2238{
2239
2240 return (__x != __x);
2241}
2242
2243/*
2244 * Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and
2245 * isinf() as functions taking double. C99, and the subsequent POSIX revisions
2246 * (SUSv3, POSIX.1-2001, define it as a macro that accepts any real floating
2247 * point type. If we are targeting SUSv2 and C99 or C11 (or C++11) then we
2248 * expose the newer definition, assuming that the language spec takes
2249 * precedence over the operating system interface spec.
2250 */
2251#if __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600 && __ISO_C_VISIBLE < 1999
2252#undef isinf
2253#undef isnan
2254int isinf(double);
2255int isnan(double);
2256#endif
2257# 231 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2258
2259double acos(double);
2260double asin(double);
2261double atan(double);
2262double atan2(double, double);
2263double cos(double);
2264double sin(double);
2265double tan(double);
2266
2267double cosh(double);
2268double sinh(double);
2269double tanh(double);
2270
2271double exp(double);
2272double frexp(double, int *); /* fundamentally !__pure2 */
2273double ldexp(double, int);
2274double log(double);
2275double log10(double);
2276double modf(double, double *); /* fundamentally !__pure2 */
2277
2278double pow(double, double);
2279double sqrt(double);
2280
2281double ceil(double);
2282double fabs(double) __pure2;
2283double floor(double);
2284double fmod(double, double);
2285
2286/*
2287 * These functions are not in C90.
2288 */
2289#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE
2290double acosh(double);
2291double asinh(double);
2292double atanh(double);
2293double cbrt(double);
2294double erf(double);
2295double erfc(double);
2296double exp2(double);
2297double expm1(double);
2298double fma(double, double, double);
2299double hypot(double, double);
2300int ilogb(double) __pure2;
2301double lgamma(double);
2302long long llrint(double);
2303long long llround(double);
2304double log1p(double);
2305double log2(double);
2306double logb(double);
2307long lrint(double);
2308long lround(double);
2309double nan(const char *) __pure2;
2310double nextafter(double, double);
2311double remainder(double, double);
2312double remquo(double, double, int *);
2313double rint(double);
2314#endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
2315# 288 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2316
2317#if __BSD_VISIBLE || __XSI_VISIBLE
2318double j0(double);
2319double j1(double);
2320double jn(int, double);
2321double y0(double);
2322double y1(double);
2323double yn(int, double);
2324
2325#if __XSI_VISIBLE <= 500 || __BSD_VISIBLE
2326double gamma(double);
2327#endif
2328# 300 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2329
2330#if __XSI_VISIBLE <= 600 || __BSD_VISIBLE
2331double scalb(double, double);
2332#endif
2333# 304 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2334#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
2335# 305 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2336
2337#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999
2338double copysign(double, double) __pure2;
2339double fdim(double, double);
2340double fmax(double, double) __pure2;
2341double fmin(double, double) __pure2;
2342double nearbyint(double);
2343double round(double);
2344double scalbln(double, long);
2345double scalbn(double, int);
2346double tgamma(double);
2347double trunc(double);
2348#endif
2349# 318 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2350
2351/*
2352 * BSD math library entry points
2353 */
2354#if __BSD_VISIBLE
2355double drem(double, double);
2356int finite(double) __pure2;
2357int isnanf(float) __pure2;
2358
2359/*
2360 * Reentrant version of gamma & lgamma; passes signgam back by reference
2361 * as the second argument; user must allocate space for signgam.
2362 */
2363double gamma_r(double, int *);
2364double lgamma_r(double, int *);
2365
2366/*
2367 * IEEE Test Vector
2368 */
2369double significand(double);
2370#endif /* __BSD_VISIBLE */
2371# 339 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2372
2373/* float versions of ANSI/POSIX functions */
2374#if __ISO_C_VISIBLE >= 1999
2375float acosf(float);
2376float asinf(float);
2377float atanf(float);
2378float atan2f(float, float);
2379float cosf(float);
2380float sinf(float);
2381float tanf(float);
2382
2383float coshf(float);
2384float sinhf(float);
2385float tanhf(float);
2386
2387float exp2f(float);
2388float expf(float);
2389float expm1f(float);
2390float frexpf(float, int *); /* fundamentally !__pure2 */
2391int ilogbf(float) __pure2;
2392float ldexpf(float, int);
2393float log10f(float);
2394float log1pf(float);
2395float log2f(float);
2396float logf(float);
2397float modff(float, float *); /* fundamentally !__pure2 */
2398
2399float powf(float, float);
2400float sqrtf(float);
2401
2402float ceilf(float);
2403float fabsf(float) __pure2;
2404float floorf(float);
2405float fmodf(float, float);
2406float roundf(float);
2407
2408float erff(float);
2409float erfcf(float);
2410float hypotf(float, float);
2411float lgammaf(float);
2412float tgammaf(float);
2413
2414float acoshf(float);
2415float asinhf(float);
2416float atanhf(float);
2417float cbrtf(float);
2418float logbf(float);
2419float copysignf(float, float) __pure2;
2420long long llrintf(float);
2421long long llroundf(float);
2422long lrintf(float);
2423long lroundf(float);
2424float nanf(const char *) __pure2;
2425float nearbyintf(float);
2426float nextafterf(float, float);
2427float remainderf(float, float);
2428float remquof(float, float, int *);
2429float rintf(float);
2430float scalblnf(float, long);
2431float scalbnf(float, int);
2432float truncf(float);
2433
2434float fdimf(float, float);
2435float fmaf(float, float, float);
2436float fmaxf(float, float) __pure2;
2437float fminf(float, float) __pure2;
2438#endif
2439# 406 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2440
2441/*
2442 * float versions of BSD math library entry points
2443 */
2444#if __BSD_VISIBLE
2445float dremf(float, float);
2446int finitef(float) __pure2;
2447float gammaf(float);
2448float j0f(float);
2449float j1f(float);
2450float jnf(int, float);
2451float scalbf(float, float);
2452float y0f(float);
2453float y1f(float);
2454float ynf(int, float);
2455
2456/*
2457 * Float versions of reentrant version of gamma & lgamma; passes
2458 * signgam back by reference as the second argument; user must
2459 * allocate space for signgam.
2460 */
2461float gammaf_r(float, int *);
2462float lgammaf_r(float, int *);
2463
2464/*
2465 * float version of IEEE Test Vector
2466 */
2467float significandf(float);
2468#endif /* __BSD_VISIBLE */
2469# 435 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2470
2471/*
2472 * long double versions of ISO/POSIX math functions
2473 */
2474#if __ISO_C_VISIBLE >= 1999
2475long double acoshl(long double);
2476long double acosl(long double);
2477long double asinhl(long double);
2478long double asinl(long double);
2479long double atan2l(long double, long double);
2480long double atanhl(long double);
2481long double atanl(long double);
2482long double cbrtl(long double);
2483long double ceill(long double);
2484long double copysignl(long double, long double) __pure2;
2485long double coshl(long double);
2486long double cosl(long double);
2487long double erfcl(long double);
2488long double erfl(long double);
2489long double exp2l(long double);
2490long double expl(long double);
2491long double expm1l(long double);
2492long double fabsl(long double) __pure2;
2493long double fdiml(long double, long double);
2494long double floorl(long double);
2495long double fmal(long double, long double, long double);
2496long double fmaxl(long double, long double) __pure2;
2497long double fminl(long double, long double) __pure2;
2498long double fmodl(long double, long double);
2499long double frexpl(long double, int *); /* fundamentally !__pure2 */
2500long double hypotl(long double, long double);
2501int ilogbl(long double) __pure2;
2502long double ldexpl(long double, int);
2503long double lgammal(long double);
2504long long llrintl(long double);
2505long long llroundl(long double);
2506long double log10l(long double);
2507long double log1pl(long double);
2508long double log2l(long double);
2509long double logbl(long double);
2510long double logl(long double);
2511long lrintl(long double);
2512long lroundl(long double);
2513long double modfl(long double, long double *); /* fundamentally !__pure2 */
2514long double nanl(const char *) __pure2;
2515long double nearbyintl(long double);
2516long double nextafterl(long double, long double);
2517double nexttoward(double, long double);
2518float nexttowardf(float, long double);
2519long double nexttowardl(long double, long double);
2520long double powl(long double, long double);
2521long double remainderl(long double, long double);
2522long double remquol(long double, long double, int *);
2523long double rintl(long double);
2524long double roundl(long double);
2525long double scalblnl(long double, long);
2526long double scalbnl(long double, int);
2527long double sinhl(long double);
2528long double sinl(long double);
2529long double sqrtl(long double);
2530long double tanhl(long double);
2531long double tanl(long double);
2532long double tgammal(long double);
2533long double truncl(long double);
2534#endif /* __ISO_C_VISIBLE >= 1999 */
2535# 500 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2536
2537#if __BSD_VISIBLE
2538long double lgammal_r(long double, int *);
2539#endif
2540# 504 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2541
2542__END_DECLS
2543
2544#endif /* !_MATH_H_ */
2545# 508 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/math.h" 3 4
2546# 21 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
2547#if 0 /* expanded by -frewrite-includes */
2548#include <assert.h>
2549#endif /* expanded by -frewrite-includes */
2550# 21 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
2551# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/assert.h" 1 3 4
2552/*-
2553 * Copyright (c) 1992, 1993
2554 * The Regents of the University of California. All rights reserved.
2555 * (c) UNIX System Laboratories, Inc.
2556 * All or some portions of this file are derived from material licensed
2557 * to the University of California by American Telephone and Telegraph
2558 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
2559 * the permission of UNIX System Laboratories, Inc.
2560 *
2561 * Redistribution and use in source and binary forms, with or without
2562 * modification, are permitted provided that the following conditions
2563 * are met:
2564 * 1. Redistributions of source code must retain the above copyright
2565 * notice, this list of conditions and the following disclaimer.
2566 * 2. Redistributions in binary form must reproduce the above copyright
2567 * notice, this list of conditions and the following disclaimer in the
2568 * documentation and/or other materials provided with the distribution.
2569 * 3. Neither the name of the University nor the names of its contributors
2570 * may be used to endorse or promote products derived from this software
2571 * without specific prior written permission.
2572 *
2573 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2574 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2575 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2576 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2577 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2578 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2579 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2580 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2581 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2582 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2583 * SUCH DAMAGE.
2584 *
2585 * @(#)assert.h 8.2 (Berkeley) 1/21/94
2586 * $FreeBSD$
2587 */
2588
2589#if 0 /* expanded by -frewrite-includes */
2590#include <sys/cdefs.h>
2591#endif /* expanded by -frewrite-includes */
2592# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/assert.h" 3 4
2593# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/assert.h" 3 4
2594
2595/*
2596 * Unlike other ANSI header files, <assert.h> may usefully be included
2597 * multiple times, with and without NDEBUG defined.
2598 */
2599
2600#undef assert
2601#undef _assert
2602
2603#ifdef NDEBUG
2604#define assert(e) ((void)0)
2605#define _assert(e) ((void)0)
2606#else
2607# 52 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/assert.h" 3 4
2608#define _assert(e) assert(e)
2609
2610#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
2611 __LINE__, #e))
2612#endif /* NDEBUG */
2613# 57 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/assert.h" 3 4
2614
2615#ifndef _ASSERT_H_
2616#define _ASSERT_H_
2617
2618/*
2619 * Static assertions. In principle we could define static_assert for
2620 * C++ older than C++11, but this breaks if _Static_assert is
2621 * implemented as a macro.
2622 *
2623 * C++ template parameters may contain commas, even if not enclosed in
2624 * parentheses, causing the _Static_assert macro to be invoked with more
2625 * than two parameters.
2626 */
2627#if __ISO_C_VISIBLE >= 2011 && !defined(__cplusplus)
2628#define static_assert _Static_assert
2629#endif
2630# 73 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/assert.h" 3 4
2631
2632__BEGIN_DECLS
2633void __assert(const char *, const char *, int, const char *) __dead2;
2634__END_DECLS
2635
2636#endif /* !_ASSERT_H_ */
2637# 79 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/assert.h" 3 4
2638# 22 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
2639#if 0 /* expanded by -frewrite-includes */
2640#include <limits.h>
2641#endif /* expanded by -frewrite-includes */
2642# 22 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
2643# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 1 3 4
2644/*-
2645 * Copyright (c) 1988, 1993
2646 * The Regents of the University of California. All rights reserved.
2647 *
2648 * Redistribution and use in source and binary forms, with or without
2649 * modification, are permitted provided that the following conditions
2650 * are met:
2651 * 1. Redistributions of source code must retain the above copyright
2652 * notice, this list of conditions and the following disclaimer.
2653 * 2. Redistributions in binary form must reproduce the above copyright
2654 * notice, this list of conditions and the following disclaimer in the
2655 * documentation and/or other materials provided with the distribution.
2656 * 3. Neither the name of the University nor the names of its contributors
2657 * may be used to endorse or promote products derived from this software
2658 * without specific prior written permission.
2659 *
2660 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2661 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2662 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2663 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2664 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2665 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2666 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2667 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2668 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2669 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2670 * SUCH DAMAGE.
2671 *
2672 * @(#)limits.h 8.2 (Berkeley) 1/4/94
2673 * $FreeBSD$
2674 */
2675
2676#ifndef _LIMITS_H_
2677#define _LIMITS_H_
2678
2679#if 0 /* expanded by -frewrite-includes */
2680#include <sys/cdefs.h>
2681#endif /* expanded by -frewrite-includes */
2682# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2683# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2684
2685#if __POSIX_VISIBLE
2686#define _POSIX_ARG_MAX 4096
2687#define _POSIX_LINK_MAX 8
2688#define _POSIX_MAX_CANON 255
2689#define _POSIX_MAX_INPUT 255
2690#define _POSIX_NAME_MAX 14
2691#define _POSIX_PIPE_BUF 512
2692#define _POSIX_SSIZE_MAX 32767
2693#define _POSIX_STREAM_MAX 8
2694
2695#if __POSIX_VISIBLE >= 200112
2696#define _POSIX_CHILD_MAX 25
2697#define _POSIX_NGROUPS_MAX 8
2698#define _POSIX_OPEN_MAX 20
2699#define _POSIX_PATH_MAX 256
2700#define _POSIX_TZNAME_MAX 6
2701#else
2702# 55 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2703#define _POSIX_CHILD_MAX 6
2704#define _POSIX_NGROUPS_MAX 0
2705#define _POSIX_OPEN_MAX 16
2706#define _POSIX_PATH_MAX 255
2707#define _POSIX_TZNAME_MAX 3
2708#endif
2709# 61 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2710
2711#if __POSIX_VISIBLE >= 200112
2712#define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */
2713#define BC_DIM_MAX 2048 /* max array elements in bc(1) */
2714#define BC_SCALE_MAX 99 /* max scale value in bc(1) */
2715#define BC_STRING_MAX 1000 /* max const string length in bc(1) */
2716#define CHARCLASS_NAME_MAX 14 /* max character class name size */
2717#define COLL_WEIGHTS_MAX 10 /* max weights for order keyword */
2718#define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */
2719#define LINE_MAX 2048 /* max bytes in an input line */
2720#define RE_DUP_MAX 255 /* max RE's in interval notation */
2721
2722#define _POSIX2_BC_BASE_MAX 99
2723#define _POSIX2_BC_DIM_MAX 2048
2724#define _POSIX2_BC_SCALE_MAX 99
2725#define _POSIX2_BC_STRING_MAX 1000
2726#define _POSIX2_CHARCLASS_NAME_MAX 14
2727#define _POSIX2_COLL_WEIGHTS_MAX 2
2728#define _POSIX2_EQUIV_CLASS_MAX 2
2729#define _POSIX2_EXPR_NEST_MAX 32
2730#define _POSIX2_LINE_MAX 2048
2731#define _POSIX2_RE_DUP_MAX 255
2732#endif
2733# 84 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2734#endif
2735# 85 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2736
2737#if __POSIX_VISIBLE >= 199309
2738#define _POSIX_AIO_LISTIO_MAX 2
2739#define _POSIX_AIO_MAX 1
2740#define _POSIX_DELAYTIMER_MAX 32
2741#define _POSIX_MQ_OPEN_MAX 8
2742#define _POSIX_MQ_PRIO_MAX 32
2743#define _POSIX_RTSIG_MAX 8
2744#define _POSIX_SEM_NSEMS_MAX 256
2745#define _POSIX_SEM_VALUE_MAX 32767
2746#define _POSIX_SIGQUEUE_MAX 32
2747#define _POSIX_TIMER_MAX 32
2748
2749#define _POSIX_CLOCKRES_MIN 20000000
2750#endif
2751# 100 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2752
2753#if __POSIX_VISIBLE >= 199506
2754#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
2755#define _POSIX_THREAD_KEYS_MAX 128
2756#define _POSIX_THREAD_THREADS_MAX 64
2757#endif
2758# 106 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2759
2760#if __POSIX_VISIBLE >= 200112
2761#define _POSIX_HOST_NAME_MAX 255
2762#define _POSIX_LOGIN_NAME_MAX 9
2763#define _POSIX_SS_REPL_MAX 4
2764#define _POSIX_SYMLINK_MAX 255
2765#define _POSIX_SYMLOOP_MAX 8
2766#define _POSIX_TRACE_EVENT_NAME_MAX 30
2767#define _POSIX_TRACE_NAME_MAX 8
2768#define _POSIX_TRACE_SYS_MAX 8
2769#define _POSIX_TRACE_USER_EVENT_MAX 32
2770#define _POSIX_TTY_NAME_MAX 9
2771
2772#define _POSIX_RE_DUP_MAX _POSIX2_RE_DUP_MAX
2773#endif
2774# 121 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2775
2776#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809
2777#define NL_ARGMAX 65536 /* max # of position args for printf */
2778#define NL_MSGMAX 32767
2779#define NL_SETMAX 255
2780#define NL_TEXTMAX 2048
2781#endif
2782# 128 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2783
2784#if __XSI_VISIBLE
2785#define _XOPEN_IOV_MAX 16
2786#define _XOPEN_NAME_MAX 255
2787#define _XOPEN_PATH_MAX 1024
2788#define PASS_MAX 128 /* _PASSWORD_LEN from <pwd.h> */
2789
2790#define NL_LANGMAX 31 /* max LANG name length */
2791#define NL_NMAX 1
2792#endif
2793# 138 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2794
2795#define MB_LEN_MAX 6 /* 31-bit UTF-8 */
2796
2797#if 0 /* expanded by -frewrite-includes */
2798#include <sys/limits.h>
2799#endif /* expanded by -frewrite-includes */
2800# 141 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2801# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 1 3 4
2802/*-
2803 * Copyright (c) 1988, 1993
2804 * The Regents of the University of California. All rights reserved.
2805 *
2806 * Redistribution and use in source and binary forms, with or without
2807 * modification, are permitted provided that the following conditions
2808 * are met:
2809 * 1. Redistributions of source code must retain the above copyright
2810 * notice, this list of conditions and the following disclaimer.
2811 * 2. Redistributions in binary form must reproduce the above copyright
2812 * notice, this list of conditions and the following disclaimer in the
2813 * documentation and/or other materials provided with the distribution.
2814 * 3. Neither the name of the University nor the names of its contributors
2815 * may be used to endorse or promote products derived from this software
2816 * without specific prior written permission.
2817 *
2818 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2819 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2820 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2821 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2822 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2823 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2824 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2825 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2826 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2827 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2828 * SUCH DAMAGE.
2829 *
2830 * $FreeBSD$
2831 */
2832
2833#ifndef _SYS_LIMITS_H_
2834#define _SYS_LIMITS_H_
2835
2836#if 0 /* expanded by -frewrite-includes */
2837#include <sys/cdefs.h>
2838#endif /* expanded by -frewrite-includes */
2839# 35 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2840# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2841#if 0 /* expanded by -frewrite-includes */
2842#include <machine/_limits.h>
2843#endif /* expanded by -frewrite-includes */
2844# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2845# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2846
2847#define CHAR_BIT __CHAR_BIT /* number of bits in a char */
2848
2849#define SCHAR_MAX __SCHAR_MAX /* max value for a signed char */
2850#define SCHAR_MIN __SCHAR_MIN /* min value for a signed char */
2851
2852#define UCHAR_MAX __UCHAR_MAX /* max value for an unsigned char */
2853
2854#ifdef __CHAR_UNSIGNED__
2855#define CHAR_MAX UCHAR_MAX /* max value for a char */
2856#define CHAR_MIN 0 /* min value for a char */
2857#else
2858# 49 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2859#define CHAR_MAX SCHAR_MAX
2860#define CHAR_MIN SCHAR_MIN
2861#endif
2862# 52 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2863
2864#define USHRT_MAX __USHRT_MAX /* max value for an unsigned short */
2865#define SHRT_MAX __SHRT_MAX /* max value for a short */
2866#define SHRT_MIN __SHRT_MIN /* min value for a short */
2867
2868#define UINT_MAX __UINT_MAX /* max value for an unsigned int */
2869#define INT_MAX __INT_MAX /* max value for an int */
2870#define INT_MIN __INT_MIN /* min value for an int */
2871
2872#define ULONG_MAX __ULONG_MAX /* max for an unsigned long */
2873#define LONG_MAX __LONG_MAX /* max for a long */
2874#define LONG_MIN __LONG_MIN /* min for a long */
2875
2876#ifdef __LONG_LONG_SUPPORTED
2877#define ULLONG_MAX __ULLONG_MAX /* max for an unsigned long long */
2878#define LLONG_MAX __LLONG_MAX /* max for a long long */
2879#define LLONG_MIN __LLONG_MIN /* min for a long long */
2880#endif
2881# 70 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2882
2883#if __POSIX_VISIBLE || __XSI_VISIBLE
2884#define SSIZE_MAX __SSIZE_MAX /* max value for an ssize_t */
2885#endif
2886# 74 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2887
2888#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
2889#define SIZE_T_MAX __SIZE_T_MAX /* max value for a size_t */
2890
2891#define OFF_MAX __OFF_MAX /* max value for an off_t */
2892#define OFF_MIN __OFF_MIN /* min value for an off_t */
2893#endif
2894# 81 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2895
2896#if __BSD_VISIBLE
2897#define GID_MAX UINT_MAX /* max value for a gid_t */
2898#define UID_MAX UINT_MAX /* max value for a uid_t */
2899
2900#define UQUAD_MAX (__UQUAD_MAX) /* max value for a uquad_t */
2901#define QUAD_MAX (__QUAD_MAX) /* max value for a quad_t */
2902#define QUAD_MIN (__QUAD_MIN) /* min value for a quad_t */
2903#endif
2904# 90 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2905
2906#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809
2907#define LONG_BIT __LONG_BIT
2908#define WORD_BIT __WORD_BIT
2909#endif
2910# 95 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2911
2912#if __POSIX_VISIBLE
2913#define MQ_PRIO_MAX 64
2914#endif
2915# 99 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2916
2917#endif /* !_SYS_LIMITS_H_ */
2918# 101 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/limits.h" 3 4
2919# 142 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 2 3 4
2920
2921#if __POSIX_VISIBLE
2922#if 0 /* expanded by -frewrite-includes */
2923#include <sys/syslimits.h>
2924#endif /* expanded by -frewrite-includes */
2925# 144 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
2926# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/syslimits.h" 1 3 4
2927/*-
2928 * Copyright (c) 1988, 1993
2929 * The Regents of the University of California. All rights reserved.
2930 *
2931 * Redistribution and use in source and binary forms, with or without
2932 * modification, are permitted provided that the following conditions
2933 * are met:
2934 * 1. Redistributions of source code must retain the above copyright
2935 * notice, this list of conditions and the following disclaimer.
2936 * 2. Redistributions in binary form must reproduce the above copyright
2937 * notice, this list of conditions and the following disclaimer in the
2938 * documentation and/or other materials provided with the distribution.
2939 * 3. Neither the name of the University nor the names of its contributors
2940 * may be used to endorse or promote products derived from this software
2941 * without specific prior written permission.
2942 *
2943 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2944 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2945 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2946 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2947 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2948 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2949 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2950 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2951 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2952 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2953 * SUCH DAMAGE.
2954 *
2955 * @(#)syslimits.h 8.1 (Berkeley) 6/2/93
2956 * $FreeBSD$
2957 */
2958
2959#ifndef _SYS_SYSLIMITS_H_
2960#define _SYS_SYSLIMITS_H_
2961
2962#if !defined(_KERNEL) && !defined(_LIMITS_H_) && !defined(_SYS_PARAM_H_)
2963#ifndef _SYS_CDEFS_H_
2964#error this file needs sys/cdefs.h as a prerequisite
2965#endif
2966# 40 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/syslimits.h" 3 4
2967#ifdef __CC_SUPPORTS_WARNING
2968#warning "No user-serviceable parts inside."
2969#endif
2970# 43 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/syslimits.h" 3 4
2971#endif
2972# 44 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/syslimits.h" 3 4
2973
2974/*
2975 * Do not add any new variables here. (See the comment at the end of
2976 * the file for why.)
2977 */
2978#define ARG_MAX 262144 /* max bytes for an exec function */
2979#ifndef CHILD_MAX
2980#define CHILD_MAX 40 /* max simultaneous processes */
2981#endif
2982# 53 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/syslimits.h" 3 4
2983#define LINK_MAX 32767 /* max file link count */
2984#define MAX_CANON 255 /* max bytes in term canon input line */
2985#define MAX_INPUT 255 /* max bytes in terminal input */
2986#define NAME_MAX 255 /* max bytes in a file name */
2987#ifndef NGROUPS_MAX
2988#define NGROUPS_MAX 1023 /* max supplemental group id's */
2989#endif
2990# 60 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/syslimits.h" 3 4
2991#ifndef OPEN_MAX
2992#define OPEN_MAX 64 /* max open files per process */
2993#endif
2994# 63 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/syslimits.h" 3 4
2995#define PATH_MAX 1024 /* max bytes in pathname */
2996#define PIPE_BUF 512 /* max bytes for atomic pipe writes */
2997#define IOV_MAX 1024 /* max elements in i/o vector */
2998
2999/*
3000 * We leave the following values undefined to force applications to either
3001 * assume conservative values or call sysconf() to get the current value.
3002 *
3003 * HOST_NAME_MAX
3004 *
3005 * (We should do this for most of the values currently defined here,
3006 * but many programs are not prepared to deal with this yet.)
3007 */
3008#endif
3009# 77 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/syslimits.h" 3 4
3010# 145 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 2 3 4
3011#endif
3012# 146 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
3013
3014#endif /* !_LIMITS_H_ */
3015# 148 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/limits.h" 3 4
3016# 23 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
3017#if 0 /* expanded by -frewrite-includes */
3018#include <memory.h>
3019#endif /* expanded by -frewrite-includes */
3020# 23 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
3021# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/memory.h" 1 3 4
3022/*
3023 * Copyright (c) 1988, 1993
3024 * The Regents of the University of California. All rights reserved.
3025 *
3026 * Redistribution and use in source and binary forms, with or without
3027 * modification, are permitted provided that the following conditions
3028 * are met:
3029 * 1. Redistributions of source code must retain the above copyright
3030 * notice, this list of conditions and the following disclaimer.
3031 * 2. Redistributions in binary form must reproduce the above copyright
3032 * notice, this list of conditions and the following disclaimer in the
3033 * documentation and/or other materials provided with the distribution.
3034 * 3. Neither the name of the University nor the names of its contributors
3035 * may be used to endorse or promote products derived from this software
3036 * without specific prior written permission.
3037 *
3038 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
3039 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3040 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3041 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3042 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3043 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3044 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3045 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3046 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3047 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3048 * SUCH DAMAGE.
3049 *
3050 * @(#)memory.h 8.1 (Berkeley) 6/2/93
3051 *
3052 * $FreeBSD$
3053 */
3054
3055#if 0 /* expanded by -frewrite-includes */
3056#include <string.h>
3057#endif /* expanded by -frewrite-includes */
3058# 34 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/memory.h" 3 4
3059# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 1 3 4
3060/*-
3061 * Copyright (c) 1990, 1993
3062 * The Regents of the University of California. All rights reserved.
3063 *
3064 * Redistribution and use in source and binary forms, with or without
3065 * modification, are permitted provided that the following conditions
3066 * are met:
3067 * 1. Redistributions of source code must retain the above copyright
3068 * notice, this list of conditions and the following disclaimer.
3069 * 2. Redistributions in binary form must reproduce the above copyright
3070 * notice, this list of conditions and the following disclaimer in the
3071 * documentation and/or other materials provided with the distribution.
3072 * 3. Neither the name of the University nor the names of its contributors
3073 * may be used to endorse or promote products derived from this software
3074 * without specific prior written permission.
3075 *
3076 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
3077 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3078 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3079 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3080 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3081 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3082 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3083 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3084 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3085 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3086 * SUCH DAMAGE.
3087 *
3088 * @(#)string.h 8.1 (Berkeley) 6/2/93
3089 * $FreeBSD$
3090 */
3091
3092#ifndef _STRING_H_
3093#define _STRING_H_
3094
3095#if 0 /* expanded by -frewrite-includes */
3096#include <sys/cdefs.h>
3097#endif /* expanded by -frewrite-includes */
3098# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3099# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3100#if 0 /* expanded by -frewrite-includes */
3101#include <sys/_null.h>
3102#endif /* expanded by -frewrite-includes */
3103# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3104# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3105#if 0 /* expanded by -frewrite-includes */
3106#include <sys/_types.h>
3107#endif /* expanded by -frewrite-includes */
3108# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3109# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3110
3111/*
3112 * Prototype functions which were historically defined in <string.h>, but
3113 * are required by POSIX to be prototyped in <strings.h>.
3114 */
3115#if __BSD_VISIBLE
3116#if 0 /* expanded by -frewrite-includes */
3117#include <strings.h>
3118#endif /* expanded by -frewrite-includes */
3119# 45 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3120# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 1 3 4
3121/*-
3122 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
3123 * All rights reserved.
3124 *
3125 * Redistribution and use in source and binary forms, with or without
3126 * modification, are permitted provided that the following conditions
3127 * are met:
3128 * 1. Redistributions of source code must retain the above copyright
3129 * notice, this list of conditions and the following disclaimer.
3130 * 2. Redistributions in binary form must reproduce the above copyright
3131 * notice, this list of conditions and the following disclaimer in the
3132 * documentation and/or other materials provided with the distribution.
3133 *
3134 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
3135 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3136 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3137 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
3138 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3139 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3140 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3141 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3142 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3143 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3144 * SUCH DAMAGE.
3145 *
3146 * $FreeBSD$
3147 */
3148
3149#ifndef _STRINGS_H_
3150#define _STRINGS_H_
3151
3152#if 0 /* expanded by -frewrite-includes */
3153#include <sys/cdefs.h>
3154#endif /* expanded by -frewrite-includes */
3155# 32 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3156# 33 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3157#if 0 /* expanded by -frewrite-includes */
3158#include <sys/_types.h>
3159#endif /* expanded by -frewrite-includes */
3160# 33 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3161# 34 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3162
3163#ifndef _SIZE_T_DECLARED
3164typedef __size_t size_t;
3165#define _SIZE_T_DECLARED
3166#endif
3167# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3168
3169__BEGIN_DECLS
3170#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
3171int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */
3172void bcopy(const void *, void *, size_t); /* LEGACY */
3173void bzero(void *, size_t); /* LEGACY */
3174#endif
3175# 46 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3176#if __BSD_VISIBLE
3177void explicit_bzero(void *, size_t);
3178#endif
3179# 49 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3180#if __XSI_VISIBLE
3181int ffs(int) __pure2;
3182#endif
3183# 52 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3184#if __BSD_VISIBLE
3185int ffsl(long) __pure2;
3186int ffsll(long long) __pure2;
3187int fls(int) __pure2;
3188int flsl(long) __pure2;
3189int flsll(long long) __pure2;
3190#endif
3191# 59 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3192#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
3193char *index(const char *, int) __pure; /* LEGACY */
3194char *rindex(const char *, int) __pure; /* LEGACY */
3195#endif
3196# 63 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3197int strcasecmp(const char *, const char *) __pure;
3198int strncasecmp(const char *, const char *, size_t) __pure;
3199
3200#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
3201#if 0 /* expanded by -frewrite-includes */
3202#include <xlocale/_strings.h>
3203#endif /* expanded by -frewrite-includes */
3204# 67 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3205# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_strings.h" 1 3 4
3206/*-
3207 * Copyright (c) 2011, 2012 The FreeBSD Foundation
3208 * All rights reserved.
3209 *
3210 * Redistribution and use in source and binary forms, with or without
3211 * modification, are permitted provided that the following conditions
3212 * are met:
3213 * 1. Redistributions of source code must retain the above copyright
3214 * notice, this list of conditions and the following disclaimer.
3215 * 2. Redistributions in binary form must reproduce the above copyright
3216 * notice, this list of conditions and the following disclaimer in the
3217 * documentation and/or other materials provided with the distribution.
3218 *
3219 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
3220 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3221 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3222 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
3223 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3224 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3225 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3226 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3227 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3228 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3229 * SUCH DAMAGE.
3230 *
3231 * $FreeBSD$
3232 */
3233
3234#ifndef _LOCALE_T_DEFINED
3235#define _LOCALE_T_DEFINED
3236typedef struct _xlocale *locale_t;
3237#endif
3238# 33 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_strings.h" 3 4
3239
3240/*
3241 * This file is included from both strings.h and xlocale.h. We need to expose
3242 * the declarations unconditionally if we are included from xlocale.h, but only
3243 * if we are in POSIX2008 mode if included from string.h.
3244 */
3245
3246#ifndef _XLOCALE_STRINGS1_H
3247#define _XLOCALE_STRINGS1_H
3248
3249/*
3250 * POSIX2008 functions
3251 */
3252int strcasecmp_l(const char *, const char *, locale_t);
3253int strncasecmp_l(const char *, const char *, size_t, locale_t);
3254#endif /* _XLOCALE_STRINGS1_H */
3255# 49 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_strings.h" 3 4
3256# 68 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 2 3 4
3257#endif
3258# 69 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3259__END_DECLS
3260
3261#endif /* _STRINGS_H_ */
3262# 72 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/strings.h" 3 4
3263# 46 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 2 3 4
3264#endif
3265# 47 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3266
3267#ifndef _SIZE_T_DECLARED
3268typedef __size_t size_t;
3269#define _SIZE_T_DECLARED
3270#endif
3271# 52 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3272
3273__BEGIN_DECLS
3274#if __XSI_VISIBLE >= 600
3275void *memccpy(void * __restrict, const void * __restrict, int, size_t);
3276#endif
3277# 57 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3278void *memchr(const void *, int, size_t) __pure;
3279#if __BSD_VISIBLE
3280void *memrchr(const void *, int, size_t) __pure;
3281#endif
3282# 61 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3283int memcmp(const void *, const void *, size_t) __pure;
3284void *memcpy(void * __restrict, const void * __restrict, size_t);
3285#if __BSD_VISIBLE
3286void *memmem(const void *, size_t, const void *, size_t) __pure;
3287#endif
3288# 66 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3289void *memmove(void *, const void *, size_t);
3290void *memset(void *, int, size_t);
3291#if __POSIX_VISIBLE >= 200809
3292char *stpcpy(char * __restrict, const char * __restrict);
3293char *stpncpy(char * __restrict, const char * __restrict, size_t);
3294#endif
3295# 72 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3296#if __BSD_VISIBLE
3297char *strcasestr(const char *, const char *) __pure;
3298#endif
3299# 75 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3300char *strcat(char * __restrict, const char * __restrict);
3301char *strchr(const char *, int) __pure;
3302#if __BSD_VISIBLE
3303char *strchrnul(const char*, int) __pure;
3304#endif
3305# 80 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3306int strcmp(const char *, const char *) __pure;
3307int strcoll(const char *, const char *);
3308char *strcpy(char * __restrict, const char * __restrict);
3309size_t strcspn(const char *, const char *) __pure;
3310#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
3311char *strdup(const char *) __malloc_like;
3312#endif
3313# 87 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3314char *strerror(int);
3315#if __POSIX_VISIBLE >= 200112
3316int strerror_r(int, char *, size_t);
3317#endif
3318# 91 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3319#if __BSD_VISIBLE
3320size_t strlcat(char * __restrict, const char * __restrict, size_t);
3321size_t strlcpy(char * __restrict, const char * __restrict, size_t);
3322#endif
3323# 95 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3324size_t strlen(const char *) __pure;
3325#if __BSD_VISIBLE
3326void strmode(int, char *);
3327#endif
3328# 99 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3329char *strncat(char * __restrict, const char * __restrict, size_t);
3330int strncmp(const char *, const char *, size_t) __pure;
3331char *strncpy(char * __restrict, const char * __restrict, size_t);
3332#if __POSIX_VISIBLE >= 200809
3333char *strndup(const char *, size_t) __malloc_like;
3334size_t strnlen(const char *, size_t) __pure;
3335#endif
3336# 106 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3337#if __BSD_VISIBLE
3338char *strnstr(const char *, const char *, size_t) __pure;
3339#endif
3340# 109 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3341char *strpbrk(const char *, const char *) __pure;
3342char *strrchr(const char *, int) __pure;
3343#if __BSD_VISIBLE
3344char *strsep(char **, const char *);
3345#endif
3346# 114 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3347#if __POSIX_VISIBLE >= 200809
3348char *strsignal(int);
3349#endif
3350# 117 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3351size_t strspn(const char *, const char *) __pure;
3352char *strstr(const char *, const char *) __pure;
3353char *strtok(char * __restrict, const char * __restrict);
3354#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
3355char *strtok_r(char *, const char *, char **);
3356#endif
3357# 123 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3358size_t strxfrm(char * __restrict, const char * __restrict, size_t);
3359#if __BSD_VISIBLE
3360
3361#ifndef _SWAB_DECLARED
3362#define _SWAB_DECLARED
3363
3364#ifndef _SSIZE_T_DECLARED
3365typedef __ssize_t ssize_t;
3366#define _SSIZE_T_DECLARED
3367#endif /* _SIZE_T_DECLARED */
3368# 133 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3369
3370void swab(const void * __restrict, void * __restrict, ssize_t);
3371#endif /* _SWAB_DECLARED */
3372# 136 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3373
3374#if __has_feature(capabilities)
3375__capability const void *
3376 memchr_c_const(__capability const void *, int, size_t) __pure;
3377__capability void
3378 *memchr_c(__capability const void *, int, size_t) __pure;
3379int memcmp_c(__capability const void *, __capability const void *, size_t)
3380 __pure;
3381__capability void
3382 *memcpy_c(__capability void * __restrict,
3383 __capability const void * __restrict, size_t);
3384void *memcpy_c_fromcap(void * __restrict,
3385 __capability const void * __restrict, size_t);
3386__capability void
3387 *memcpy_c_tocap(__capability void * __restrict,
3388 const void * __restrict, size_t);
3389__capability void
3390 *memmove_c(__capability void * __restrict,
3391 __capability const void * __restrict, size_t);
3392__capability void
3393 *memset_c(__capability void *, int, size_t);
3394
3395__capability char
3396 *strchr_c(__capability const char *, int) __pure;
3397int strcmp_c(__capability const char *,
3398 __capability const char *s2) __pure;
3399__capability char
3400 *strcpy_c(__capability char * __restrict,
3401 __capability const char * __restrict);
3402int strncmp_c(__capability const char *, __capability const char *,
3403 size_t) __pure;
3404__capability char
3405*strncpy_c(__capability char * __restrict, __capability const char * __restrict,
3406 size_t);
3407char *strncpy_c_fromcap(char * __restrict,
3408 __capability const char * __restrict, size_t);
3409__capability char
3410 *strncpy_c_tocap(__capability char * __restrict,
3411 const char * __restrict, size_t);
3412size_t strnlen_c(__capability const char *, size_t) __pure;
3413#endif
3414# 177 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3415
3416int timingsafe_bcmp(const void *, const void *, size_t);
3417int timingsafe_memcmp(const void *, const void *, size_t);
3418#endif /* __BSD_VISIBLE */
3419# 181 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3420
3421#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
3422#if 0 /* expanded by -frewrite-includes */
3423#include <xlocale/_string.h>
3424#endif /* expanded by -frewrite-includes */
3425# 183 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3426# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_string.h" 1 3 4
3427/*-
3428 * Copyright (c) 2011, 2012 The FreeBSD Foundation
3429 * All rights reserved.
3430 *
3431 * Redistribution and use in source and binary forms, with or without
3432 * modification, are permitted provided that the following conditions
3433 * are met:
3434 * 1. Redistributions of source code must retain the above copyright
3435 * notice, this list of conditions and the following disclaimer.
3436 * 2. Redistributions in binary form must reproduce the above copyright
3437 * notice, this list of conditions and the following disclaimer in the
3438 * documentation and/or other materials provided with the distribution.
3439 *
3440 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
3441 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3442 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3443 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
3444 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3445 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3446 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3447 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3448 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3449 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3450 * SUCH DAMAGE.
3451 *
3452 * $FreeBSD$
3453 */
3454
3455#ifndef _LOCALE_T_DEFINED
3456#define _LOCALE_T_DEFINED
3457typedef struct _xlocale *locale_t;
3458#endif
3459# 33 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_string.h" 3 4
3460
3461/*
3462 * This file is included from both string.h and xlocale.h. We need to expose
3463 * the declarations unconditionally if we are included from xlocale.h, but only
3464 * if we are in POSIX2008 mode if included from string.h.
3465 */
3466
3467#ifndef _XLOCALE_STRING1_H
3468#define _XLOCALE_STRING1_H
3469
3470/*
3471 * POSIX2008 functions
3472 */
3473int strcoll_l(const char *, const char *, locale_t);
3474size_t strxfrm_l(char *, const char *, size_t, locale_t);
3475#endif /* _XLOCALE_STRING1_H */
3476# 49 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_string.h" 3 4
3477
3478/*
3479 * xlocale extensions
3480 */
3481#ifdef _XLOCALE_H_
3482#ifndef _XLOCALE_STRING2_H
3483#define _XLOCALE_STRING2_H
3484char *strcasestr_l(const char *, const char *, locale_t);
3485
3486#endif /* _XLOCALE_STRING2_H */
3487# 59 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_string.h" 3 4
3488#endif /* _XLOCALE_H_ */
3489# 60 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_string.h" 3 4
3490# 184 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 2 3 4
3491#endif
3492# 185 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3493
3494#if __EXT1_VISIBLE
3495
3496#ifndef _RSIZE_T_DEFINED
3497#define _RSIZE_T_DEFINED
3498typedef size_t rsize_t;
3499#endif
3500# 192 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3501
3502#ifndef _ERRNO_T_DEFINED
3503#define _ERRNO_T_DEFINED
3504typedef int errno_t;
3505#endif
3506# 197 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3507
3508/* ISO/IEC 9899:2011 K.3.7.4.1.1 */
3509errno_t memset_s(void *, rsize_t, int, rsize_t);
3510#endif /* __EXT1_VISIBLE */
3511# 201 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3512__END_DECLS
3513
3514#endif /* _STRING_H_ */
3515# 204 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/string.h" 3 4
3516# 35 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/memory.h" 2 3 4
3517# 24 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
3518#if 0 /* expanded by -frewrite-includes */
3519#include <string.h>
3520#endif /* expanded by -frewrite-includes */
3521# 24 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
3522# 25 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
3523
3524#if 0 /* expanded by -frewrite-includes */
3525#include "global.h"
3526#endif /* expanded by -frewrite-includes */
3527# 26 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
3528# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 1
3529
3530/*!
3531 ************************************************************************
3532 * \file
3533 * global.h
3534 *
3535 * \brief
3536 * global definitions for H.264 encoder.
3537 *
3538 * \author
3539 * Copyright (C) 1999 Telenor Satellite Services,Norway
3540 * Ericsson Radio Systems, Sweden
3541 *
3542 * Inge Lille-Langoy <inge.lille-langoy@telenor.com>
3543 *
3544 * Telenor Satellite Services
3545 * Keysers gt.13 tel.: +47 23 13 86 98
3546 * N-0130 Oslo,Norway fax.: +47 22 77 79 80
3547 *
3548 * Rickard Sjoberg <rickard.sjoberg@era.ericsson.se>
3549 *
3550 * Ericsson Radio Systems
3551 * KI/ERA/T/VV
3552 * 164 80 Stockholm, Sweden
3553 *
3554 ************************************************************************
3555 */
3556#ifndef _GLOBAL_H_
3557#define _GLOBAL_H_
3558
3559#if 0 /* expanded by -frewrite-includes */
3560#include <stdio.h>
3561#endif /* expanded by -frewrite-includes */
3562# 31 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
3563# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 1 3 4
3564/*-
3565 * Copyright (c) 1990, 1993
3566 * The Regents of the University of California. All rights reserved.
3567 *
3568 * This code is derived from software contributed to Berkeley by
3569 * Chris Torek.
3570 *
3571 * Redistribution and use in source and binary forms, with or without
3572 * modification, are permitted provided that the following conditions
3573 * are met:
3574 * 1. Redistributions of source code must retain the above copyright
3575 * notice, this list of conditions and the following disclaimer.
3576 * 2. Redistributions in binary form must reproduce the above copyright
3577 * notice, this list of conditions and the following disclaimer in the
3578 * documentation and/or other materials provided with the distribution.
3579 * 3. Neither the name of the University nor the names of its contributors
3580 * may be used to endorse or promote products derived from this software
3581 * without specific prior written permission.
3582 *
3583 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
3584 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3585 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3586 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3587 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3588 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3589 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3590 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3591 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3592 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3593 * SUCH DAMAGE.
3594 *
3595 * @(#)stdio.h 8.5 (Berkeley) 4/29/95
3596 * $FreeBSD$
3597 */
3598
3599#ifndef _STDIO_H_
3600#define _STDIO_H_
3601
3602#if 0 /* expanded by -frewrite-includes */
3603#include <sys/cdefs.h>
3604#endif /* expanded by -frewrite-includes */
3605# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3606# 40 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3607#if 0 /* expanded by -frewrite-includes */
3608#include <sys/_null.h>
3609#endif /* expanded by -frewrite-includes */
3610# 40 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3611# 41 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3612#if 0 /* expanded by -frewrite-includes */
3613#include <sys/_types.h>
3614#endif /* expanded by -frewrite-includes */
3615# 41 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3616# 42 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3617
3618__NULLABILITY_PRAGMA_PUSH
3619
3620typedef __off_t fpos_t;
3621
3622#ifndef _SIZE_T_DECLARED
3623typedef __size_t size_t;
3624#define _SIZE_T_DECLARED
3625#endif
3626# 51 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3627
3628#if __POSIX_VISIBLE >= 200809
3629#ifndef _OFF_T_DECLARED
3630#define _OFF_T_DECLARED
3631typedef __off_t off_t;
3632#endif
3633# 57 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3634#ifndef _SSIZE_T_DECLARED
3635#define _SSIZE_T_DECLARED
3636typedef __ssize_t ssize_t;
3637#endif
3638# 61 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3639#endif
3640# 62 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3641
3642#ifndef _OFF64_T_DECLARED
3643#define _OFF64_T_DECLARED
3644typedef __off64_t off64_t;
3645#endif
3646# 67 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3647
3648#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
3649#ifndef _VA_LIST_DECLARED
3650typedef __va_list va_list;
3651#define _VA_LIST_DECLARED
3652#endif
3653# 73 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3654#endif
3655# 74 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3656
3657#define _FSTDIO /* Define for new stdio with functions. */
3658
3659/*
3660 * NB: to fit things in six character monocase externals, the stdio
3661 * code uses the prefix `__s' for stdio objects, typically followed
3662 * by a three-character attempt at a mnemonic.
3663 */
3664
3665/* stdio buffers */
3666struct __sbuf {
3667 unsigned char *_base;
3668 int _size;
3669};
3670
3671/*
3672 * stdio state variables.
3673 *
3674 * The following always hold:
3675 *
3676 * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
3677 * _lbfsize is -_bf._size, else _lbfsize is 0
3678 * if _flags&__SRD, _w is 0
3679 * if _flags&__SWR, _r is 0
3680 *
3681 * This ensures that the getc and putc macros (or inline functions) never
3682 * try to write or read from a file that is in `read' or `write' mode.
3683 * (Moreover, they can, and do, automatically switch from read mode to
3684 * write mode, and back, on "r+" and "w+" files.)
3685 *
3686 * _lbfsize is used only to make the inline line-buffered output stream
3687 * code as compact as possible.
3688 *
3689 * _ub, _up, and _ur are used when ungetc() pushes back more characters
3690 * than fit in the current _bf, or when ungetc() pushes back a character
3691 * that does not match the previous one in _bf. When this happens,
3692 * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
3693 * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
3694 *
3695 * Certain members of __sFILE are accessed directly via macros or
3696 * inline functions. To preserve ABI compat, these members must not
3697 * be disturbed. These members are marked below with (*).
3698 */
3699struct __sFILE {
3700 unsigned char *_p; /* (*) current position in (some) buffer */
3701 int _r; /* (*) read space left for getc() */
3702 int _w; /* (*) write space left for putc() */
3703 short _flags; /* (*) flags, below; this FILE is free if 0 */
3704 short _file; /* (*) fileno, if Unix descriptor, else -1 */
3705 struct __sbuf _bf; /* (*) the buffer (at least 1 byte, if !NULL) */
3706 int _lbfsize; /* (*) 0 or -_bf._size, for inline putc */
3707
3708 /* operations */
3709 void *_cookie; /* (*) cookie passed to io functions */
3710 int (* _Nullable _close)(void *);
3711 int (* _Nullable _read)(void *, char *, int);
3712 fpos_t (* _Nullable _seek)(void *, fpos_t, int);
3713 int (* _Nullable _write)(void *, const char *, int);
3714
3715 /* separate buffer for long sequences of ungetc() */
3716 struct __sbuf _ub; /* ungetc buffer */
3717 unsigned char *_up; /* saved _p when _p is doing ungetc data */
3718 int _ur; /* saved _r when _r is counting ungetc data */
3719
3720 /* tricks to meet minimum requirements even when malloc() fails */
3721 unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
3722 unsigned char _nbuf[1]; /* guarantee a getc() buffer */
3723
3724 /* separate buffer for fgetln() when line crosses buffer boundary */
3725 struct __sbuf _lb; /* buffer for fgetln() */
3726
3727 /* Unix stdio files get aligned to block boundaries on fseek() */
3728 int _blksize; /* stat.st_blksize (may be != _bf._size) */
3729 fpos_t _offset; /* current lseek offset */
3730
3731 struct pthread_mutex *_fl_mutex; /* used for MT-safety */
3732 struct pthread *_fl_owner; /* current owner */
3733 int _fl_count; /* recursive lock count */
3734 int _orientation; /* orientation for fwide() */
3735 __mbstate_t _mbstate; /* multibyte conversion state */
3736 int _flags2; /* additional flags */
3737};
3738#ifndef _STDFILE_DECLARED
3739#define _STDFILE_DECLARED
3740typedef struct __sFILE FILE;
3741#endif
3742# 160 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3743#ifndef _STDSTREAM_DECLARED
3744__BEGIN_DECLS
3745extern FILE *__stdinp;
3746extern FILE *__stdoutp;
3747extern FILE *__stderrp;
3748__END_DECLS
3749#define _STDSTREAM_DECLARED
3750#endif
3751# 168 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3752
3753#define __SLBF 0x0001 /* line buffered */
3754#define __SNBF 0x0002 /* unbuffered */
3755#define __SRD 0x0004 /* OK to read */
3756#define __SWR 0x0008 /* OK to write */
3757 /* RD and WR are never simultaneously asserted */
3758#define __SRW 0x0010 /* open for reading & writing */
3759#define __SEOF 0x0020 /* found EOF */
3760#define __SERR 0x0040 /* found error */
3761#define __SMBF 0x0080 /* _bf._base is from malloc */
3762#define __SAPP 0x0100 /* fdopen()ed in append mode */
3763#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
3764#define __SOPT 0x0400 /* do fseek() optimization */
3765#define __SNPT 0x0800 /* do not do fseek() optimization */
3766#define __SOFF 0x1000 /* set iff _offset is in fact correct */
3767#define __SMOD 0x2000 /* true => fgetln modified _p text */
3768#define __SALC 0x4000 /* allocate string space dynamically */
3769#define __SIGN 0x8000 /* ignore this file in _fwalk */
3770
3771#define __S2OAP 0x0001 /* O_APPEND mode is set */
3772
3773/*
3774 * The following three definitions are for ANSI C, which took them
3775 * from System V, which brilliantly took internal interface macros and
3776 * made them official arguments to setvbuf(), without renaming them.
3777 * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
3778 *
3779 * Although numbered as their counterparts above, the implementation
3780 * does not rely on this.
3781 */
3782#define _IOFBF 0 /* setvbuf should set fully buffered */
3783#define _IOLBF 1 /* setvbuf should set line buffered */
3784#define _IONBF 2 /* setvbuf should set unbuffered */
3785
3786#define BUFSIZ 1024 /* size of buffer used by setbuf */
3787#define EOF (-1)
3788
3789/*
3790 * FOPEN_MAX is a minimum maximum, and is the number of streams that
3791 * stdio can provide without attempting to allocate further resources
3792 * (which could fail). Do not use this for anything.
3793 */
3794 /* must be == _POSIX_STREAM_MAX <limits.h> */
3795#ifndef FOPEN_MAX
3796#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */
3797#endif
3798# 214 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3799#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */
3800
3801/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
3802#if __XSI_VISIBLE
3803#define P_tmpdir "/tmp/"
3804#endif
3805# 220 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3806#define L_tmpnam 1024 /* XXX must be == PATH_MAX */
3807#define TMP_MAX 308915776
3808
3809#ifndef SEEK_SET
3810#define SEEK_SET 0 /* set file offset to offset */
3811#endif
3812# 226 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3813#ifndef SEEK_CUR
3814#define SEEK_CUR 1 /* set file offset to current plus offset */
3815#endif
3816# 229 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3817#ifndef SEEK_END
3818#define SEEK_END 2 /* set file offset to EOF plus offset */
3819#endif
3820# 232 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3821
3822#define stdin __stdinp
3823#define stdout __stdoutp
3824#define stderr __stderrp
3825
3826__BEGIN_DECLS
3827#ifdef _XLOCALE_H_
3828#if 0 /* expanded by -frewrite-includes */
3829#include <xlocale/_stdio.h>
3830#endif /* expanded by -frewrite-includes */
3831# 239 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3832# 240 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3833#endif
3834# 241 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3835/*
3836 * Functions defined in ANSI C standard.
3837 */
3838void clearerr(FILE *);
3839int fclose(FILE *);
3840int feof(FILE *);
3841int ferror(FILE *);
3842int fflush(FILE *);
3843int fgetc(FILE *);
3844int fgetpos(FILE * __restrict, fpos_t * __restrict);
3845char *fgets(char * __restrict, int, FILE * __restrict);
3846FILE *fopen(const char * __restrict, const char * __restrict);
3847int fprintf(FILE * __restrict, const char * __restrict, ...) __printflike(2, 3);
3848int fputc(int, FILE *);
3849int fputs(const char * __restrict, FILE * __restrict);
3850size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
3851FILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict);
3852int fscanf(FILE * __restrict, const char * __restrict, ...) __scanflike(2, 3);;
3853int fseek(FILE *, long, int);
3854int fsetpos(FILE *, const fpos_t *);
3855long ftell(FILE *);
3856size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
3857int getc(FILE *);
3858int getchar(void);
3859char *gets(char *);
3860void perror(const char *);
3861int printf(const char * __restrict, ...) __printflike(1, 2);
3862int putc(int, FILE *);
3863int putchar(int);
3864int puts(const char *);
3865int remove(const char *);
3866int rename(const char *, const char *);
3867void rewind(FILE *);
3868int scanf(const char * __restrict, ...) __scanflike(1, 2);
3869void setbuf(FILE * __restrict, char * __restrict);
3870int setvbuf(FILE * __restrict, char * __restrict, int, size_t);
3871int sprintf(char * __restrict, const char * __restrict, ...) __printflike(2, 3);
3872int sscanf(const char * __restrict, const char * __restrict, ...) __scanflike(2, 3);
3873FILE *tmpfile(void);
3874char *tmpnam(char *);
3875int ungetc(int, FILE *);
3876int vfprintf(FILE * __restrict, const char * __restrict,
3877 __va_list);
3878int vprintf(const char * __restrict, __va_list);
3879int vsprintf(char * __restrict, const char * __restrict,
3880 __va_list);
3881
3882#if __ISO_C_VISIBLE >= 1999
3883int snprintf(char * __restrict, size_t, const char * __restrict,
3884 ...) __printflike(3, 4);
3885int vfscanf(FILE * __restrict, const char * __restrict, __va_list)
3886 __scanflike(2, 0);
3887int vscanf(const char * __restrict, __va_list) __scanflike(1, 0);
3888int vsnprintf(char * __restrict, size_t, const char * __restrict,
3889 __va_list) __printflike(3, 0);
3890int vsscanf(const char * __restrict, const char * __restrict, __va_list)
3891 __scanflike(2, 0);
3892#endif
3893# 299 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3894
3895/*
3896 * Functions defined in all versions of POSIX 1003.1.
3897 */
3898#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE <= 199506)
3899#define L_cuserid 17 /* size for cuserid(3); MAXLOGNAME, legacy */
3900#endif
3901# 306 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3902
3903#if __POSIX_VISIBLE
3904#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */
3905
3906char *ctermid(char *);
3907FILE *fdopen(int, const char *);
3908int fileno(FILE *);
3909#endif /* __POSIX_VISIBLE */
3910# 314 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3911
3912#if __POSIX_VISIBLE >= 199209
3913int pclose(FILE *);
3914FILE *popen(const char *, const char *);
3915#endif
3916# 319 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3917
3918#if __POSIX_VISIBLE >= 199506
3919int ftrylockfile(FILE *);
3920void flockfile(FILE *);
3921void funlockfile(FILE *);
3922
3923/*
3924 * These are normally used through macros as defined below, but POSIX
3925 * requires functions as well.
3926 */
3927int getc_unlocked(FILE *);
3928int getchar_unlocked(void);
3929int putc_unlocked(int, FILE *);
3930int putchar_unlocked(int);
3931#endif
3932# 334 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3933#if __BSD_VISIBLE
3934void clearerr_unlocked(FILE *);
3935int feof_unlocked(FILE *);
3936int ferror_unlocked(FILE *);
3937int fileno_unlocked(FILE *);
3938#endif
3939# 340 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3940
3941#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
3942int fseeko(FILE *, __off_t, int);
3943__off_t ftello(FILE *);
3944#endif
3945# 345 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3946
3947#if __BSD_VISIBLE || __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600
3948int getw(FILE *);
3949int putw(int, FILE *);
3950#endif /* BSD or X/Open before issue 6 */
3951# 350 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3952
3953#if __XSI_VISIBLE
3954char *tempnam(const char *, const char *);
3955#endif
3956# 354 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3957
3958#if __POSIX_VISIBLE >= 200809
3959FILE *fmemopen(void * __restrict, size_t, const char * __restrict);
3960ssize_t getdelim(char ** __restrict, size_t * __restrict, int,
3961 FILE * __restrict);
3962FILE *open_memstream(char **, size_t *);
3963int renameat(int, const char *, int, const char *);
3964int vdprintf(int, const char * __restrict, __va_list) __printflike(2, 0);
3965/* _WITH_GETLINE to allow pre 11 sources to build on 11+ systems */
3966ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
3967int dprintf(int, const char * __restrict, ...) __printflike(2, 3);
3968#endif /* __POSIX_VISIBLE >= 200809 */
3969# 366 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
3970
3971/*
3972 * Routines that are purely local.
3973 */
3974#if __BSD_VISIBLE
3975int asprintf(char **, const char *, ...) __printflike(2, 3);
3976char *ctermid_r(char *);
3977void fcloseall(void);
3978int fdclose(FILE *, int *);
3979char *fgetln(FILE *, size_t *);
3980const char *fmtcheck(const char *, const char *) __format_arg(2);
3981int fpurge(FILE *);
3982void setbuffer(FILE *, char *, int);
3983int setlinebuf(FILE *);
3984int vasprintf(char **, const char *, __va_list)
3985 __printflike(2, 0);
3986
3987/*
3988 * The system error table contains messages for the first sys_nerr
3989 * positive errno values. Use strerror() or strerror_r() from <string.h>
3990 * instead.
3991 */
3992extern const int sys_nerr;
3993extern const char * const sys_errlist[];
3994
3995/*
3996 * Stdio function-access interface.
3997 */
3998FILE *funopen(const void *,
3999 int (* _Nullable)(void *, char *, int),
4000 int (* _Nullable)(void *, const char *, int),
4001 fpos_t (* _Nullable)(void *, fpos_t, int),
4002 int (* _Nullable)(void *));
4003#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
4004#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
4005
4006typedef __ssize_t cookie_read_function_t(void *, char *, size_t);
4007typedef __ssize_t cookie_write_function_t(void *, const char *, size_t);
4008typedef int cookie_seek_function_t(void *, off64_t *, int);
4009typedef int cookie_close_function_t(void *);
4010typedef struct {
4011 cookie_read_function_t *read;
4012 cookie_write_function_t *write;
4013 cookie_seek_function_t *seek;
4014 cookie_close_function_t *close;
4015} cookie_io_functions_t;
4016FILE *fopencookie(void *, const char *, cookie_io_functions_t);
4017
4018/*
4019 * Portability hacks. See <sys/types.h>.
4020 */
4021#ifndef _FTRUNCATE_DECLARED
4022#define _FTRUNCATE_DECLARED
4023int ftruncate(int, __off_t);
4024#endif
4025# 421 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4026#ifndef _LSEEK_DECLARED
4027#define _LSEEK_DECLARED
4028__off_t lseek(int, __off_t, int);
4029#endif
4030# 425 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4031#ifndef _MMAP_DECLARED
4032#define _MMAP_DECLARED
4033void *mmap(void *, size_t, int, int, int, __off_t);
4034#endif
4035# 429 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4036#ifndef _TRUNCATE_DECLARED
4037#define _TRUNCATE_DECLARED
4038int truncate(const char *, __off_t);
4039#endif
4040# 433 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4041#endif /* __BSD_VISIBLE */
4042# 434 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4043
4044/*
4045 * Functions internal to the implementation.
4046 */
4047int __srget(FILE *);
4048int __swbuf(int, FILE *);
4049
4050/*
4051 * The __sfoo macros are here so that we can
4052 * define function versions in the C library.
4053 */
4054#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
4055#if defined(__GNUC__) && defined(__STDC__)
4056static __inline int __sputc(int _c, FILE *_p) {
4057 if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
4058 return (*_p->_p++ = _c);
4059 else
4060 return (__swbuf(_c, _p));
4061}
4062#else
4063# 454 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4064/*
4065 * This has been tuned to generate reasonable code on the vax using pcc.
4066 */
4067#define __sputc(c, p) \
4068 (--(p)->_w < 0 ? \
4069 (p)->_w >= (p)->_lbfsize ? \
4070 (*(p)->_p = (c)), *(p)->_p != '\n' ? \
4071 (int)*(p)->_p++ : \
4072 __swbuf('\n', p) : \
4073 __swbuf((int)(c), p) : \
4074 (*(p)->_p = (c), (int)*(p)->_p++))
4075#endif
4076# 466 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4077
4078extern int __isthreaded;
4079
4080#ifndef __cplusplus
4081
4082#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
4083#define __sferror(p) (((p)->_flags & __SERR) != 0)
4084#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
4085#define __sfileno(p) ((p)->_file)
4086
4087
4088#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p))
4089#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))
4090#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p))
4091
4092#if __POSIX_VISIBLE
4093#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p))
4094#endif
4095# 484 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4096
4097#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))
4098#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp))
4099
4100#define getchar() getc(stdin)
4101#define putchar(x) putc(x, stdout)
4102
4103#if __BSD_VISIBLE
4104/*
4105 * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12
4106 * B.8.2.7 for the rationale behind the *_unlocked() macros.
4107 */
4108#define feof_unlocked(p) __sfeof(p)
4109#define ferror_unlocked(p) __sferror(p)
4110#define clearerr_unlocked(p) __sclearerr(p)
4111#define fileno_unlocked(p) __sfileno(p)
4112#endif
4113# 501 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4114#if __POSIX_VISIBLE >= 199506
4115#define getc_unlocked(fp) __sgetc(fp)
4116#define putc_unlocked(x, fp) __sputc(x, fp)
4117
4118#define getchar_unlocked() getc_unlocked(stdin)
4119#define putchar_unlocked(x) putc_unlocked(x, stdout)
4120#endif
4121# 508 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4122#endif /* __cplusplus */
4123# 509 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4124
4125__END_DECLS
4126__NULLABILITY_PRAGMA_POP
4127
4128#endif /* !_STDIO_H_ */
4129# 514 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/stdio.h" 3 4
4130# 32 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 2
4131#if 0 /* expanded by -frewrite-includes */
4132#include <time.h>
4133#endif /* expanded by -frewrite-includes */
4134# 32 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
4135# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 1 3 4
4136/*
4137 * Copyright (c) 1989, 1993
4138 * The Regents of the University of California. All rights reserved.
4139 * (c) UNIX System Laboratories, Inc.
4140 * All or some portions of this file are derived from material licensed
4141 * to the University of California by American Telephone and Telegraph
4142 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
4143 * the permission of UNIX System Laboratories, Inc.
4144 *
4145 * Redistribution and use in source and binary forms, with or without
4146 * modification, are permitted provided that the following conditions
4147 * are met:
4148 * 1. Redistributions of source code must retain the above copyright
4149 * notice, this list of conditions and the following disclaimer.
4150 * 2. Redistributions in binary form must reproduce the above copyright
4151 * notice, this list of conditions and the following disclaimer in the
4152 * documentation and/or other materials provided with the distribution.
4153 * 3. Neither the name of the University nor the names of its contributors
4154 * may be used to endorse or promote products derived from this software
4155 * without specific prior written permission.
4156 *
4157 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4158 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4159 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4160 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4161 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4162 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4163 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4164 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4165 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4166 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4167 * SUCH DAMAGE.
4168 *
4169 * @(#)time.h 8.3 (Berkeley) 1/21/94
4170 */
4171
4172/*
4173 * $FreeBSD$
4174 */
4175
4176#ifndef _TIME_H_
4177#define _TIME_H_
4178
4179#if 0 /* expanded by -frewrite-includes */
4180#include <sys/cdefs.h>
4181#endif /* expanded by -frewrite-includes */
4182# 44 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4183# 45 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4184#if 0 /* expanded by -frewrite-includes */
4185#include <sys/_null.h>
4186#endif /* expanded by -frewrite-includes */
4187# 45 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4188# 46 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4189#if 0 /* expanded by -frewrite-includes */
4190#include <sys/_types.h>
4191#endif /* expanded by -frewrite-includes */
4192# 46 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4193# 47 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4194
4195#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
4196/*
4197 * Frequency of the clock ticks reported by times(). Deprecated - use
4198 * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.)
4199 */
4200#define CLK_TCK 128
4201#endif
4202# 55 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4203
4204/* Frequency of the clock ticks reported by clock(). */
4205#define CLOCKS_PER_SEC 128
4206
4207#ifndef _CLOCK_T_DECLARED
4208typedef __clock_t clock_t;
4209#define _CLOCK_T_DECLARED
4210#endif
4211# 63 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4212
4213#ifndef _TIME_T_DECLARED
4214typedef __time_t time_t;
4215#define _TIME_T_DECLARED
4216#endif
4217# 68 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4218
4219#ifndef _SIZE_T_DECLARED
4220typedef __size_t size_t;
4221#define _SIZE_T_DECLARED
4222#endif
4223# 73 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4224
4225#if __POSIX_VISIBLE >= 199309
4226/*
4227 * New in POSIX 1003.1b-1993.
4228 */
4229#ifndef _CLOCKID_T_DECLARED
4230typedef __clockid_t clockid_t;
4231#define _CLOCKID_T_DECLARED
4232#endif
4233# 82 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4234
4235#ifndef _TIMER_T_DECLARED
4236typedef __timer_t timer_t;
4237#define _TIMER_T_DECLARED
4238#endif
4239# 87 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4240
4241#if 0 /* expanded by -frewrite-includes */
4242#include <sys/timespec.h>
4243#endif /* expanded by -frewrite-includes */
4244# 88 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4245# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/timespec.h" 1 3 4
4246/*-
4247 * Copyright (c) 1982, 1986, 1993
4248 * The Regents of the University of California. All rights reserved.
4249 *
4250 * Redistribution and use in source and binary forms, with or without
4251 * modification, are permitted provided that the following conditions
4252 * are met:
4253 * 1. Redistributions of source code must retain the above copyright
4254 * notice, this list of conditions and the following disclaimer.
4255 * 2. Redistributions in binary form must reproduce the above copyright
4256 * notice, this list of conditions and the following disclaimer in the
4257 * documentation and/or other materials provided with the distribution.
4258 * 3. Neither the name of the University nor the names of its contributors
4259 * may be used to endorse or promote products derived from this software
4260 * without specific prior written permission.
4261 *
4262 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4263 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4264 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4265 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4266 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4267 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4268 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4269 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4270 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4271 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4272 * SUCH DAMAGE.
4273 *
4274 * @(#)time.h 8.5 (Berkeley) 5/4/95
4275 * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
4276 * $FreeBSD$
4277 */
4278
4279#ifndef _SYS_TIMESPEC_H_
4280#define _SYS_TIMESPEC_H_
4281
4282#if 0 /* expanded by -frewrite-includes */
4283#include <sys/cdefs.h>
4284#endif /* expanded by -frewrite-includes */
4285# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/timespec.h" 3 4
4286# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/timespec.h" 3 4
4287#if 0 /* expanded by -frewrite-includes */
4288#include <sys/_timespec.h>
4289#endif /* expanded by -frewrite-includes */
4290# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/timespec.h" 3 4
4291# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timespec.h" 1 3 4
4292/*-
4293 * Copyright (c) 1982, 1986, 1993
4294 * The Regents of the University of California. All rights reserved.
4295 *
4296 * Redistribution and use in source and binary forms, with or without
4297 * modification, are permitted provided that the following conditions
4298 * are met:
4299 * 1. Redistributions of source code must retain the above copyright
4300 * notice, this list of conditions and the following disclaimer.
4301 * 2. Redistributions in binary form must reproduce the above copyright
4302 * notice, this list of conditions and the following disclaimer in the
4303 * documentation and/or other materials provided with the distribution.
4304 * 3. Neither the name of the University nor the names of its contributors
4305 * may be used to endorse or promote products derived from this software
4306 * without specific prior written permission.
4307 *
4308 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4309 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4310 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4311 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4312 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4313 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4314 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4315 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4316 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4317 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4318 * SUCH DAMAGE.
4319 *
4320 * @(#)time.h 8.5 (Berkeley) 5/4/95
4321 * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
4322 * $FreeBSD$
4323 */
4324
4325#ifndef _SYS__TIMESPEC_H_
4326#define _SYS__TIMESPEC_H_
4327
4328#if 0 /* expanded by -frewrite-includes */
4329#include <sys/_types.h>
4330#endif /* expanded by -frewrite-includes */
4331# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timespec.h" 3 4
4332# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timespec.h" 3 4
4333
4334#ifndef _TIME_T_DECLARED
4335typedef __time_t time_t;
4336#define _TIME_T_DECLARED
4337#endif
4338# 43 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timespec.h" 3 4
4339
4340struct timespec {
4341 time_t tv_sec; /* seconds */
4342 long tv_nsec; /* and nanoseconds */
4343};
4344
4345#endif /* !_SYS__TIMESPEC_H_ */
4346# 50 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timespec.h" 3 4
4347# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/timespec.h" 2 3 4
4348
4349#if __BSD_VISIBLE
4350#define TIMEVAL_TO_TIMESPEC(tv, ts) \
4351 do { \
4352 (ts)->tv_sec = (tv)->tv_sec; \
4353 (ts)->tv_nsec = (tv)->tv_usec * 1000; \
4354 } while (0)
4355#define TIMESPEC_TO_TIMEVAL(tv, ts) \
4356 do { \
4357 (tv)->tv_sec = (ts)->tv_sec; \
4358 (tv)->tv_usec = (ts)->tv_nsec / 1000; \
4359 } while (0)
4360
4361#endif /* __BSD_VISIBLE */
4362# 53 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/timespec.h" 3 4
4363
4364/*
4365 * Structure defined by POSIX.1b to be like a itimerval, but with
4366 * timespecs. Used in the timer_*() system calls.
4367 */
4368struct itimerspec {
4369 struct timespec it_interval;
4370 struct timespec it_value;
4371};
4372
4373#endif /* _SYS_TIMESPEC_H_ */
4374# 64 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/timespec.h" 3 4
4375# 89 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 2 3 4
4376#endif /* __POSIX_VISIBLE >= 199309 */
4377# 90 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4378
4379#if __POSIX_VISIBLE >= 200112
4380#ifndef _PID_T_DECLARED
4381typedef __pid_t pid_t;
4382#define _PID_T_DECLARED
4383#endif
4384# 96 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4385#endif
4386# 97 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4387
4388/* These macros are also in sys/time.h. */
4389#if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112
4390#define CLOCK_REALTIME 0
4391#ifdef __BSD_VISIBLE
4392#define CLOCK_VIRTUAL 1
4393#define CLOCK_PROF 2
4394#endif
4395# 105 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4396#define CLOCK_MONOTONIC 4
4397#define CLOCK_UPTIME 5 /* FreeBSD-specific. */
4398#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */
4399#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */
4400#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */
4401#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */
4402#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */
4403#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */
4404#define CLOCK_SECOND 13 /* FreeBSD-specific. */
4405#define CLOCK_THREAD_CPUTIME_ID 14
4406#define CLOCK_PROCESS_CPUTIME_ID 15
4407#endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */
4408# 117 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4409
4410#if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112
4411#if __BSD_VISIBLE
4412#define TIMER_RELTIME 0x0 /* relative timer */
4413#endif
4414# 122 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4415#define TIMER_ABSTIME 0x1 /* absolute timer */
4416#endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */
4417# 124 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4418
4419struct tm {
4420 int tm_sec; /* seconds after the minute [0-60] */
4421 int tm_min; /* minutes after the hour [0-59] */
4422 int tm_hour; /* hours since midnight [0-23] */
4423 int tm_mday; /* day of the month [1-31] */
4424 int tm_mon; /* months since January [0-11] */
4425 int tm_year; /* years since 1900 */
4426 int tm_wday; /* days since Sunday [0-6] */
4427 int tm_yday; /* days since January 1 [0-365] */
4428 int tm_isdst; /* Daylight Savings Time flag */
4429 long tm_gmtoff; /* offset from UTC in seconds */
4430 char *tm_zone; /* timezone abbreviation */
4431};
4432
4433#if __POSIX_VISIBLE
4434extern char *tzname[];
4435#endif
4436# 142 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4437
4438__BEGIN_DECLS
4439char *asctime(const struct tm *);
4440clock_t clock(void);
4441char *ctime(const time_t *);
4442double difftime(time_t, time_t);
4443/* XXX missing: getdate() */
4444struct tm *gmtime(const time_t *);
4445struct tm *localtime(const time_t *);
4446time_t mktime(struct tm *);
4447size_t strftime(char * __restrict, size_t, const char * __restrict,
4448 const struct tm * __restrict);
4449time_t time(time_t *);
4450#if __POSIX_VISIBLE >= 200112
4451struct sigevent;
4452int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict);
4453int timer_delete(timer_t);
4454int timer_gettime(timer_t, struct itimerspec *);
4455int timer_getoverrun(timer_t);
4456int timer_settime(timer_t, int, const struct itimerspec *__restrict,
4457 struct itimerspec *__restrict);
4458#endif
4459# 164 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4460#if __POSIX_VISIBLE
4461void tzset(void);
4462#endif
4463# 167 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4464
4465#if __POSIX_VISIBLE >= 199309
4466int clock_getres(clockid_t, struct timespec *);
4467int clock_gettime(clockid_t, struct timespec *);
4468int clock_settime(clockid_t, const struct timespec *);
4469int nanosleep(const struct timespec *, struct timespec *);
4470#endif /* __POSIX_VISIBLE >= 199309 */
4471# 174 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4472
4473#if __POSIX_VISIBLE >= 200112
4474int clock_getcpuclockid(pid_t, clockid_t *);
4475int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
4476#endif
4477# 179 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4478
4479#if __POSIX_VISIBLE >= 199506
4480char *asctime_r(const struct tm *, char *);
4481char *ctime_r(const time_t *, char *);
4482struct tm *gmtime_r(const time_t *, struct tm *);
4483struct tm *localtime_r(const time_t *, struct tm *);
4484#endif
4485# 186 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4486
4487#if __XSI_VISIBLE
4488char *strptime(const char * __restrict, const char * __restrict,
4489 struct tm * __restrict);
4490#endif
4491# 191 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4492
4493#if __BSD_VISIBLE
4494char *timezone(int, int); /* XXX XSI conflict */
4495void tzsetwall(void);
4496time_t timelocal(struct tm * const);
4497time_t timegm(struct tm * const);
4498int timer_oshandle_np(timer_t timerid);
4499#endif /* __BSD_VISIBLE */
4500# 199 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4501
4502#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
4503#if 0 /* expanded by -frewrite-includes */
4504#include <xlocale/_time.h>
4505#endif /* expanded by -frewrite-includes */
4506# 201 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4507# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_time.h" 1 3 4
4508/*-
4509 * Copyright (c) 2011, 2012 The FreeBSD Foundation
4510 * All rights reserved.
4511 *
4512 * This software was developed by David Chisnall under sponsorship from
4513 * the FreeBSD Foundation.
4514 *
4515 * Redistribution and use in source and binary forms, with or without
4516 * modification, are permitted provided that the following conditions
4517 * are met:
4518 * 1. Redistributions of source code must retain the above copyright
4519 * notice, this list of conditions and the following disclaimer.
4520 * 2. Redistributions in binary form must reproduce the above copyright
4521 * notice, this list of conditions and the following disclaimer in the
4522 * documentation and/or other materials provided with the distribution.
4523 *
4524 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
4525 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4526 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4527 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4528 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4529 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4530 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4531 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4532 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4533 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4534 * SUCH DAMAGE.
4535 *
4536 * $FreeBSD$
4537 */
4538
4539#ifndef _LOCALE_T_DEFINED
4540#define _LOCALE_T_DEFINED
4541typedef struct _xlocale *locale_t;
4542#endif
4543# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_time.h" 3 4
4544
4545/*
4546 * This file is included from both locale.h and xlocale.h. We need to expose
4547 * the declarations unconditionally if we are included from xlocale.h, but only
4548 * if we are in POSIX2008 mode if included from locale.h.
4549 */
4550#ifndef _XLOCALE_LOCALE1_H
4551#define _XLOCALE_LOCALE1_H
4552
4553size_t strftime_l(char * __restrict, size_t, const char * __restrict,
4554 const struct tm * __restrict, locale_t) __strftimelike(3, 0);
4555
4556#endif /* _XLOCALE_LOCALE1_H */
4557# 49 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_time.h" 3 4
4558
4559#ifdef _XLOCALE_H_
4560#ifndef _XLOCALE_LOCALE2_H
4561#define _XLOCALE_LOCALE2_H
4562
4563char *strptime_l(const char * __restrict, const char * __restrict,
4564 struct tm * __restrict, locale_t);
4565
4566#endif /* _XLOCALE_LOCALE2_H */
4567# 58 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_time.h" 3 4
4568#endif /* _XLOCALE_H_ */
4569# 59 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/xlocale/_time.h" 3 4
4570# 202 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 2 3 4
4571#endif
4572# 203 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4573__END_DECLS
4574
4575#endif /* !_TIME_H_ */
4576# 206 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/time.h" 3 4
4577# 33 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 2
4578
4579#if 0 /* expanded by -frewrite-includes */
4580#include "win32.h"
4581#endif /* expanded by -frewrite-includes */
4582# 34 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
4583# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h" 1
4584
4585/*!
4586 ************************************************************************
4587 * \file
4588 * win32.h
4589 *
4590 * \brief
4591 * win32 definitions for H.264 encoder.
4592 *
4593 * \author
4594 *
4595 ************************************************************************
4596 */
4597#ifndef _WIN32_H_
4598#define _WIN32_H_
4599
4600#if 0 /* expanded by -frewrite-includes */
4601# include <fcntl.h>
4602#endif /* expanded by -frewrite-includes */
4603# 17 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
4604# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 1 3 4
4605/*-
4606 * Copyright (c) 1983, 1990, 1993
4607 * The Regents of the University of California. All rights reserved.
4608 * (c) UNIX System Laboratories, Inc.
4609 * All or some portions of this file are derived from material licensed
4610 * to the University of California by American Telephone and Telegraph
4611 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
4612 * the permission of UNIX System Laboratories, Inc.
4613 *
4614 * Redistribution and use in source and binary forms, with or without
4615 * modification, are permitted provided that the following conditions
4616 * are met:
4617 * 1. Redistributions of source code must retain the above copyright
4618 * notice, this list of conditions and the following disclaimer.
4619 * 2. Redistributions in binary form must reproduce the above copyright
4620 * notice, this list of conditions and the following disclaimer in the
4621 * documentation and/or other materials provided with the distribution.
4622 * 3. Neither the name of the University nor the names of its contributors
4623 * may be used to endorse or promote products derived from this software
4624 * without specific prior written permission.
4625 *
4626 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4627 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4628 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4629 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4630 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4631 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4632 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4633 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4634 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4635 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4636 * SUCH DAMAGE.
4637 *
4638 * @(#)fcntl.h 8.3 (Berkeley) 1/21/94
4639 * $FreeBSD$
4640 */
4641
4642#ifndef _SYS_FCNTL_H_
4643#define _SYS_FCNTL_H_
4644
4645/*
4646 * This file includes the definitions for open and fcntl
4647 * described by POSIX for <fcntl.h>; it also includes
4648 * related kernel definitions.
4649 */
4650
4651#if 0 /* expanded by -frewrite-includes */
4652#include <sys/cdefs.h>
4653#endif /* expanded by -frewrite-includes */
4654# 47 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4655# 48 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4656#if 0 /* expanded by -frewrite-includes */
4657#include <sys/_types.h>
4658#endif /* expanded by -frewrite-includes */
4659# 48 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4660# 49 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4661
4662#ifndef _MODE_T_DECLARED
4663typedef __mode_t mode_t;
4664#define _MODE_T_DECLARED
4665#endif
4666# 54 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4667
4668#ifndef _OFF_T_DECLARED
4669typedef __off_t off_t;
4670#define _OFF_T_DECLARED
4671#endif
4672# 59 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4673
4674#ifndef _PID_T_DECLARED
4675typedef __pid_t pid_t;
4676#define _PID_T_DECLARED
4677#endif
4678# 64 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4679
4680/*
4681 * File status flags: these are used by open(2), fcntl(2).
4682 * They are also used (indirectly) in the kernel file structure f_flags,
4683 * which is a superset of the open/fcntl flags. Open flags and f_flags
4684 * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
4685 * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
4686 */
4687/* open-only flags */
4688#define O_RDONLY 0x0000 /* open for reading only */
4689#define O_WRONLY 0x0001 /* open for writing only */
4690#define O_RDWR 0x0002 /* open for reading and writing */
4691#define O_ACCMODE 0x0003 /* mask for above modes */
4692
4693/*
4694 * Kernel encoding of open mode; separate read and write bits that are
4695 * independently testable: 1 greater than the above.
4696 *
4697 * XXX
4698 * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH,
4699 * which was documented to use FREAD/FWRITE, continues to work.
4700 */
4701#if __BSD_VISIBLE
4702#define FREAD 0x0001
4703#define FWRITE 0x0002
4704#endif
4705# 90 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4706#define O_NONBLOCK 0x0004 /* no delay */
4707#define O_APPEND 0x0008 /* set append mode */
4708#if __BSD_VISIBLE
4709#define O_SHLOCK 0x0010 /* open with shared file lock */
4710#define O_EXLOCK 0x0020 /* open with exclusive file lock */
4711#define O_ASYNC 0x0040 /* signal pgrp when data ready */
4712#define O_FSYNC 0x0080 /* synchronous writes */
4713#endif
4714# 98 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4715#define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */
4716#if __POSIX_VISIBLE >= 200809
4717#define O_NOFOLLOW 0x0100 /* don't follow symlinks */
4718#endif
4719# 102 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4720#define O_CREAT 0x0200 /* create if nonexistent */
4721#define O_TRUNC 0x0400 /* truncate to zero length */
4722#define O_EXCL 0x0800 /* error if already exists */
4723#ifdef _KERNEL
4724#define FHASLOCK 0x4000 /* descriptor holds advisory lock */
4725#endif
4726# 108 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4727
4728/* Defined by POSIX 1003.1; BSD default, but must be distinct from O_RDONLY. */
4729#define O_NOCTTY 0x8000 /* don't assign controlling terminal */
4730
4731#if __BSD_VISIBLE
4732/* Attempt to bypass buffer cache */
4733#define O_DIRECT 0x00010000
4734#endif
4735# 116 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4736
4737#if __POSIX_VISIBLE >= 200809
4738#define O_DIRECTORY 0x00020000 /* Fail if not directory */
4739#define O_EXEC 0x00040000 /* Open for execute only */
4740#endif
4741# 121 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4742#ifdef _KERNEL
4743#define FEXEC O_EXEC
4744#endif
4745# 124 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4746
4747#if __POSIX_VISIBLE >= 200809
4748/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */
4749#define O_TTY_INIT 0x00080000 /* Restore default termios attributes */
4750
4751#define O_CLOEXEC 0x00100000
4752#endif
4753# 131 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4754
4755#if __BSD_VISIBLE
4756#define O_VERIFY 0x00200000 /* open only after verification */
4757#endif
4758# 135 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4759
4760/*
4761 * XXX missing O_DSYNC, O_RSYNC.
4762 */
4763
4764#ifdef _KERNEL
4765
4766/* Only for devfs d_close() flags. */
4767#define FLASTCLOSE O_DIRECTORY
4768#define FREVOKE O_VERIFY
4769/* Only for fo_close() from half-succeeded open */
4770#define FOPENFAILED O_TTY_INIT
4771
4772/* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
4773#define FFLAGS(oflags) ((oflags) & O_EXEC ? (oflags) : (oflags) + 1)
4774#define OFLAGS(fflags) ((fflags) & O_EXEC ? (fflags) : (fflags) - 1)
4775
4776/* bits to save after open */
4777#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK|O_DIRECT|FEXEC)
4778/* bits settable by fcntl(F_SETFL, ...) */
4779#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FRDAHEAD|O_DIRECT)
4780
4781#if defined(COMPAT_FREEBSD7) || defined(COMPAT_FREEBSD6) || \
4782 defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4)
4783/*
4784 * Set by shm_open(3) in older libc's to get automatic MAP_ASYNC
4785 * behavior for POSIX shared memory objects (which are otherwise
4786 * implemented as plain files).
4787 */
4788#define FPOSIXSHM O_NOFOLLOW
4789#undef FCNTLFLAGS
4790#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|FRDAHEAD| \
4791 O_DIRECT)
4792#endif
4793# 169 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4794#endif
4795# 170 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4796
4797/*
4798 * The O_* flags used to have only F* names, which were used in the kernel
4799 * and by fcntl. We retain the F* names for the kernel f_flag field
4800 * and for backward compatibility for fcntl. These flags are deprecated.
4801 */
4802#if __BSD_VISIBLE
4803#define FAPPEND O_APPEND /* kernel/compat */
4804#define FASYNC O_ASYNC /* kernel/compat */
4805#define FFSYNC O_FSYNC /* kernel */
4806#define FNONBLOCK O_NONBLOCK /* kernel */
4807#define FNDELAY O_NONBLOCK /* compat */
4808#define O_NDELAY O_NONBLOCK /* compat */
4809#endif
4810# 184 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4811
4812/*
4813 * We are out of bits in f_flag (which is a short). However,
4814 * the flag bits not set in FMASK are only meaningful in the
4815 * initial open syscall. Those bits can thus be given a
4816 * different meaning for fcntl(2).
4817 */
4818#if __BSD_VISIBLE
4819/* Read ahead */
4820#define FRDAHEAD O_CREAT
4821#endif
4822# 195 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4823
4824#if __POSIX_VISIBLE >= 200809
4825/*
4826 * Magic value that specify the use of the current working directory
4827 * to determine the target of relative file paths in the openat() and
4828 * similar syscalls.
4829 */
4830#define AT_FDCWD -100
4831
4832/*
4833 * Miscellaneous flags for the *at() syscalls.
4834 */
4835#define AT_EACCESS 0x100 /* Check access using effective user and group ID */
4836#define AT_SYMLINK_NOFOLLOW 0x200 /* Do not follow symbolic links */
4837#define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic link */
4838#define AT_REMOVEDIR 0x800 /* Remove directory instead of file */
4839#endif
4840# 212 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4841
4842/*
4843 * Constants used for fcntl(2)
4844 */
4845
4846/* command values */
4847#define F_DUPFD 0 /* duplicate file descriptor */
4848#define F_GETFD 1 /* get file descriptor flags */
4849#define F_SETFD 2 /* set file descriptor flags */
4850#define F_GETFL 3 /* get file status flags */
4851#define F_SETFL 4 /* set file status flags */
4852#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
4853#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
4854#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
4855#endif
4856# 227 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4857#if __BSD_VISIBLE
4858#define F_OGETLK 7 /* get record locking information */
4859#define F_OSETLK 8 /* set record locking information */
4860#define F_OSETLKW 9 /* F_SETLK; wait if blocked */
4861#define F_DUP2FD 10 /* duplicate file descriptor to arg */
4862#endif
4863# 233 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4864#define F_GETLK 11 /* get record locking information */
4865#define F_SETLK 12 /* set record locking information */
4866#define F_SETLKW 13 /* F_SETLK; wait if blocked */
4867#if __BSD_VISIBLE
4868#define F_SETLK_REMOTE 14 /* debugging support for remote locks */
4869#define F_READAHEAD 15 /* read ahead */
4870#define F_RDAHEAD 16 /* Darwin compatible read ahead */
4871#endif
4872# 241 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4873#if __POSIX_VISIBLE >= 200809
4874#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */
4875#endif
4876# 244 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4877#if __BSD_VISIBLE
4878#define F_DUP2FD_CLOEXEC 18 /* Like F_DUP2FD, but FD_CLOEXEC is set */
4879#endif
4880# 247 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4881
4882/* file descriptor flags (F_GETFD, F_SETFD) */
4883#define FD_CLOEXEC 1 /* close-on-exec flag */
4884
4885/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
4886#define F_RDLCK 1 /* shared or read lock */
4887#define F_UNLCK 2 /* unlock */
4888#define F_WRLCK 3 /* exclusive or write lock */
4889#if __BSD_VISIBLE
4890#define F_UNLCKSYS 4 /* purge locks for a given system ID */
4891#define F_CANCEL 5 /* cancel an async lock request */
4892#endif
4893# 259 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4894#ifdef _KERNEL
4895#define F_WAIT 0x010 /* Wait until lock is granted */
4896#define F_FLOCK 0x020 /* Use flock(2) semantics for lock */
4897#define F_POSIX 0x040 /* Use POSIX semantics for lock */
4898#define F_REMOTE 0x080 /* Lock owner is remote NFS client */
4899#define F_NOINTR 0x100 /* Ignore signals when waiting */
4900#endif
4901# 266 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4902
4903/*
4904 * Advisory file segment locking data type -
4905 * information passed to system by user
4906 */
4907struct flock {
4908 off_t l_start; /* starting offset */
4909 off_t l_len; /* len = 0 means until end of file */
4910 pid_t l_pid; /* lock owner */
4911 short l_type; /* lock type: read/write, etc. */
4912 short l_whence; /* type of l_start */
4913 int l_sysid; /* remote system id or zero for local */
4914};
4915
4916#if __BSD_VISIBLE
4917/*
4918 * Old advisory file segment locking data type,
4919 * before adding l_sysid.
4920 */
4921struct __oflock {
4922 off_t l_start; /* starting offset */
4923 off_t l_len; /* len = 0 means until end of file */
4924 pid_t l_pid; /* lock owner */
4925 short l_type; /* lock type: read/write, etc. */
4926 short l_whence; /* type of l_start */
4927};
4928#endif
4929# 293 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4930
4931#if __BSD_VISIBLE
4932/* lock operations for flock(2) */
4933#define LOCK_SH 0x01 /* shared file lock */
4934#define LOCK_EX 0x02 /* exclusive file lock */
4935#define LOCK_NB 0x04 /* don't block when locking */
4936#define LOCK_UN 0x08 /* unlock file */
4937#endif
4938# 301 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4939
4940#if __POSIX_VISIBLE >= 200112
4941/*
4942 * Advice to posix_fadvise
4943 */
4944#define POSIX_FADV_NORMAL 0 /* no special treatment */
4945#define POSIX_FADV_RANDOM 1 /* expect random page references */
4946#define POSIX_FADV_SEQUENTIAL 2 /* expect sequential page references */
4947#define POSIX_FADV_WILLNEED 3 /* will need these pages */
4948#define POSIX_FADV_DONTNEED 4 /* dont need these pages */
4949#define POSIX_FADV_NOREUSE 5 /* access data only once */
4950#endif
4951# 313 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4952
4953#ifndef _KERNEL
4954__BEGIN_DECLS
4955int open(const char *, int, ...);
4956int creat(const char *, mode_t);
4957int fcntl(int, int, ...);
4958#if __BSD_VISIBLE
4959int flock(int, int);
4960#endif
4961# 322 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4962#if __POSIX_VISIBLE >= 200809
4963int openat(int, const char *, int, ...);
4964#endif
4965# 325 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4966#if __POSIX_VISIBLE >= 200112
4967int posix_fadvise(int, off_t, off_t, int);
4968int posix_fallocate(int, off_t, off_t);
4969#endif
4970# 329 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4971__END_DECLS
4972#endif
4973# 331 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4974
4975#endif /* !_SYS_FCNTL_H_ */
4976# 333 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/fcntl.h" 3 4
4977# 18 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h" 2
4978#if 0 /* expanded by -frewrite-includes */
4979# include <stdio.h>
4980#endif /* expanded by -frewrite-includes */
4981# 18 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
4982# 19 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
4983
4984#if defined(WIN32)
4985#if 0 /* expanded by -frewrite-includes */
4986# include <io.h>
4987#endif /* expanded by -frewrite-includes */
4988# 21 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
4989# 22 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
4990#if 0 /* expanded by -frewrite-includes */
4991# include <sys/types.h>
4992#endif /* expanded by -frewrite-includes */
4993# 22 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
4994# 23 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
4995#if 0 /* expanded by -frewrite-includes */
4996# include <sys/stat.h>
4997#endif /* expanded by -frewrite-includes */
4998# 23 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
4999# 24 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
5000# define strcasecmp _strcmpi
5001
5002# define snprintf _snprintf
5003# define open _open
5004# define close _close
5005# define read _read
5006# define write _write
5007# define lseek _lseeki64
5008# define fsync _commit
5009# define tell _tell
5010# define TIMEB _timeb
5011# define ftime _ftime
5012# define OPENFLAGS_WRITE _O_WRONLY|_O_CREAT|_O_BINARY|_O_TRUNC
5013# define OPEN_PERMISSIONS _S_IREAD | _S_IWRITE
5014# define OPENFLAGS_READ _O_RDONLY|_O_BINARY
5015# define inline _inline
5016#else
5017# 41 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
5018#if 0 /* expanded by -frewrite-includes */
5019# include <unistd.h>
5020#endif /* expanded by -frewrite-includes */
5021# 41 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
5022# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 1 3 4
5023/*-
5024 * Copyright (c) 1991, 1993, 1994
5025 * The Regents of the University of California. All rights reserved.
5026 *
5027 * Redistribution and use in source and binary forms, with or without
5028 * modification, are permitted provided that the following conditions
5029 * are met:
5030 * 1. Redistributions of source code must retain the above copyright
5031 * notice, this list of conditions and the following disclaimer.
5032 * 2. Redistributions in binary form must reproduce the above copyright
5033 * notice, this list of conditions and the following disclaimer in the
5034 * documentation and/or other materials provided with the distribution.
5035 * 3. Neither the name of the University nor the names of its contributors
5036 * may be used to endorse or promote products derived from this software
5037 * without specific prior written permission.
5038 *
5039 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5040 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5041 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5042 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5043 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5044 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5045 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5046 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5047 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5048 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5049 * SUCH DAMAGE.
5050 *
5051 * @(#)unistd.h 8.12 (Berkeley) 4/27/95
5052 * $FreeBSD$
5053 */
5054
5055#ifndef _UNISTD_H_
5056#define _UNISTD_H_
5057
5058#if 0 /* expanded by -frewrite-includes */
5059#include <sys/cdefs.h>
5060#endif /* expanded by -frewrite-includes */
5061# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
5062# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
5063#if 0 /* expanded by -frewrite-includes */
5064#include <sys/types.h> /* XXX adds too much pollution. */
5065#endif /* expanded by -frewrite-includes */
5066# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
5067# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 1 3 4
5068/*-
5069 * Copyright (c) 1982, 1986, 1991, 1993, 1994
5070 * The Regents of the University of California. All rights reserved.
5071 * (c) UNIX System Laboratories, Inc.
5072 * All or some portions of this file are derived from material licensed
5073 * to the University of California by American Telephone and Telegraph
5074 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
5075 * the permission of UNIX System Laboratories, Inc.
5076 *
5077 * Redistribution and use in source and binary forms, with or without
5078 * modification, are permitted provided that the following conditions
5079 * are met:
5080 * 1. Redistributions of source code must retain the above copyright
5081 * notice, this list of conditions and the following disclaimer.
5082 * 2. Redistributions in binary form must reproduce the above copyright
5083 * notice, this list of conditions and the following disclaimer in the
5084 * documentation and/or other materials provided with the distribution.
5085 * 3. Neither the name of the University nor the names of its contributors
5086 * may be used to endorse or promote products derived from this software
5087 * without specific prior written permission.
5088 *
5089 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5090 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5091 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5092 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5093 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5094 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5095 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5096 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5097 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5098 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5099 * SUCH DAMAGE.
5100 *
5101 * @(#)types.h 8.6 (Berkeley) 2/19/95
5102 * $FreeBSD$
5103 */
5104
5105#ifndef _SYS_TYPES_H_
5106#define _SYS_TYPES_H_
5107
5108#if 0 /* expanded by -frewrite-includes */
5109#include <sys/cdefs.h>
5110#endif /* expanded by -frewrite-includes */
5111# 41 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5112# 42 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5113
5114/* Machine type dependent parameters. */
5115#if 0 /* expanded by -frewrite-includes */
5116#include <machine/endian.h>
5117#endif /* expanded by -frewrite-includes */
5118# 44 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5119# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 1 3 4
5120/*-
5121 * Copyright (c) 1987, 1991 Regents of the University of California.
5122 * All rights reserved.
5123 *
5124 * Redistribution and use in source and binary forms, with or without
5125 * modification, are permitted provided that the following conditions
5126 * are met:
5127 * 1. Redistributions of source code must retain the above copyright
5128 * notice, this list of conditions and the following disclaimer.
5129 * 2. Redistributions in binary form must reproduce the above copyright
5130 * notice, this list of conditions and the following disclaimer in the
5131 * documentation and/or other materials provided with the distribution.
5132 * 3. Neither the name of the University nor the names of its contributors
5133 * may be used to endorse or promote products derived from this software
5134 * without specific prior written permission.
5135 *
5136 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5137 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5138 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5139 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5140 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5141 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5142 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5143 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5144 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5145 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5146 * SUCH DAMAGE.
5147 *
5148 * @(#)endian.h 7.8 (Berkeley) 4/3/91
5149 * $FreeBSD$
5150 */
5151
5152#ifndef _MACHINE_ENDIAN_H_
5153#define _MACHINE_ENDIAN_H_
5154
5155#if 0 /* expanded by -frewrite-includes */
5156#include <sys/cdefs.h>
5157#endif /* expanded by -frewrite-includes */
5158# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5159# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5160#ifndef __ASSEMBLER__
5161#if 0 /* expanded by -frewrite-includes */
5162#include <sys/_types.h>
5163#endif /* expanded by -frewrite-includes */
5164# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5165# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5166#endif
5167# 40 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5168
5169#ifdef __cplusplus
5170extern "C" {
5171#endif
5172# 44 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5173
5174/*
5175 * Definitions for byte order, according to byte significance from low
5176 * address to high.
5177 */
5178#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
5179#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
5180#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
5181
5182#ifdef __MIPSEB__
5183#define _BYTE_ORDER _BIG_ENDIAN
5184#else
5185# 56 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5186#define _BYTE_ORDER _LITTLE_ENDIAN
5187#endif /* __MIBSEB__ */
5188# 58 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5189
5190/*
5191 * Deprecated variants that don't have enough underscores to be useful in more
5192 * strict namespaces.
5193 */
5194#if __BSD_VISIBLE
5195#define LITTLE_ENDIAN _LITTLE_ENDIAN
5196#define BIG_ENDIAN _BIG_ENDIAN
5197#define PDP_ENDIAN _PDP_ENDIAN
5198#define BYTE_ORDER _BYTE_ORDER
5199#endif
5200# 69 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5201
5202#ifndef __ASSEMBLER__
5203#if defined(__GNUCLIKE_BUILTIN_CONSTANT_P) && defined(__OPTIMIZE__)
5204#define __is_constant(x) __builtin_constant_p(x)
5205#else
5206# 74 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5207#define __is_constant(x) 0
5208#endif
5209# 76 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5210
5211#define __bswap16_const(x) (((x) >> 8) | (((x) << 8) & 0xff00))
5212#define __bswap32_const(x) (((x) >> 24) | (((x) >> 8) & 0xff00) | \
5213 (((x) << 8) & 0xff0000) | (((x) << 24) & 0xff000000))
5214#define __bswap64_const(x) (((x) >> 56) | (((x) >> 40) & 0xff00) | \
5215 (((x) >> 24) & 0xff0000) | (((x) >> 8) & 0xff000000) | \
5216 (((x) << 8) & ((__uint64_t)0xff << 32)) | \
5217 (((x) << 24) & ((__uint64_t)0xff << 40)) | \
5218 (((x) << 40) & ((__uint64_t)0xff << 48)) | (((x) << 56)))
5219
5220static __inline __uint16_t
5221__bswap16_var(__uint16_t _x)
5222{
5223
5224 return ((_x >> 8) | ((_x << 8) & 0xff00));
5225}
5226
5227static __inline __uint32_t
5228__bswap32_var(__uint32_t _x)
5229{
5230
5231 return ((_x >> 24) | ((_x >> 8) & 0xff00) | ((_x << 8) & 0xff0000) |
5232 ((_x << 24) & 0xff000000));
5233}
5234
5235static __inline __uint64_t
5236__bswap64_var(__uint64_t _x)
5237{
5238
5239 return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
5240 ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
5241 ((_x << 24) & ((__uint64_t)0xff << 40)) |
5242 ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
5243}
5244
5245#define __bswap16(x) ((__uint16_t)(__is_constant((x)) ? \
5246 __bswap16_const((__uint16_t)(x)) : __bswap16_var((__uint16_t)(x))))
5247#define __bswap32(x) ((__uint32_t)(__is_constant((x)) ? \
5248 __bswap32_const((__uint32_t)(x)) : __bswap32_var((__uint32_t)(x))))
5249#define __bswap64(x) ((__uint64_t)(__is_constant((x)) ? \
5250 __bswap64_const((__uint64_t)(x)) : __bswap64_var((__uint64_t)(x))))
5251
5252#ifdef __MIPSEB__
5253#define __htonl(x) ((__uint32_t)(x))
5254#define __htons(x) ((__uint16_t)(x))
5255#define __ntohl(x) ((__uint32_t)(x))
5256#define __ntohs(x) ((__uint16_t)(x))
5257/*
5258 * Define the order of 32-bit words in 64-bit words.
5259 */
5260/*
5261 * XXXMIPS: Additional parentheses to make gcc more happy.
5262 */
5263#define _QUAD_HIGHWORD 0
5264#define _QUAD_LOWWORD 1
5265#else
5266# 132 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5267#define _QUAD_HIGHWORD 1
5268#define _QUAD_LOWWORD 0
5269#define __ntohl(x) (__bswap32((x)))
5270#define __ntohs(x) (__bswap16((x)))
5271#define __htonl(x) (__bswap32((x)))
5272#define __htons(x) (__bswap16((x)))
5273#endif /* _MIPSEB */
5274# 139 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5275
5276#endif /* _ASSEMBLER_ */
5277# 141 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5278
5279#ifdef __cplusplus
5280}
5281#endif
5282# 145 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5283
5284#endif /* !_MACHINE_ENDIAN_H_ */
5285# 147 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/machine/endian.h" 3 4
5286# 45 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 2 3 4
5287#if 0 /* expanded by -frewrite-includes */
5288#include <sys/_types.h>
5289#endif /* expanded by -frewrite-includes */
5290# 45 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5291# 46 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5292
5293#if 0 /* expanded by -frewrite-includes */
5294#include <sys/_pthreadtypes.h>
5295#endif /* expanded by -frewrite-includes */
5296# 47 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5297# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_pthreadtypes.h" 1 3 4
5298/*
5299 * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu
5300 * Copyright (c) 1995-1998 by John Birrell <jb@cimlogic.com.au>
5301 * All rights reserved.
5302 *
5303 * Redistribution and use in source and binary forms, with or without
5304 * modification, are permitted provided that the following conditions
5305 * are met:
5306 * 1. Redistributions of source code must retain the above copyright
5307 * notice, this list of conditions and the following disclaimer.
5308 * 2. Redistributions in binary form must reproduce the above copyright
5309 * notice, this list of conditions and the following disclaimer in the
5310 * documentation and/or other materials provided with the distribution.
5311 * 3. All advertising materials mentioning features or use of this software
5312 * must display the following acknowledgement:
5313 * This product includes software developed by Chris Provenzano.
5314 * 4. The name of Chris Provenzano may not be used to endorse or promote
5315 * products derived from this software without specific prior written
5316 * permission.
5317 *
5318 * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
5319 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5320 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5321 * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY
5322 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
5323 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5324 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5325 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5326 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5327 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5328 * SUCH DAMAGE.
5329 *
5330 * $FreeBSD$
5331 */
5332
5333#ifndef _SYS__PTHREADTYPES_H_
5334#define _SYS__PTHREADTYPES_H_
5335
5336/*
5337 * Forward structure definitions.
5338 *
5339 * These are mostly opaque to the user.
5340 */
5341struct pthread;
5342struct pthread_attr;
5343struct pthread_cond;
5344struct pthread_cond_attr;
5345struct pthread_mutex;
5346struct pthread_mutex_attr;
5347struct pthread_once;
5348struct pthread_rwlock;
5349struct pthread_rwlockattr;
5350struct pthread_barrier;
5351struct pthread_barrier_attr;
5352struct pthread_spinlock;
5353
5354/*
5355 * Primitive system data type definitions required by P1003.1c.
5356 *
5357 * Note that P1003.1c specifies that there are no defined comparison
5358 * or assignment operators for the types pthread_attr_t, pthread_cond_t,
5359 * pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t.
5360 */
5361#ifndef _PTHREAD_T_DECLARED
5362typedef struct pthread *pthread_t;
5363#define _PTHREAD_T_DECLARED
5364#endif
5365# 68 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_pthreadtypes.h" 3 4
5366typedef struct pthread_attr *pthread_attr_t;
5367typedef struct pthread_mutex *pthread_mutex_t;
5368typedef struct pthread_mutex_attr *pthread_mutexattr_t;
5369typedef struct pthread_cond *pthread_cond_t;
5370typedef struct pthread_cond_attr *pthread_condattr_t;
5371typedef int pthread_key_t;
5372typedef struct pthread_once pthread_once_t;
5373typedef struct pthread_rwlock *pthread_rwlock_t;
5374typedef struct pthread_rwlockattr *pthread_rwlockattr_t;
5375typedef struct pthread_barrier *pthread_barrier_t;
5376typedef struct pthread_barrierattr *pthread_barrierattr_t;
5377typedef struct pthread_spinlock *pthread_spinlock_t;
5378
5379/*
5380 * Additional type definitions:
5381 *
5382 * Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for
5383 * use in header symbols.
5384 */
5385typedef void *pthread_addr_t;
5386typedef void *(*pthread_startroutine_t)(void *);
5387
5388/*
5389 * Once definitions.
5390 */
5391struct pthread_once {
5392 int state;
5393 pthread_mutex_t mutex;
5394};
5395
5396#endif /* ! _SYS__PTHREADTYPES_H_ */
5397# 99 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_pthreadtypes.h" 3 4
5398# 48 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 2 3 4
5399
5400#if __BSD_VISIBLE
5401typedef unsigned char u_char;
5402typedef unsigned short u_short;
5403typedef unsigned int u_int;
5404typedef unsigned long u_long;
5405#ifndef _KERNEL
5406typedef unsigned short ushort; /* Sys V compatibility */
5407typedef unsigned int uint; /* Sys V compatibility */
5408#endif
5409# 58 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5410#endif
5411# 59 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5412
5413/*
5414 * XXX POSIX sized integrals that should appear only in <sys/stdint.h>.
5415 */
5416#if 0 /* expanded by -frewrite-includes */
5417#include <sys/_stdint.h>
5418#endif /* expanded by -frewrite-includes */
5419# 63 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5420# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 1 3 4
5421/*-
5422 * Copyright (c) 2011 David E. O'Brien <obrien@FreeBSD.org>
5423 * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
5424 * All rights reserved.
5425 *
5426 * Redistribution and use in source and binary forms, with or without
5427 * modification, are permitted provided that the following conditions
5428 * are met:
5429 * 1. Redistributions of source code must retain the above copyright
5430 * notice, this list of conditions and the following disclaimer.
5431 * 2. Redistributions in binary form must reproduce the above copyright
5432 * notice, this list of conditions and the following disclaimer in the
5433 * documentation and/or other materials provided with the distribution.
5434 *
5435 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
5436 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5437 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5438 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
5439 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5440 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5441 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5442 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5443 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5444 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5445 * SUCH DAMAGE.
5446 *
5447 * $FreeBSD$
5448 */
5449
5450#ifndef _SYS__STDINT_H_
5451#define _SYS__STDINT_H_
5452
5453#ifndef _INT8_T_DECLARED
5454typedef __int8_t int8_t;
5455#define _INT8_T_DECLARED
5456#endif
5457# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5458
5459#ifndef _INT16_T_DECLARED
5460typedef __int16_t int16_t;
5461#define _INT16_T_DECLARED
5462#endif
5463# 42 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5464
5465#ifndef _INT32_T_DECLARED
5466typedef __int32_t int32_t;
5467#define _INT32_T_DECLARED
5468#endif
5469# 47 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5470
5471#ifndef _INT64_T_DECLARED
5472typedef __int64_t int64_t;
5473#define _INT64_T_DECLARED
5474#endif
5475# 52 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5476
5477#ifndef _UINT8_T_DECLARED
5478typedef __uint8_t uint8_t;
5479#define _UINT8_T_DECLARED
5480#endif
5481# 57 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5482
5483#ifndef _UINT16_T_DECLARED
5484typedef __uint16_t uint16_t;
5485#define _UINT16_T_DECLARED
5486#endif
5487# 62 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5488
5489#ifndef _UINT32_T_DECLARED
5490typedef __uint32_t uint32_t;
5491#define _UINT32_T_DECLARED
5492#endif
5493# 67 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5494
5495#ifndef _UINT64_T_DECLARED
5496typedef __uint64_t uint64_t;
5497#define _UINT64_T_DECLARED
5498#endif
5499# 72 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5500
5501#ifndef _INTPTR_T_DECLARED
5502typedef __intptr_t intptr_t;
5503#define _INTPTR_T_DECLARED
5504#endif
5505# 77 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5506#ifndef _UINTPTR_T_DECLARED
5507typedef __uintptr_t uintptr_t;
5508#define _UINTPTR_T_DECLARED
5509#endif
5510# 81 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5511#ifndef _INTMAX_T_DECLARED
5512typedef __intmax_t intmax_t;
5513#define _INTMAX_T_DECLARED
5514#endif
5515# 85 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5516#ifndef _UINTMAX_T_DECLARED
5517typedef __uintmax_t uintmax_t;
5518#define _UINTMAX_T_DECLARED
5519#endif
5520# 89 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5521
5522#ifndef _VADDR_T_DECLARED
5523#ifndef __CHERI_PURE_CAPABILITY__
5524typedef __uintptr_t vaddr_t;
5525#else
5526# 94 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5527typedef __uint64_t vaddr_t;
5528#endif
5529# 96 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5530#define _VADDR_T_DECLARED
5531#endif
5532# 98 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5533
5534#endif /* !_SYS__STDINT_H_ */
5535# 100 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_stdint.h" 3 4
5536# 64 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 2 3 4
5537
5538typedef __uint8_t u_int8_t; /* unsigned integrals (deprecated) */
5539typedef __uint16_t u_int16_t;
5540typedef __uint32_t u_int32_t;
5541typedef __uint64_t u_int64_t;
5542
5543typedef __uint64_t u_quad_t; /* quads (deprecated) */
5544typedef __int64_t quad_t;
5545typedef quad_t * qaddr_t;
5546
5547typedef char * caddr_t; /* core address */
5548typedef const char * c_caddr_t; /* core address, pointer to const */
5549
5550#ifndef _BLKSIZE_T_DECLARED
5551typedef __blksize_t blksize_t;
5552#define _BLKSIZE_T_DECLARED
5553#endif
5554# 81 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5555
5556typedef __cpuwhich_t cpuwhich_t;
5557typedef __cpulevel_t cpulevel_t;
5558typedef __cpusetid_t cpusetid_t;
5559
5560#ifndef _BLKCNT_T_DECLARED
5561typedef __blkcnt_t blkcnt_t;
5562#define _BLKCNT_T_DECLARED
5563#endif
5564# 90 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5565
5566#ifndef _CLOCK_T_DECLARED
5567typedef __clock_t clock_t;
5568#define _CLOCK_T_DECLARED
5569#endif
5570# 95 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5571
5572#ifndef _CLOCKID_T_DECLARED
5573typedef __clockid_t clockid_t;
5574#define _CLOCKID_T_DECLARED
5575#endif
5576# 100 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5577
5578typedef __critical_t critical_t; /* Critical section value */
5579typedef __int64_t daddr_t; /* disk address */
5580
5581#ifndef _DEV_T_DECLARED
5582typedef __dev_t dev_t; /* device number or struct cdev */
5583#define _DEV_T_DECLARED
5584#endif
5585# 108 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5586
5587#ifndef _FFLAGS_T_DECLARED
5588typedef __fflags_t fflags_t; /* file flags */
5589#define _FFLAGS_T_DECLARED
5590#endif
5591# 113 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5592
5593typedef __fixpt_t fixpt_t; /* fixed point number */
5594
5595#ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */
5596typedef __fsblkcnt_t fsblkcnt_t;
5597typedef __fsfilcnt_t fsfilcnt_t;
5598#define _FSBLKCNT_T_DECLARED
5599#endif
5600# 121 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5601
5602#ifndef _GID_T_DECLARED
5603typedef __gid_t gid_t; /* group id */
5604#define _GID_T_DECLARED
5605#endif
5606# 126 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5607
5608#ifndef _IN_ADDR_T_DECLARED
5609typedef __uint32_t in_addr_t; /* base type for internet address */
5610#define _IN_ADDR_T_DECLARED
5611#endif
5612# 131 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5613
5614#ifndef _IN_PORT_T_DECLARED
5615typedef __uint16_t in_port_t;
5616#define _IN_PORT_T_DECLARED
5617#endif
5618# 136 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5619
5620#ifndef _ID_T_DECLARED
5621typedef __id_t id_t; /* can hold a uid_t or pid_t */
5622#define _ID_T_DECLARED
5623#endif
5624# 141 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5625
5626#ifndef _INO_T_DECLARED
5627typedef __ino_t ino_t; /* inode number */
5628#define _INO_T_DECLARED
5629#endif
5630# 146 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5631
5632#ifndef _KEY_T_DECLARED
5633typedef __key_t key_t; /* IPC key (for Sys V IPC) */
5634#define _KEY_T_DECLARED
5635#endif
5636# 151 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5637
5638#ifndef _LWPID_T_DECLARED
5639typedef __lwpid_t lwpid_t; /* Thread ID (a.k.a. LWP) */
5640#define _LWPID_T_DECLARED
5641#endif
5642# 156 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5643
5644#ifndef _MODE_T_DECLARED
5645typedef __mode_t mode_t; /* permissions */
5646#define _MODE_T_DECLARED
5647#endif
5648# 161 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5649
5650#ifndef _ACCMODE_T_DECLARED
5651typedef __accmode_t accmode_t; /* access permissions */
5652#define _ACCMODE_T_DECLARED
5653#endif
5654# 166 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5655
5656#ifndef _NLINK_T_DECLARED
5657typedef __nlink_t nlink_t; /* link count */
5658#define _NLINK_T_DECLARED
5659#endif
5660# 171 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5661
5662#ifndef _OFF_T_DECLARED
5663typedef __off_t off_t; /* file offset */
5664#define _OFF_T_DECLARED
5665#endif
5666# 176 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5667
5668#ifndef _OFF64_T_DECLARED
5669typedef __off64_t off64_t; /* file offset (alias) */
5670#define _OFF64_T_DECLARED
5671#endif
5672# 181 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5673
5674#ifndef _PID_T_DECLARED
5675typedef __pid_t pid_t; /* process id */
5676#define _PID_T_DECLARED
5677#endif
5678# 186 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5679
5680typedef __register_t register_t;
5681
5682#ifndef _RLIM_T_DECLARED
5683typedef __rlim_t rlim_t; /* resource limit */
5684#define _RLIM_T_DECLARED
5685#endif
5686# 193 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5687
5688typedef __int64_t sbintime_t;
5689
5690typedef __segsz_t segsz_t; /* segment size (in pages) */
5691
5692#ifndef _SIZE_T_DECLARED
5693typedef __size_t size_t;
5694#define _SIZE_T_DECLARED
5695#endif
5696# 202 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5697
5698#ifndef _SSIZE_T_DECLARED
5699typedef __ssize_t ssize_t;
5700#define _SSIZE_T_DECLARED
5701#endif
5702# 207 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5703
5704#ifndef _SUSECONDS_T_DECLARED
5705typedef __suseconds_t suseconds_t; /* microseconds (signed) */
5706#define _SUSECONDS_T_DECLARED
5707#endif
5708# 212 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5709
5710#ifndef _TIME_T_DECLARED
5711typedef __time_t time_t;
5712#define _TIME_T_DECLARED
5713#endif
5714# 217 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5715
5716#ifndef _TIMER_T_DECLARED
5717typedef __timer_t timer_t;
5718#define _TIMER_T_DECLARED
5719#endif
5720# 222 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5721
5722#ifndef _MQD_T_DECLARED
5723typedef __mqd_t mqd_t;
5724#define _MQD_T_DECLARED
5725#endif
5726# 227 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5727
5728typedef __u_register_t u_register_t;
5729
5730#ifndef _UID_T_DECLARED
5731typedef __uid_t uid_t; /* user id */
5732#define _UID_T_DECLARED
5733#endif
5734# 234 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5735
5736#ifndef _USECONDS_T_DECLARED
5737typedef __useconds_t useconds_t; /* microseconds (unsigned) */
5738#define _USECONDS_T_DECLARED
5739#endif
5740# 239 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5741
5742#ifndef _CAP_IOCTL_T_DECLARED
5743#define _CAP_IOCTL_T_DECLARED
5744typedef unsigned long cap_ioctl_t;
5745#endif
5746# 244 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5747
5748#ifndef _CAP_RIGHTS_T_DECLARED
5749#define _CAP_RIGHTS_T_DECLARED
5750struct cap_rights;
5751
5752typedef struct cap_rights cap_rights_t;
5753#endif
5754# 251 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5755
5756typedef __vm_offset_t vm_offset_t;
5757typedef __int64_t vm_ooffset_t;
5758typedef __vm_paddr_t vm_paddr_t;
5759typedef __uint64_t vm_pindex_t;
5760typedef __vm_size_t vm_size_t;
5761
5762typedef __rman_res_t rman_res_t;
5763
5764#ifdef _KERNEL
5765typedef int boolean_t;
5766typedef struct device *device_t;
5767typedef __intfptr_t intfptr_t;
5768
5769/*
5770 * XXX this is fixed width for historical reasons. It should have had type
5771 * __int_fast32_t. Fixed-width types should not be used unless binary
5772 * compatibility is essential. Least-width types should be used even less
5773 * since they provide smaller benefits.
5774 *
5775 * XXX should be MD.
5776 *
5777 * XXX this is bogus in -current, but still used for spl*().
5778 */
5779typedef __uint32_t intrmask_t; /* Interrupt mask (spl, xxx_imask...) */
5780
5781typedef __uintfptr_t uintfptr_t;
5782typedef __uint64_t uoff_t;
5783typedef char vm_memattr_t; /* memory attribute codes */
5784typedef struct vm_page *vm_page_t;
5785
5786#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
5787#define __bool_true_false_are_defined 1
5788#define false 0
5789#define true 1
5790#if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER)
5791typedef int _Bool;
5792#endif
5793# 289 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5794typedef _Bool bool;
5795#endif /* !__bool_true_false_are_defined && !__cplusplus */
5796# 291 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5797
5798#define offsetof(type, field) __offsetof(type, field)
5799
5800#endif /* !_KERNEL */
5801# 295 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5802
5803/*
5804 * The following are all things that really shouldn't exist in this header,
5805 * since its purpose is to provide typedefs, not miscellaneous doodads.
5806 */
5807
5808#ifdef __POPCNT__
5809#define __bitcount64(x) __builtin_popcountll((__uint64_t)(x))
5810#define __bitcount32(x) __builtin_popcount((__uint32_t)(x))
5811#define __bitcount16(x) __builtin_popcount((__uint16_t)(x))
5812#define __bitcountl(x) __builtin_popcountl((unsigned long)(x))
5813#define __bitcount(x) __builtin_popcount((unsigned int)(x))
5814#else
5815# 308 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5816/*
5817 * Population count algorithm using SWAR approach
5818 * - "SIMD Within A Register".
5819 */
5820static __inline __uint16_t
5821__bitcount16(__uint16_t _x)
5822{
5823
5824 _x = (_x & 0x5555) + ((_x & 0xaaaa) >> 1);
5825 _x = (_x & 0x3333) + ((_x & 0xcccc) >> 2);
5826 _x = (_x + (_x >> 4)) & 0x0f0f;
5827 _x = (_x + (_x >> 8)) & 0x00ff;
5828 return (_x);
5829}
5830
5831static __inline __uint32_t
5832__bitcount32(__uint32_t _x)
5833{
5834
5835 _x = (_x & 0x55555555) + ((_x & 0xaaaaaaaa) >> 1);
5836 _x = (_x & 0x33333333) + ((_x & 0xcccccccc) >> 2);
5837 _x = (_x + (_x >> 4)) & 0x0f0f0f0f;
5838 _x = (_x + (_x >> 8));
5839 _x = (_x + (_x >> 16)) & 0x000000ff;
5840 return (_x);
5841}
5842
5843#ifdef __LP64__
5844static __inline __uint64_t
5845__bitcount64(__uint64_t _x)
5846{
5847
5848 _x = (_x & 0x5555555555555555) + ((_x & 0xaaaaaaaaaaaaaaaa) >> 1);
5849 _x = (_x & 0x3333333333333333) + ((_x & 0xcccccccccccccccc) >> 2);
5850 _x = (_x + (_x >> 4)) & 0x0f0f0f0f0f0f0f0f;
5851 _x = (_x + (_x >> 8));
5852 _x = (_x + (_x >> 16));
5853 _x = (_x + (_x >> 32)) & 0x000000ff;
5854 return (_x);
5855}
5856
5857#define __bitcountl(x) __bitcount64((unsigned long)(x))
5858#else
5859# 351 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5860static __inline __uint64_t
5861__bitcount64(__uint64_t _x)
5862{
5863
5864 return (__bitcount32(_x >> 32) + __bitcount32(_x));
5865}
5866
5867#define __bitcountl(x) __bitcount32((unsigned long)(x))
5868#endif
5869# 360 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5870#define __bitcount(x) __bitcount32((unsigned int)(x))
5871#endif
5872# 362 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5873
5874#if __BSD_VISIBLE
5875
5876#if 0 /* expanded by -frewrite-includes */
5877#include <sys/select.h>
5878#endif /* expanded by -frewrite-includes */
5879# 365 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
5880# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 1 3 4
5881/*-
5882 * Copyright (c) 1992, 1993
5883 * The Regents of the University of California. All rights reserved.
5884 *
5885 * Redistribution and use in source and binary forms, with or without
5886 * modification, are permitted provided that the following conditions
5887 * are met:
5888 * 1. Redistributions of source code must retain the above copyright
5889 * notice, this list of conditions and the following disclaimer.
5890 * 2. Redistributions in binary form must reproduce the above copyright
5891 * notice, this list of conditions and the following disclaimer in the
5892 * documentation and/or other materials provided with the distribution.
5893 * 3. Neither the name of the University nor the names of its contributors
5894 * may be used to endorse or promote products derived from this software
5895 * without specific prior written permission.
5896 *
5897 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5898 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5899 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5900 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5901 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5902 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5903 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5904 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5905 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5906 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5907 * SUCH DAMAGE.
5908 *
5909 * $FreeBSD$
5910 */
5911
5912#ifndef _SYS_SELECT_H_
5913#define _SYS_SELECT_H_
5914
5915#if 0 /* expanded by -frewrite-includes */
5916#include <sys/cdefs.h>
5917#endif /* expanded by -frewrite-includes */
5918# 35 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
5919# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
5920#if 0 /* expanded by -frewrite-includes */
5921#include <sys/_types.h>
5922#endif /* expanded by -frewrite-includes */
5923# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
5924# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
5925
5926#if 0 /* expanded by -frewrite-includes */
5927#include <sys/_sigset.h>
5928#endif /* expanded by -frewrite-includes */
5929# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
5930# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_sigset.h" 1 3 4
5931/*-
5932 * Copyright (c) 1982, 1986, 1989, 1991, 1993
5933 * The Regents of the University of California. All rights reserved.
5934 * (c) UNIX System Laboratories, Inc.
5935 * All or some portions of this file are derived from material licensed
5936 * to the University of California by American Telephone and Telegraph
5937 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
5938 * the permission of UNIX System Laboratories, Inc.
5939 *
5940 * Redistribution and use in source and binary forms, with or without
5941 * modification, are permitted provided that the following conditions
5942 * are met:
5943 * 1. Redistributions of source code must retain the above copyright
5944 * notice, this list of conditions and the following disclaimer.
5945 * 2. Redistributions in binary form must reproduce the above copyright
5946 * notice, this list of conditions and the following disclaimer in the
5947 * documentation and/or other materials provided with the distribution.
5948 * 3. Neither the name of the University nor the names of its contributors
5949 * may be used to endorse or promote products derived from this software
5950 * without specific prior written permission.
5951 *
5952 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5953 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5954 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5955 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5956 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5957 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5958 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5959 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5960 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5961 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5962 * SUCH DAMAGE.
5963 *
5964 * @(#)signal.h 8.4 (Berkeley) 5/4/95
5965 * $FreeBSD$
5966 */
5967
5968#ifndef _SYS__SIGSET_H_
5969#define _SYS__SIGSET_H_
5970
5971/*
5972 * sigset_t macros.
5973 */
5974#define _SIG_WORDS 4
5975#define _SIG_MAXSIG 128
5976#define _SIG_IDX(sig) ((sig) - 1)
5977#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
5978#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31))
5979#define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0)
5980
5981typedef struct __sigset {
5982 __uint32_t __bits[_SIG_WORDS];
5983} __sigset_t;
5984
5985#if defined(_KERNEL) && defined(COMPAT_43)
5986typedef unsigned int osigset_t;
5987#endif
5988# 58 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_sigset.h" 3 4
5989
5990#endif /* !_SYS__SIGSET_H_ */
5991# 60 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_sigset.h" 3 4
5992# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 2 3 4
5993#if 0 /* expanded by -frewrite-includes */
5994#include <sys/_timeval.h>
5995#endif /* expanded by -frewrite-includes */
5996# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
5997# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timeval.h" 1 3 4
5998/*-
5999 * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
6000 * All rights reserved.
6001 *
6002 * Redistribution and use in source and binary forms, with or without
6003 * modification, are permitted provided that the following conditions
6004 * are met:
6005 * 1. Redistributions of source code must retain the above copyright
6006 * notice, this list of conditions and the following disclaimer.
6007 * 2. Redistributions in binary form must reproduce the above copyright
6008 * notice, this list of conditions and the following disclaimer in the
6009 * documentation and/or other materials provided with the distribution.
6010 *
6011 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
6012 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6013 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6014 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
6015 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6016 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6017 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6018 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6019 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6020 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6021 * SUCH DAMAGE.
6022 *
6023 * $FreeBSD$
6024 */
6025
6026#ifndef _SYS__TIMEVAL_H_
6027#define _SYS__TIMEVAL_H_
6028
6029#if 0 /* expanded by -frewrite-includes */
6030#include <sys/_types.h>
6031#endif /* expanded by -frewrite-includes */
6032# 32 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timeval.h" 3 4
6033# 33 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timeval.h" 3 4
6034
6035#ifndef _SUSECONDS_T_DECLARED
6036typedef __suseconds_t suseconds_t;
6037#define _SUSECONDS_T_DECLARED
6038#endif
6039# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timeval.h" 3 4
6040
6041#ifndef _TIME_T_DECLARED
6042typedef __time_t time_t;
6043#define _TIME_T_DECLARED
6044#endif
6045# 43 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timeval.h" 3 4
6046
6047/*
6048 * Structure returned by gettimeofday(2) system call, and used in other calls.
6049 */
6050struct timeval {
6051 time_t tv_sec; /* seconds */
6052 suseconds_t tv_usec; /* and microseconds */
6053};
6054
6055#endif /* !_SYS__TIMEVAL_H_ */
6056# 53 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/_timeval.h" 3 4
6057# 40 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 2 3 4
6058#if 0 /* expanded by -frewrite-includes */
6059#include <sys/timespec.h>
6060#endif /* expanded by -frewrite-includes */
6061# 40 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6062# 41 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6063
6064typedef unsigned long __fd_mask;
6065#if __BSD_VISIBLE
6066typedef __fd_mask fd_mask;
6067#endif
6068# 46 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6069
6070#ifndef _SIGSET_T_DECLARED
6071#define _SIGSET_T_DECLARED
6072typedef __sigset_t sigset_t;
6073#endif
6074# 51 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6075
6076/*
6077 * Select uses bit masks of file descriptors in longs. These macros
6078 * manipulate such bit fields (the filesystem macros use chars).
6079 * FD_SETSIZE may be defined by the user, but the default here should
6080 * be enough for most uses.
6081 */
6082#ifndef FD_SETSIZE
6083#define FD_SETSIZE 1024
6084#endif
6085# 61 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6086
6087#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */
6088#if __BSD_VISIBLE
6089#define NFDBITS _NFDBITS
6090#endif
6091# 66 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6092
6093#ifndef _howmany
6094#define _howmany(x, y) (((x) + ((y) - 1)) / (y))
6095#endif
6096# 70 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6097
6098typedef struct fd_set {
6099 __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)];
6100} fd_set;
6101#if __BSD_VISIBLE
6102#define fds_bits __fds_bits
6103#endif
6104# 77 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6105
6106#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS))
6107#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n))
6108#if __BSD_VISIBLE
6109#define FD_COPY(f, t) (void)(*(t) = *(f))
6110#endif
6111# 83 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6112#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0)
6113#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n))
6114#define FD_ZERO(p) do { \
6115 fd_set *_p; \
6116 __size_t _n; \
6117 \
6118 _p = (p); \
6119 _n = _howmany(FD_SETSIZE, _NFDBITS); \
6120 while (_n > 0) \
6121 _p->__fds_bits[--_n] = 0; \
6122} while (0)
6123
6124#ifndef _KERNEL
6125
6126__BEGIN_DECLS
6127int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict,
6128 const struct timespec *__restrict, const sigset_t *__restrict);
6129#ifndef _SELECT_DECLARED
6130#define _SELECT_DECLARED
6131/* XXX missing restrict type-qualifier */
6132int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
6133#endif
6134# 105 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6135__END_DECLS
6136#endif /* !_KERNEL */
6137# 107 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6138
6139#endif /* _SYS_SELECT_H_ */
6140# 109 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/select.h" 3 4
6141# 366 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 2 3 4
6142
6143/*
6144 * minor() gives a cookie instead of an index since we don't want to
6145 * change the meanings of bits 0-15 or waste time and space shifting
6146 * bits 16-31 for devices that don't use them.
6147 */
6148#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
6149#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */
6150#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */
6151
6152/*
6153 * These declarations belong elsewhere, but are repeated here and in
6154 * <stdio.h> to give broken programs a better chance of working with
6155 * 64-bit off_t's.
6156 */
6157#ifndef _KERNEL
6158__BEGIN_DECLS
6159#ifndef _FTRUNCATE_DECLARED
6160#define _FTRUNCATE_DECLARED
6161int ftruncate(int, off_t);
6162#endif
6163# 387 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
6164#ifndef _LSEEK_DECLARED
6165#define _LSEEK_DECLARED
6166off_t lseek(int, off_t, int);
6167#endif
6168# 391 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
6169#ifndef _MMAP_DECLARED
6170#define _MMAP_DECLARED
6171void * mmap(void *, size_t, int, int, int, off_t);
6172#endif
6173# 395 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
6174#ifndef _TRUNCATE_DECLARED
6175#define _TRUNCATE_DECLARED
6176int truncate(const char *, off_t);
6177#endif
6178# 399 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
6179__END_DECLS
6180#endif /* !_KERNEL */
6181# 401 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
6182
6183#endif /* __BSD_VISIBLE */
6184# 403 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
6185
6186#endif /* !_SYS_TYPES_H_ */
6187# 405 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/types.h" 3 4
6188# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 2 3 4
6189#if 0 /* expanded by -frewrite-includes */
6190#include <sys/unistd.h>
6191#endif /* expanded by -frewrite-includes */
6192# 38 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6193# 1 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 1 3 4
6194/*-
6195 * Copyright (c) 1989, 1993
6196 * The Regents of the University of California. All rights reserved.
6197 *
6198 * Redistribution and use in source and binary forms, with or without
6199 * modification, are permitted provided that the following conditions
6200 * are met:
6201 * 1. Redistributions of source code must retain the above copyright
6202 * notice, this list of conditions and the following disclaimer.
6203 * 2. Redistributions in binary form must reproduce the above copyright
6204 * notice, this list of conditions and the following disclaimer in the
6205 * documentation and/or other materials provided with the distribution.
6206 * 3. Neither the name of the University nor the names of its contributors
6207 * may be used to endorse or promote products derived from this software
6208 * without specific prior written permission.
6209 *
6210 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
6211 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6212 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6213 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
6214 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6215 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6216 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6217 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6218 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6219 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6220 * SUCH DAMAGE.
6221 *
6222 * @(#)unistd.h 8.2 (Berkeley) 1/7/94
6223 * $FreeBSD$
6224 */
6225
6226#ifndef _SYS_UNISTD_H_
6227#define _SYS_UNISTD_H_
6228
6229#if 0 /* expanded by -frewrite-includes */
6230#include <sys/cdefs.h>
6231#endif /* expanded by -frewrite-includes */
6232# 36 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6233# 37 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6234
6235/*
6236 * POSIX options and option groups we unconditionally do or don't
6237 * implement. Those options which are implemented (or not) entirely
6238 * in user mode are defined in <unistd.h>. Please keep this list in
6239 * alphabetical order.
6240 *
6241 * Anything which is defined as zero below **must** have an
6242 * implementation for the corresponding sysconf() which is able to
6243 * determine conclusively whether or not the feature is supported.
6244 * Anything which is defined as other than -1 below **must** have
6245 * complete headers, types, and function declarations as specified by
6246 * the POSIX standard; however, if the relevant sysconf() function
6247 * returns -1, the functions may be stubbed out.
6248 */
6249#define _POSIX_ADVISORY_INFO 200112L
6250#define _POSIX_ASYNCHRONOUS_IO 200112L
6251#define _POSIX_CHOWN_RESTRICTED 1
6252#define _POSIX_CLOCK_SELECTION (-1)
6253#define _POSIX_CPUTIME 200112L
6254#define _POSIX_FSYNC 200112L
6255#define _POSIX_IPV6 0
6256#define _POSIX_JOB_CONTROL 1
6257#define _POSIX_MAPPED_FILES 200112L
6258#define _POSIX_MEMLOCK (-1)
6259#define _POSIX_MEMLOCK_RANGE 200112L
6260#define _POSIX_MEMORY_PROTECTION 200112L
6261#define _POSIX_MESSAGE_PASSING 200112L
6262#define _POSIX_MONOTONIC_CLOCK 200112L
6263#define _POSIX_NO_TRUNC 1
6264#define _POSIX_PRIORITIZED_IO (-1)
6265#define _POSIX_PRIORITY_SCHEDULING 0
6266#define _POSIX_RAW_SOCKETS 200112L
6267#define _POSIX_REALTIME_SIGNALS 200112L
6268#define _POSIX_SEMAPHORES 200112L
6269#define _POSIX_SHARED_MEMORY_OBJECTS 200112L
6270#define _POSIX_SPORADIC_SERVER (-1)
6271#define _POSIX_SYNCHRONIZED_IO (-1)
6272#define _POSIX_TIMEOUTS 200112L
6273#define _POSIX_TIMERS 200112L
6274#define _POSIX_TYPED_MEMORY_OBJECTS (-1)
6275#define _POSIX_VDISABLE 0xff
6276
6277#if __XSI_VISIBLE
6278#define _XOPEN_SHM 1
6279#define _XOPEN_STREAMS (-1)
6280#endif
6281# 84 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6282
6283/*
6284 * Although we have saved user/group IDs, we do not use them in setuid
6285 * as described in POSIX 1003.1, because the feature does not work for
6286 * root. We use the saved IDs in seteuid/setegid, which are not currently
6287 * part of the POSIX 1003.1 specification. XXX revisit for 1003.1-2001
6288 * as this is now mandatory.
6289 */
6290#ifdef _NOT_AVAILABLE
6291#define _POSIX_SAVED_IDS 1 /* saved set-user-ID and set-group-ID */
6292#endif
6293# 95 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6294
6295/* Define the POSIX.1 version we target for compliance. */
6296#define _POSIX_VERSION 200112L
6297
6298/* access function */
6299#define F_OK 0 /* test for existence of file */
6300#define X_OK 0x01 /* test for execute or search permission */
6301#define W_OK 0x02 /* test for write permission */
6302#define R_OK 0x04 /* test for read permission */
6303
6304/* whence values for lseek(2) */
6305#ifndef SEEK_SET
6306#define SEEK_SET 0 /* set file offset to offset */
6307#define SEEK_CUR 1 /* set file offset to current plus offset */
6308#define SEEK_END 2 /* set file offset to EOF plus offset */
6309#endif
6310# 111 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6311#if __BSD_VISIBLE
6312#define SEEK_DATA 3 /* set file offset to next data past offset */
6313#define SEEK_HOLE 4 /* set file offset to next hole past offset */
6314#endif
6315# 115 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6316
6317#ifndef _POSIX_SOURCE
6318/* whence values for lseek(2); renamed by POSIX 1003.1 */
6319#define L_SET SEEK_SET
6320#define L_INCR SEEK_CUR
6321#define L_XTND SEEK_END
6322#endif
6323# 122 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6324
6325/* configurable pathname variables */
6326#define _PC_LINK_MAX 1
6327#define _PC_MAX_CANON 2
6328#define _PC_MAX_INPUT 3
6329#define _PC_NAME_MAX 4
6330#define _PC_PATH_MAX 5
6331#define _PC_PIPE_BUF 6
6332#define _PC_CHOWN_RESTRICTED 7
6333#define _PC_NO_TRUNC 8
6334#define _PC_VDISABLE 9
6335
6336#if __POSIX_VISIBLE >= 199309
6337#define _PC_ASYNC_IO 53
6338#define _PC_PRIO_IO 54
6339#define _PC_SYNC_IO 55
6340#endif
6341# 139 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6342
6343#if __POSIX_VISIBLE >= 200112
6344#define _PC_ALLOC_SIZE_MIN 10
6345#define _PC_FILESIZEBITS 12
6346#define _PC_REC_INCR_XFER_SIZE 14
6347#define _PC_REC_MAX_XFER_SIZE 15
6348#define _PC_REC_MIN_XFER_SIZE 16
6349#define _PC_REC_XFER_ALIGN 17
6350#define _PC_SYMLINK_MAX 18
6351#endif
6352# 149 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6353
6354#if __BSD_VISIBLE
6355#define _PC_ACL_EXTENDED 59
6356#define _PC_ACL_PATH_MAX 60
6357#define _PC_CAP_PRESENT 61
6358#define _PC_INF_PRESENT 62
6359#define _PC_MAC_PRESENT 63
6360#define _PC_ACL_NFS4 64
6361#endif
6362# 158 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6363
6364/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */
6365#define _PC_MIN_HOLE_SIZE 21
6366
6367#if __BSD_VISIBLE
6368/*
6369 * rfork() options.
6370 *
6371 * XXX currently, some operations without RFPROC set are not supported.
6372 */
6373#define RFNAMEG (1<<0) /* UNIMPL new plan9 `name space' */
6374#define RFENVG (1<<1) /* UNIMPL copy plan9 `env space' */
6375#define RFFDG (1<<2) /* copy fd table */
6376#define RFNOTEG (1<<3) /* UNIMPL create new plan9 `note group' */
6377#define RFPROC (1<<4) /* change child (else changes curproc) */
6378#define RFMEM (1<<5) /* share `address space' */
6379#define RFNOWAIT (1<<6) /* give child to init */
6380#define RFCNAMEG (1<<10) /* UNIMPL zero plan9 `name space' */
6381#define RFCENVG (1<<11) /* UNIMPL zero plan9 `env space' */
6382#define RFCFDG (1<<12) /* close all fds, zero fd table */
6383#define RFTHREAD (1<<13) /* enable kernel thread support */
6384#define RFSIGSHARE (1<<14) /* share signal handlers */
6385#define RFLINUXTHPN (1<<16) /* do linux clone exit parent notification */
6386#define RFSTOPPED (1<<17) /* leave child in a stopped state */
6387#define RFHIGHPID (1<<18) /* use a pid higher than 10 (idleproc) */
6388#define RFTSIGZMB (1<<19) /* select signal for exit parent notification */
6389#define RFTSIGSHIFT 20 /* selected signal number is in bits 20-27 */
6390#define RFTSIGMASK 0xFF
6391#define RFTSIGNUM(flags) (((flags) >> RFTSIGSHIFT) & RFTSIGMASK)
6392#define RFTSIGFLAGS(signum) ((signum) << RFTSIGSHIFT)
6393#define RFPROCDESC (1<<28) /* return a process descriptor */
6394#define RFPPWAIT (1<<31) /* parent sleeps until child exits (vfork) */
6395#define RFFLAGS (RFFDG | RFPROC | RFMEM | RFNOWAIT | RFCFDG | \
6396 RFTHREAD | RFSIGSHARE | RFLINUXTHPN | RFSTOPPED | RFHIGHPID | RFTSIGZMB | \
6397 RFPROCDESC | RFPPWAIT)
6398#define RFKERNELONLY (RFSTOPPED | RFHIGHPID | RFPPWAIT | RFPROCDESC)
6399
6400#endif /* __BSD_VISIBLE */
6401# 196 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6402
6403#endif /* !_SYS_UNISTD_H_ */
6404# 198 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/sys/unistd.h" 3 4
6405# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 2 3 4
6406#if 0 /* expanded by -frewrite-includes */
6407#include <sys/_null.h>
6408#endif /* expanded by -frewrite-includes */
6409# 39 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6410# 40 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6411#if 0 /* expanded by -frewrite-includes */
6412#include <sys/_types.h>
6413#endif /* expanded by -frewrite-includes */
6414# 40 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6415# 41 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6416
6417#ifndef _GID_T_DECLARED
6418typedef __gid_t gid_t;
6419#define _GID_T_DECLARED
6420#endif
6421# 46 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6422
6423#ifndef _OFF_T_DECLARED
6424typedef __off_t off_t;
6425#define _OFF_T_DECLARED
6426#endif
6427# 51 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6428
6429#ifndef _PID_T_DECLARED
6430typedef __pid_t pid_t;
6431#define _PID_T_DECLARED
6432#endif
6433# 56 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6434
6435#ifndef _SIZE_T_DECLARED
6436typedef __size_t size_t;
6437#define _SIZE_T_DECLARED
6438#endif
6439# 61 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6440
6441#ifndef _SSIZE_T_DECLARED
6442typedef __ssize_t ssize_t;
6443#define _SSIZE_T_DECLARED
6444#endif
6445# 66 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6446
6447#ifndef _UID_T_DECLARED
6448typedef __uid_t uid_t;
6449#define _UID_T_DECLARED
6450#endif
6451# 71 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6452
6453#ifndef _USECONDS_T_DECLARED
6454typedef __useconds_t useconds_t;
6455#define _USECONDS_T_DECLARED
6456#endif
6457# 76 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6458
6459#define STDIN_FILENO 0 /* standard input file descriptor */
6460#define STDOUT_FILENO 1 /* standard output file descriptor */
6461#define STDERR_FILENO 2 /* standard error file descriptor */
6462
6463#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
6464#define F_ULOCK 0 /* unlock locked section */
6465#define F_LOCK 1 /* lock a section for exclusive use */
6466#define F_TLOCK 2 /* test and lock a section for exclusive use */
6467#define F_TEST 3 /* test a section for locks by other procs */
6468#endif
6469# 87 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6470
6471/*
6472 * POSIX options and option groups we unconditionally do or don't
6473 * implement. This list includes those options which are exclusively
6474 * implemented (or not) in user mode. Please keep this list in
6475 * alphabetical order.
6476 *
6477 * Anything which is defined as zero below **must** have an
6478 * implementation for the corresponding sysconf() which is able to
6479 * determine conclusively whether or not the feature is supported.
6480 * Anything which is defined as other than -1 below **must** have
6481 * complete headers, types, and function declarations as specified by
6482 * the POSIX standard; however, if the relevant sysconf() function
6483 * returns -1, the functions may be stubbed out.
6484 */
6485#define _POSIX_BARRIERS 200112L
6486#define _POSIX_CPUTIME 200112L
6487#define _POSIX_READER_WRITER_LOCKS 200112L
6488#define _POSIX_REGEXP 1
6489#define _POSIX_SHELL 1
6490#define _POSIX_SPAWN 200112L
6491#define _POSIX_SPIN_LOCKS 200112L
6492#define _POSIX_THREAD_ATTR_STACKADDR 200112L
6493#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
6494#define _POSIX_THREAD_CPUTIME 200112L
6495#define _POSIX_THREAD_PRIO_INHERIT 200112L
6496#define _POSIX_THREAD_PRIO_PROTECT 200112L
6497#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L
6498#define _POSIX_THREAD_PROCESS_SHARED 200112L
6499#define _POSIX_THREAD_SAFE_FUNCTIONS -1
6500#define _POSIX_THREAD_SPORADIC_SERVER -1
6501#define _POSIX_THREADS 200112L
6502#define _POSIX_TRACE -1
6503#define _POSIX_TRACE_EVENT_FILTER -1
6504#define _POSIX_TRACE_INHERIT -1
6505#define _POSIX_TRACE_LOG -1
6506#define _POSIX2_C_BIND 200112L /* mandatory */
6507#define _POSIX2_C_DEV -1 /* need c99 utility */
6508#define _POSIX2_CHAR_TERM 1
6509#define _POSIX2_FORT_DEV -1 /* need fort77 utility */
6510#define _POSIX2_FORT_RUN 200112L
6511#define _POSIX2_LOCALEDEF -1
6512#define _POSIX2_PBS -1
6513#define _POSIX2_PBS_ACCOUNTING -1
6514#define _POSIX2_PBS_CHECKPOINT -1
6515#define _POSIX2_PBS_LOCATE -1
6516#define _POSIX2_PBS_MESSAGE -1
6517#define _POSIX2_PBS_TRACK -1
6518#define _POSIX2_SW_DEV -1 /* XXX ??? */
6519#define _POSIX2_UPE 200112L
6520#define _V6_ILP32_OFF32 -1
6521#define _V6_ILP32_OFFBIG 0
6522#define _V6_LP64_OFF64 0
6523#define _V6_LPBIG_OFFBIG -1
6524
6525#if __XSI_VISIBLE
6526#define _XOPEN_CRYPT -1 /* XXX ??? */
6527#define _XOPEN_ENH_I18N -1 /* mandatory in XSI */
6528#define _XOPEN_LEGACY -1
6529#define _XOPEN_REALTIME -1
6530#define _XOPEN_REALTIME_THREADS -1
6531#define _XOPEN_UNIX -1
6532#endif
6533# 150 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6534
6535/* Define the POSIX.2 version we target for compliance. */
6536#define _POSIX2_VERSION 199212L
6537
6538/*
6539 * POSIX-style system configuration variable accessors (for the
6540 * sysconf function). The kernel does not directly implement the
6541 * sysconf() interface; rather, a C library stub translates references
6542 * to sysconf() into calls to sysctl() using a giant switch statement.
6543 * Those that are marked `user' are implemented entirely in the C
6544 * library and never query the kernel. pathconf() is implemented
6545 * directly by the kernel so those are not defined here.
6546 */
6547#define _SC_ARG_MAX 1
6548#define _SC_CHILD_MAX 2
6549#define _SC_CLK_TCK 3
6550#define _SC_NGROUPS_MAX 4
6551#define _SC_OPEN_MAX 5
6552#define _SC_JOB_CONTROL 6
6553#define _SC_SAVED_IDS 7
6554#define _SC_VERSION 8
6555#define _SC_BC_BASE_MAX 9 /* user */
6556#define _SC_BC_DIM_MAX 10 /* user */
6557#define _SC_BC_SCALE_MAX 11 /* user */
6558#define _SC_BC_STRING_MAX 12 /* user */
6559#define _SC_COLL_WEIGHTS_MAX 13 /* user */
6560#define _SC_EXPR_NEST_MAX 14 /* user */
6561#define _SC_LINE_MAX 15 /* user */
6562#define _SC_RE_DUP_MAX 16 /* user */
6563#define _SC_2_VERSION 17 /* user */
6564#define _SC_2_C_BIND 18 /* user */
6565#define _SC_2_C_DEV 19 /* user */
6566#define _SC_2_CHAR_TERM 20 /* user */
6567#define _SC_2_FORT_DEV 21 /* user */
6568#define _SC_2_FORT_RUN 22 /* user */
6569#define _SC_2_LOCALEDEF 23 /* user */
6570#define _SC_2_SW_DEV 24 /* user */
6571#define _SC_2_UPE 25 /* user */
6572#define _SC_STREAM_MAX 26 /* user */
6573#define _SC_TZNAME_MAX 27 /* user */
6574
6575#if __POSIX_VISIBLE >= 199309
6576#define _SC_ASYNCHRONOUS_IO 28
6577#define _SC_MAPPED_FILES 29
6578#define _SC_MEMLOCK 30
6579#define _SC_MEMLOCK_RANGE 31
6580#define _SC_MEMORY_PROTECTION 32
6581#define _SC_MESSAGE_PASSING 33
6582#define _SC_PRIORITIZED_IO 34
6583#define _SC_PRIORITY_SCHEDULING 35
6584#define _SC_REALTIME_SIGNALS 36
6585#define _SC_SEMAPHORES 37
6586#define _SC_FSYNC 38
6587#define _SC_SHARED_MEMORY_OBJECTS 39
6588#define _SC_SYNCHRONIZED_IO 40
6589#define _SC_TIMERS 41
6590#define _SC_AIO_LISTIO_MAX 42
6591#define _SC_AIO_MAX 43
6592#define _SC_AIO_PRIO_DELTA_MAX 44
6593#define _SC_DELAYTIMER_MAX 45
6594#define _SC_MQ_OPEN_MAX 46
6595#define _SC_PAGESIZE 47
6596#define _SC_RTSIG_MAX 48
6597#define _SC_SEM_NSEMS_MAX 49
6598#define _SC_SEM_VALUE_MAX 50
6599#define _SC_SIGQUEUE_MAX 51
6600#define _SC_TIMER_MAX 52
6601#endif
6602# 218 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6603
6604#if __POSIX_VISIBLE >= 200112
6605#define _SC_2_PBS 59 /* user */
6606#define _SC_2_PBS_ACCOUNTING 60 /* user */
6607#define _SC_2_PBS_CHECKPOINT 61 /* user */
6608#define _SC_2_PBS_LOCATE 62 /* user */
6609#define _SC_2_PBS_MESSAGE 63 /* user */
6610#define _SC_2_PBS_TRACK 64 /* user */
6611#define _SC_ADVISORY_INFO 65
6612#define _SC_BARRIERS 66 /* user */
6613#define _SC_CLOCK_SELECTION 67
6614#define _SC_CPUTIME 68
6615#define _SC_FILE_LOCKING 69
6616#define _SC_GETGR_R_SIZE_MAX 70 /* user */
6617#define _SC_GETPW_R_SIZE_MAX 71 /* user */
6618#define _SC_HOST_NAME_MAX 72
6619#define _SC_LOGIN_NAME_MAX 73
6620#define _SC_MONOTONIC_CLOCK 74
6621#define _SC_MQ_PRIO_MAX 75
6622#define _SC_READER_WRITER_LOCKS 76 /* user */
6623#define _SC_REGEXP 77 /* user */
6624#define _SC_SHELL 78 /* user */
6625#define _SC_SPAWN 79 /* user */
6626#define _SC_SPIN_LOCKS 80 /* user */
6627#define _SC_SPORADIC_SERVER 81
6628#define _SC_THREAD_ATTR_STACKADDR 82 /* user */
6629#define _SC_THREAD_ATTR_STACKSIZE 83 /* user */
6630#define _SC_THREAD_CPUTIME 84 /* user */
6631#define _SC_THREAD_DESTRUCTOR_ITERATIONS 85 /* user */
6632#define _SC_THREAD_KEYS_MAX 86 /* user */
6633#define _SC_THREAD_PRIO_INHERIT 87 /* user */
6634#define _SC_THREAD_PRIO_PROTECT 88 /* user */
6635#define _SC_THREAD_PRIORITY_SCHEDULING 89 /* user */
6636#define _SC_THREAD_PROCESS_SHARED 90 /* user */
6637#define _SC_THREAD_SAFE_FUNCTIONS 91 /* user */
6638#define _SC_THREAD_SPORADIC_SERVER 92 /* user */
6639#define _SC_THREAD_STACK_MIN 93 /* user */
6640#define _SC_THREAD_THREADS_MAX 94 /* user */
6641#define _SC_TIMEOUTS 95 /* user */
6642#define _SC_THREADS 96 /* user */
6643#define _SC_TRACE 97 /* user */
6644#define _SC_TRACE_EVENT_FILTER 98 /* user */
6645#define _SC_TRACE_INHERIT 99 /* user */
6646#define _SC_TRACE_LOG 100 /* user */
6647#define _SC_TTY_NAME_MAX 101 /* user */
6648#define _SC_TYPED_MEMORY_OBJECTS 102
6649#define _SC_V6_ILP32_OFF32 103 /* user */
6650#define _SC_V6_ILP32_OFFBIG 104 /* user */
6651#define _SC_V6_LP64_OFF64 105 /* user */
6652#define _SC_V6_LPBIG_OFFBIG 106 /* user */
6653#define _SC_IPV6 118
6654#define _SC_RAW_SOCKETS 119
6655#define _SC_SYMLOOP_MAX 120
6656#endif
6657# 272 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6658
6659#if __XSI_VISIBLE
6660#define _SC_ATEXIT_MAX 107 /* user */
6661#define _SC_IOV_MAX 56
6662#define _SC_PAGE_SIZE _SC_PAGESIZE
6663#define _SC_XOPEN_CRYPT 108 /* user */
6664#define _SC_XOPEN_ENH_I18N 109 /* user */
6665#define _SC_XOPEN_LEGACY 110 /* user */
6666#define _SC_XOPEN_REALTIME 111
6667#define _SC_XOPEN_REALTIME_THREADS 112
6668#define _SC_XOPEN_SHM 113
6669#define _SC_XOPEN_STREAMS 114
6670#define _SC_XOPEN_UNIX 115
6671#define _SC_XOPEN_VERSION 116
6672#define _SC_XOPEN_XCU_VERSION 117 /* user */
6673#endif
6674# 288 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6675
6676#if __BSD_VISIBLE
6677#define _SC_NPROCESSORS_CONF 57
6678#define _SC_NPROCESSORS_ONLN 58
6679#define _SC_CPUSET_SIZE 122
6680#endif
6681# 294 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6682
6683/* Extensions found in Solaris and Linux. */
6684#define _SC_PHYS_PAGES 121
6685
6686/* Keys for the confstr(3) function. */
6687#if __POSIX_VISIBLE >= 199209
6688#define _CS_PATH 1 /* default value of PATH */
6689#endif
6690# 302 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6691
6692#if __POSIX_VISIBLE >= 200112
6693#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 2
6694#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 3
6695#define _CS_POSIX_V6_ILP32_OFF32_LIBS 4
6696#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 5
6697#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 6
6698#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 7
6699#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 8
6700#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 9
6701#define _CS_POSIX_V6_LP64_OFF64_LIBS 10
6702#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 11
6703#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 12
6704#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 13
6705#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 14
6706#endif
6707# 318 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6708
6709__BEGIN_DECLS
6710/* 1003.1-1990 */
6711void _exit(int) __dead2;
6712int access(const char *, int);
6713unsigned int alarm(unsigned int);
6714int chdir(const char *);
6715int chown(const char *, uid_t, gid_t);
6716int close(int);
6717void closefrom(int);
6718int dup(int);
6719int dup2(int, int);
6720int execl(const char *, const char *, ...) __null_sentinel;
6721int execle(const char *, const char *, ...);
6722int execlp(const char *, const char *, ...) __null_sentinel;
6723int execv(const char *, char * const *);
6724int execve(const char *, char * const *, char * const *);
6725int execvp(const char *, char * const *);
6726pid_t fork(void);
6727long fpathconf(int, int);
6728char *getcwd(char *, size_t);
6729gid_t getegid(void);
6730uid_t geteuid(void);
6731gid_t getgid(void);
6732int getgroups(int, gid_t []);
6733char *getlogin(void);
6734pid_t getpgrp(void);
6735pid_t getpid(void);
6736pid_t getppid(void);
6737uid_t getuid(void);
6738int isatty(int);
6739int link(const char *, const char *);
6740#ifndef _LSEEK_DECLARED
6741#define _LSEEK_DECLARED
6742off_t lseek(int, off_t, int);
6743#endif
6744# 354 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6745long pathconf(const char *, int);
6746int pause(void);
6747int pipe(int *);
6748ssize_t read(int, void *, size_t);
6749int rmdir(const char *);
6750int setgid(gid_t);
6751int setpgid(pid_t, pid_t);
6752pid_t setsid(void);
6753int setuid(uid_t);
6754unsigned int sleep(unsigned int);
6755long sysconf(int);
6756pid_t tcgetpgrp(int);
6757int tcsetpgrp(int, pid_t);
6758char *ttyname(int);
6759int ttyname_r(int, char *, size_t);
6760int unlink(const char *);
6761ssize_t write(int, const void *, size_t);
6762
6763/* 1003.2-1992 */
6764#if __POSIX_VISIBLE >= 199209 || __XSI_VISIBLE
6765size_t confstr(int, char *, size_t);
6766#ifndef _GETOPT_DECLARED
6767#define _GETOPT_DECLARED
6768int getopt(int, char * const [], const char *);
6769
6770extern char *optarg; /* getopt(3) external variables */
6771extern int optind, opterr, optopt;
6772#endif /* _GETOPT_DECLARED */
6773# 382 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6774#endif
6775# 383 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6776
6777/* ISO/IEC 9945-1: 1996 */
6778#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
6779int fsync(int);
6780int fdatasync(int);
6781
6782/*
6783 * ftruncate() was in the POSIX Realtime Extension (it's used for shared
6784 * memory), but truncate() was not.
6785 */
6786#ifndef _FTRUNCATE_DECLARED
6787#define _FTRUNCATE_DECLARED
6788int ftruncate(int, off_t);
6789#endif
6790# 397 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6791#endif
6792# 398 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6793
6794#if __POSIX_VISIBLE >= 199506
6795int getlogin_r(char *, int);
6796#endif
6797# 402 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6798
6799/* 1003.1-2001 */
6800#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
6801int fchown(int, uid_t, gid_t);
6802ssize_t readlink(const char * __restrict, char * __restrict, size_t);
6803#endif
6804# 408 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6805#if __POSIX_VISIBLE >= 200112
6806int gethostname(char *, size_t);
6807int setegid(gid_t);
6808int seteuid(uid_t);
6809#endif
6810# 413 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6811
6812/* 1003.1-2008 */
6813#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
6814int getsid(pid_t _pid);
6815int fchdir(int);
6816int getpgid(pid_t _pid);
6817int lchown(const char *, uid_t, gid_t);
6818ssize_t pread(int, void *, size_t, off_t);
6819ssize_t pwrite(int, const void *, size_t, off_t);
6820
6821/* See comment at ftruncate() above. */
6822#ifndef _TRUNCATE_DECLARED
6823#define _TRUNCATE_DECLARED
6824int truncate(const char *, off_t);
6825#endif
6826# 428 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6827#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
6828# 429 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6829
6830#if __POSIX_VISIBLE >= 200809
6831int faccessat(int, const char *, int, int);
6832int fchownat(int, const char *, uid_t, gid_t, int);
6833int fexecve(int, char *const [], char *const []);
6834int linkat(int, const char *, int, const char *, int);
6835ssize_t readlinkat(int, const char * __restrict, char * __restrict, size_t);
6836int symlinkat(const char *, int, const char *);
6837int unlinkat(int, const char *, int);
6838#endif /* __POSIX_VISIBLE >= 200809 */
6839# 439 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6840
6841/*
6842 * symlink() was originally in POSIX.1a, which was withdrawn after
6843 * being overtaken by events (1003.1-2001). It was in XPG4.2, and of
6844 * course has been in BSD since 4.2.
6845 */
6846#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 402
6847int symlink(const char * __restrict, const char * __restrict);
6848#endif
6849# 448 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6850
6851/* X/Open System Interfaces */
6852#if __XSI_VISIBLE
6853char *crypt(const char *, const char *);
6854long gethostid(void);
6855int lockf(int, int, off_t);
6856int nice(int);
6857int setregid(gid_t, gid_t);
6858int setreuid(uid_t, uid_t);
6859
6860#ifndef _SWAB_DECLARED
6861#define _SWAB_DECLARED
6862void swab(const void * __restrict, void * __restrict, ssize_t);
6863#endif /* _SWAB_DECLARED */
6864# 462 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6865
6866void sync(void);
6867
6868#endif /* __XSI_VISIBLE */
6869# 466 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6870
6871#if (__XSI_VISIBLE && __XSI_VISIBLE <= 500) || __BSD_VISIBLE
6872int brk(const void *);
6873int chroot(const char *);
6874int getdtablesize(void);
6875int getpagesize(void) __pure2;
6876char *getpass(const char *);
6877void *sbrk(intptr_t);
6878#endif
6879# 475 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6880
6881#if (__XSI_VISIBLE && __XSI_VISIBLE <= 600) || __BSD_VISIBLE
6882char *getwd(char *); /* obsoleted by getcwd() */
6883useconds_t
6884 ualarm(useconds_t, useconds_t);
6885int usleep(useconds_t);
6886pid_t vfork(void) __returns_twice;
6887#endif
6888# 483 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6889
6890#if __BSD_VISIBLE
6891struct timeval; /* select(2) */
6892
6893struct crypt_data {
6894 int initialized; /* For compatibility with glibc. */
6895 char __buf[256]; /* Buffer returned by crypt_r(). */
6896};
6897
6898int acct(const char *);
6899int async_daemon(void);
6900int check_utility_compat(const char *);
6901const char *
6902 crypt_get_format(void);
6903char *crypt_r(const char *, const char *, struct crypt_data *);
6904int crypt_set_format(const char *);
6905int dup3(int, int, int);
6906int eaccess(const char *, int);
6907void endusershell(void);
6908int exect(const char *, char * const *, char * const *);
6909int execvP(const char *, const char *, char * const *);
6910int feature_present(const char *);
6911char *fflagstostr(u_long);
6912int getdomainname(char *, int);
6913int getgrouplist(const char *, gid_t, gid_t *, int *);
6914int getloginclass(char *, size_t);
6915mode_t getmode(const void *, mode_t);
6916int getosreldate(void);
6917int getpeereid(int, uid_t *, gid_t *);
6918int getresgid(gid_t *, gid_t *, gid_t *);
6919int getresuid(uid_t *, uid_t *, uid_t *);
6920char *getusershell(void);
6921int initgroups(const char *, gid_t);
6922int iruserok(unsigned long, int, const char *, const char *);
6923int iruserok_sa(const void *, int, int, const char *, const char *);
6924int issetugid(void);
6925void __FreeBSD_libc_enter_restricted_mode(void);
6926long lpathconf(const char *, int);
6927#ifndef _MKDTEMP_DECLARED
6928char *mkdtemp(char *);
6929#define _MKDTEMP_DECLARED
6930#endif
6931# 525 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6932#ifndef _MKNOD_DECLARED
6933int mknod(const char *, mode_t, dev_t);
6934#define _MKNOD_DECLARED
6935#endif
6936# 529 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6937#ifndef _MKSTEMP_DECLARED
6938int mkstemp(char *);
6939#define _MKSTEMP_DECLARED
6940#endif
6941# 533 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6942int mkstemps(char *, int);
6943#ifndef _MKTEMP_DECLARED
6944char *mktemp(char *);
6945#define _MKTEMP_DECLARED
6946#endif
6947# 538 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6948int nfssvc(int, void *);
6949int nlm_syscall(int, int, int, char **);
6950int pipe2(int *, int);
6951int profil(char *, size_t, vm_offset_t, int);
6952int rcmd(char **, int, const char *, const char *, const char *, int *);
6953int rcmd_af(char **, int, const char *,
6954 const char *, const char *, int *, int);
6955int rcmdsh(char **, int, const char *,
6956 const char *, const char *, const char *);
6957char *re_comp(const char *);
6958int re_exec(const char *);
6959int reboot(int);
6960int revoke(const char *);
6961pid_t rfork(int);
6962pid_t rfork_thread(int, void *, int (*)(void *), void *);
6963int rresvport(int *);
6964int rresvport_af(int *, int);
6965int ruserok(const char *, int, const char *, const char *);
6966#if __BSD_VISIBLE
6967#ifndef _SELECT_DECLARED
6968#define _SELECT_DECLARED
6969int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
6970#endif
6971# 561 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6972#endif
6973# 562 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
6974int setdomainname(const char *, int);
6975int setgroups(int, const gid_t *);
6976void sethostid(long);
6977int sethostname(const char *, int);
6978int setlogin(const char *);
6979int setloginclass(const char *);
6980void *setmode(const char *);
6981int setpgrp(pid_t, pid_t); /* obsoleted by setpgid() */
6982void setproctitle(const char *_fmt, ...) __printf0like(1, 2);
6983int setresgid(gid_t, gid_t, gid_t);
6984int setresuid(uid_t, uid_t, uid_t);
6985int setrgid(gid_t);
6986int setruid(uid_t);
6987void setusershell(void);
6988int strtofflags(char **, u_long *, u_long *);
6989int swapon(const char *);
6990int swapoff(const char *);
6991int syscall(int, ...);
6992off_t __syscall(quad_t, ...);
6993int undelete(const char *);
6994int unwhiteout(const char *);
6995void *valloc(size_t); /* obsoleted by malloc() */
6996
6997#ifndef _OPTRESET_DECLARED
6998#define _OPTRESET_DECLARED
6999extern int optreset; /* getopt(3) external variable */
7000#endif
7001# 589 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
7002
7003#if __has_feature(capabilities)
7004ssize_t write_c(int, __capability const void *, size_t);
7005#endif
7006# 593 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
7007#endif /* __BSD_VISIBLE */
7008# 594 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
7009__END_DECLS
7010
7011#endif /* !_UNISTD_H_ */
7012# 597 "/local/scratch/alr48/cheri/output-release/sdk256/sysroot/usr/include/unistd.h" 3 4
7013# 42 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h" 2
7014#if 0 /* expanded by -frewrite-includes */
7015# include <strings.h>
7016#endif /* expanded by -frewrite-includes */
7017# 42 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
7018# 43 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
7019# define TIMEB timeb
7020# define OPENFLAGS_WRITE O_WRONLY|O_CREAT|O_TRUNC
7021# define OPENFLAGS_READ O_RDONLY
7022# define OPEN_PERMISSIONS S_IRUSR | S_IWUSR
7023
7024# if __STDC_VERSION__ >= 199901L
7025 /* "inline" is a keyword */
7026# else
7027# 51 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
7028# define inline /* nothing */
7029# endif
7030# 53 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
7031#endif
7032# 54 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
7033
7034#if defined(WIN32) && !defined(__GNUC__)
7035typedef __int64 int64;
7036# define FORMAT_OFF_T "I64d"
7037# ifndef INT64_MIN
7038# define INT64_MIN (-9223372036854775807i64 - 1i64)
7039# endif
7040# 61 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
7041#else
7042# 62 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
7043typedef long long int64;
7044# define FORMAT_OFF_T "lld"
7045# ifndef INT64_MIN
7046# define INT64_MIN (-9223372036854775807LL - 1LL)
7047# endif
7048# 67 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
7049#endif
7050# 68 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
7051
7052#endif
7053# 70 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/win32.h"
7054# 35 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 2
7055#if 0 /* expanded by -frewrite-includes */
7056#include "defines.h"
7057#endif /* expanded by -frewrite-includes */
7058# 35 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
7059# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/defines.h" 1
7060
7061/*!
7062 **************************************************************************
7063 * \file defines.h
7064 *
7065 * \brief
7066 * Header file containing some useful global definitions
7067 *
7068 * \author
7069 * Detlev Marpe
7070 * Copyright (C) 2000 HEINRICH HERTZ INSTITUTE All Rights Reserved.
7071 *
7072 * \date
7073 * 21. March 2001
7074 **************************************************************************
7075 */
7076
7077
7078#ifndef _DEFINES_H_
7079#define _DEFINES_H_
7080
7081#if defined _DEBUG
7082#define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
7083#else
7084# 25 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/defines.h"
7085#define TRACE 0 //!< 0:Trace off 1:Trace on 2:detailed CABAC context information
7086#endif
7087# 27 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/defines.h"
7088
7089#define GET_METIME 1 //!< Enables or disables ME computation time
7090#define DUMP_DPB 0 //!< Dump dbp for debug purposes
7091typedef unsigned char byte; //!< byte type definition
7092
7093#define RC_MAX_TEMPORAL_LEVELS 5
7094
7095//#define BEST_NZ_COEFF 1 // yuwen 2005.11.03 => for high complexity mode decision (CAVLC, #TotalCoeff)
7096
7097//FREXT Profile IDC definitions
7098#define FREXT_HP 100 //!< YUV 4:2:0/8 "High"
7099#define FREXT_Hi10P 110 //!< YUV 4:2:0/10 "High 10"
7100#define FREXT_Hi422 122 //!< YUV 4:2:2/10 "High 4:2:2"
7101#define FREXT_Hi444 144 //!< YUV 4:4:4/12 "High 4:4:4"
7102
7103#define ZEROSNR 1
7104
7105// CAVLC
7106#define LUMA 0
7107#define LUMA_INTRA16x16DC 1
7108#define LUMA_INTRA16x16AC 2
7109
7110#define LEVEL_NUM 6
7111#define TOTRUN_NUM 15
7112#define RUNBEFORE_NUM 7
7113
7114#define CAVLC_LEVEL_LIMIT 2063
7115
7116//--- block types for CABAC
7117#define LUMA_16DC 0
7118#define LUMA_16AC 1
7119#define LUMA_8x8 2
7120#define LUMA_8x4 3
7121#define LUMA_4x8 4
7122#define LUMA_4x4 5
7123#define CHROMA_DC 6
7124#define CHROMA_AC 7
7125#define CHROMA_DC_2x4 8
7126#define CHROMA_DC_4x4 9
7127#define NUM_BLOCK_TYPES 10
7128
7129#define _FULL_SEARCH_RANGE_
7130#define _ADAPT_LAST_GROUP_
7131#define _CHANGE_QP_
7132#define _LEAKYBUCKET_
7133
7134// ---------------------------------------------------------------------------------
7135// FLAGS and DEFINES for new chroma intra prediction, Dzung Hoang
7136// Threshold values to zero out quantized transform coefficients.
7137// Recommend that _CHROMA_COEFF_COST_ be low to improve chroma quality
7138#define _LUMA_COEFF_COST_ 4 //!< threshold for luma coeffs
7139#define _CHROMA_COEFF_COST_ 4 //!< threshold for chroma coeffs, used to be 7
7140#define _LUMA_MB_COEFF_COST_ 5 //!< threshold for luma coeffs of inter Macroblocks
7141#define _LUMA_8x8_COEFF_COST_ 5 //!< threshold for luma coeffs of 8x8 Inter Partition
7142
7143#define IMG_PAD_SIZE 20 //!< Number of pixels padded around the reference frame (>=4)
7144#define IMG_PAD_SIZE_TIMES4 80 //!< Number of pixels padded around the reference frame in subpel units(>=16)
7145
7146#define MAX_VALUE 999999 //!< used for start value for some variables
7147#define INVALIDINDEX (-135792468)
7148
7149#define P8x8 8
7150#define I4MB 9
7151#define I16MB 10
7152#define IBLOCK 11
7153#define SI4MB 12
7154#define I8MB 13
7155#define IPCM 14
7156#define MAXMODE 15
7157
7158
7159#define LAMBDA_ACCURACY_BITS 16
7160#define LAMBDA_FACTOR(lambda) ((int)((double)(1<<LAMBDA_ACCURACY_BITS)*lambda+0.5))
7161#define WEIGHTED_COST(factor,bits) (((factor)*(bits))>>LAMBDA_ACCURACY_BITS)
7162#define MV_COST(f,s,cx,cy,px,py) (WEIGHTED_COST(f,mvbits[((cx)<<(s))-px]+mvbits[((cy)<<(s))-py]))
7163#define MV_COST_SMP(f,cx,cy,px,py) (WEIGHTED_COST(f,mvbits[cx-px]+mvbits[cy-py]))
7164#define REF_COST(f,ref,list_offset) (WEIGHTED_COST(f,((listXsize[list_offset]<=1)? 0:refbits[(ref)])))
7165
7166#define IS_INTRA(MB) ((MB)->mb_type==I4MB || (MB)->mb_type==I16MB || (MB)->mb_type==I8MB || (MB)->mb_type==IPCM)
7167#define IS_NEWINTRA(MB) ((MB)->mb_type==I16MB)
7168#define IS_OLDINTRA(MB) ((MB)->mb_type==I4MB)
7169#define IS_IPCM(MB) ((MB)->mb_type==IPCM)
7170
7171#define IS_INTER(MB) ((MB)->mb_type!=I4MB && (MB)->mb_type!=I16MB && (MB)->mb_type!=I8MB)
7172#define IS_INTERMV(MB) ((MB)->mb_type!=I4MB && (MB)->mb_type!=I16MB && (MB)->mb_type!=I8MB && (MB)->mb_type!=0)
7173#define IS_DIRECT(MB) ((MB)->mb_type==0 && (img->type==B_SLICE))
7174#define IS_COPY(MB) ((MB)->mb_type==0 && (img->type==P_SLICE||img ->type==SP_SLICE))
7175#define IS_P8x8(MB) ((MB)->mb_type==P8x8)
7176
7177// Quantization parameter range
7178
7179#define MIN_QP 0
7180#define MAX_QP 51
7181#define SHIFT_QP 12
7182
7183// Direct Mode types
7184#define DIR_TEMPORAL 0 //!< Temporal Direct Mode
7185#define DIR_SPATIAL 1 //!< Spatial Direct Mode
7186
7187#define MAX_REFERENCE_PICTURES 32
7188
7189#define BLOCK_SHIFT 2
7190#define BLOCK_SIZE 4
7191#define BLOCK_SIZE8x8 8
7192#define MB_BLOCK_SIZE 16
7193#define MB_BLOCK_SHIFT 4
7194
7195// These variables relate to the subpel accuracy supported by the software (1/4)
7196#define BLOCK_SIZE_SP 16 // BLOCK_SIZE << 2
7197#define BLOCK_SIZE8x8_SP 32 // BLOCK_SIZE8x8 << 2
7198
7199// number of intra prediction modes
7200#define NO_INTRA_PMODE 9
7201
7202// 4x4 intra prediction modes
7203#define VERT_PRED 0
7204#define HOR_PRED 1
7205#define DC_PRED 2
7206#define DIAG_DOWN_LEFT_PRED 3
7207#define DIAG_DOWN_RIGHT_PRED 4
7208#define VERT_RIGHT_PRED 5
7209#define HOR_DOWN_PRED 6
7210#define VERT_LEFT_PRED 7
7211#define HOR_UP_PRED 8
7212
7213// 16x16 intra prediction modes
7214#define VERT_PRED_16 0
7215#define HOR_PRED_16 1
7216#define DC_PRED_16 2
7217#define PLANE_16 3
7218
7219// 8x8 chroma intra prediction modes
7220#define DC_PRED_8 0
7221#define HOR_PRED_8 1
7222#define VERT_PRED_8 2
7223#define PLANE_8 3
7224
7225#define INIT_FRAME_RATE 30
7226#define EOS 1 //!< End Of Sequence
7227
7228
7229#define MVPRED_MEDIAN 0
7230#define MVPRED_L 1
7231#define MVPRED_U 2
7232#define MVPRED_UR 3
7233
7234#define BLOCK_MULTIPLE 4 //(MB_BLOCK_SIZE/BLOCK_SIZE)
7235#define MB_BLOCK_PARTITIONS 16 //(BLOCK_MULTIPLE * BLOCK_MULTIPLE)
7236#define MB_PIXELS 256 //(MB_BLOCK_SIZE * MB_BLOCK_SIZE)
7237#define BLOCK_CONTEXT 64 //(4 * MB_BLOCK_PARTITIONS)
7238
7239#define MAX_SYMBOLS_PER_MB 1200 //!< Maximum number of different syntax elements for one MB
7240 // CAVLC needs more symbols per MB
7241
7242
7243#define MAX_PART_NR 3 /*!< Maximum number of different data partitions.
7244 Some reasonable number which should reflect
7245 what is currently defined in the SE2Partition map (elements.h) */
7246
7247//Start code and Emulation Prevention need this to be defined in identical manner at encoder and decoder
7248#define ZEROBYTES_SHORTSTARTCODE 2 //indicates the number of zero bytes in the short start-code prefix
7249
7250#define Q_BITS 15
7251#define DQ_BITS 6
7252#define DQ_ROUND (1<<(DQ_BITS-1))
7253
7254#define Q_BITS_8 16
7255#define DQ_BITS_8 6
7256#define DQ_ROUND_8 (1<<(DQ_BITS_8-1))
7257
7258// Context Adaptive Lagrange Multiplier (CALM)
7259#define CALM_MF_FACTOR_THRESHOLD 512.0
7260
7261#endif
7262# 201 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/defines.h"
7263
7264# 36 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 2
7265#if 0 /* expanded by -frewrite-includes */
7266#include "parsetcommon.h"
7267#endif /* expanded by -frewrite-includes */
7268# 36 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
7269# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/parsetcommon.h" 1
7270
7271/*!
7272 **************************************************************************************
7273 * \file
7274 * parsetcommon.h
7275 * \brief
7276 * Picture and Sequence Parameter Sets, structures common to encoder and decoder
7277 * This code reflects JVT version xxx
7278 * \date 25 November 2002
7279 * \author
7280 * Main contributors (see contributors.h for copyright, address and affiliation details)
7281 * - Stephan Wenger <stewe@cs.tu-berlin.de>
7282 ***************************************************************************************
7283 */
7284
7285
7286
7287// In the JVT syntax, frequently flags are used that indicate the presence of
7288// certain pieces of information in the NALU. Here, these flags are also
7289// present. In the encoder, those bits indicate that the values signalled to
7290// be present are meaningful and that this part of the syntax should be
7291// written to the NALU. In the decoder, the flag indicates that information
7292// was received from the decoded NALU and should be used henceforth.
7293// The structure names were chosen as indicated in the JVT syntax
7294
7295#ifndef _PARSETCOMMON_H_
7296#define _PARSETCOMMON_H_
7297
7298#define MAXIMUMPARSETRBSPSIZE 1500
7299#define MAXIMUMPARSETNALUSIZE 1500
7300
7301#define MAXSPS 32
7302#define MAXPPS 256
7303
7304//! Boolean Type
7305#ifdef FALSE
7306# define Boolean int
7307#else
7308# 39 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/parsetcommon.h"
7309typedef enum {
7310 FALSE,
7311 TRUE
7312} Boolean;
7313#endif
7314# 44 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/parsetcommon.h"
7315
7316#define MAXIMUMVALUEOFcpb_cnt 32
7317typedef struct
7318{
7319 unsigned int cpb_cnt; // ue(v)
7320 unsigned int bit_rate_scale; // u(4)
7321 unsigned int cpb_size_scale; // u(4)
7322 unsigned int bit_rate_value [MAXIMUMVALUEOFcpb_cnt]; // ue(v)
7323 unsigned int cpb_size_value[MAXIMUMVALUEOFcpb_cnt]; // ue(v)
7324 unsigned int vbr_cbr_flag[MAXIMUMVALUEOFcpb_cnt]; // u(1)
7325 unsigned int initial_cpb_removal_delay_length_minus1; // u(5)
7326 unsigned int cpb_removal_delay_length_minus1; // u(5)
7327 unsigned int dpb_output_delay_length_minus1; // u(5)
7328 unsigned int time_offset_length; // u(5)
7329} hrd_parameters_t;
7330
7331
7332typedef struct
7333{
7334 Boolean aspect_ratio_info_present_flag; // u(1)
7335 unsigned int aspect_ratio_idc; // u(8)
7336 unsigned int sar_width; // u(16)
7337 unsigned int sar_height; // u(16)
7338 Boolean overscan_info_present_flag; // u(1)
7339 Boolean overscan_appropriate_flag; // u(1)
7340 Boolean video_signal_type_present_flag; // u(1)
7341 unsigned int video_format; // u(3)
7342 Boolean video_full_range_flag; // u(1)
7343 Boolean colour_description_present_flag; // u(1)
7344 unsigned int colour_primaries; // u(8)
7345 unsigned int transfer_characteristics; // u(8)
7346 unsigned int matrix_coefficients; // u(8)
7347 Boolean chroma_location_info_present_flag; // u(1)
7348 unsigned int chroma_location_frame; // ue(v)
7349 unsigned int chroma_location_field; // ue(v)
7350 Boolean timing_info_present_flag; // u(1)
7351 unsigned int num_units_in_tick; // u(32)
7352 unsigned int time_scale; // u(32)
7353 Boolean fixed_frame_rate_flag; // u(1)
7354 Boolean nal_hrd_parameters_present_flag; // u(1)
7355 hrd_parameters_t nal_hrd_parameters; // hrd_paramters_t
7356 Boolean vcl_hrd_parameters_present_flag; // u(1)
7357 hrd_parameters_t vcl_hrd_parameters; // hrd_paramters_t
7358 // if ((nal_hrd_parameters_present_flag || (vcl_hrd_parameters_present_flag))
7359 Boolean low_delay_hrd_flag; // u(1)
7360 Boolean bitstream_restriction_flag; // u(1)
7361 Boolean motion_vectors_over_pic_boundaries_flag; // u(1)
7362 unsigned int max_bytes_per_pic_denom; // ue(v)
7363 unsigned int max_bits_per_mb_denom; // ue(v)
7364 unsigned int log2_max_mv_length_vertical; // ue(v)
7365 unsigned int log2_max_mv_length_horizontal; // ue(v)
7366 unsigned int max_dec_frame_reordering; // ue(v)
7367 unsigned int max_dec_frame_buffering; // ue(v)
7368} vui_seq_parameters_t;
7369
7370
7371#define MAXnum_slice_groups_minus1 8
7372typedef struct
7373{
7374 Boolean Valid; // indicates the parameter set is valid
7375 unsigned int pic_parameter_set_id; // ue(v)
7376 unsigned int seq_parameter_set_id; // ue(v)
7377 Boolean entropy_coding_mode_flag; // u(1)
7378
7379 Boolean transform_8x8_mode_flag; // u(1)
7380 Boolean pic_scaling_matrix_present_flag; // u(1)
7381 int pic_scaling_list_present_flag[8]; // u(1)
7382
7383 // if( pic_order_cnt_type < 2 ) in the sequence parameter set
7384 Boolean pic_order_present_flag; // u(1)
7385 unsigned int num_slice_groups_minus1; // ue(v)
7386 unsigned int slice_group_map_type; // ue(v)
7387 // if( slice_group_map_type = = 0 )
7388 unsigned int run_length_minus1[MAXnum_slice_groups_minus1]; // ue(v)
7389 // else if( slice_group_map_type = = 2 )
7390 unsigned int top_left[MAXnum_slice_groups_minus1]; // ue(v)
7391 unsigned int bottom_right[MAXnum_slice_groups_minus1]; // ue(v)
7392 // else if( slice_group_map_type = = 3 || 4 || 5
7393 Boolean slice_group_change_direction_flag; // u(1)
7394 unsigned int slice_group_change_rate_minus1; // ue(v)
7395 // else if( slice_group_map_type = = 6 )
7396 unsigned int pic_size_in_map_units_minus1; // ue(v)
7397 byte *slice_group_id; // complete MBAmap u(v)
7398
7399 int num_ref_idx_l0_active_minus1; // ue(v)
7400 int num_ref_idx_l1_active_minus1; // ue(v)
7401 Boolean weighted_pred_flag; // u(1)
7402 unsigned int weighted_bipred_idc; // u(2)
7403 int pic_init_qp_minus26; // se(v)
7404 int pic_init_qs_minus26; // se(v)
7405 int chroma_qp_index_offset; // se(v)
7406
7407 int cb_qp_index_offset; // se(v)
7408 int cr_qp_index_offset; // se(v)
7409
7410 Boolean deblocking_filter_control_present_flag; // u(1)
7411 Boolean constrained_intra_pred_flag; // u(1)
7412 Boolean redundant_pic_cnt_present_flag; // u(1)
7413 Boolean vui_pic_parameters_flag; // u(1)
7414} pic_parameter_set_rbsp_t;
7415
7416
7417#define MAXnum_ref_frames_in_pic_order_cnt_cycle 256
7418typedef struct
7419{
7420 Boolean Valid; // indicates the parameter set is valid
7421
7422 unsigned int profile_idc; // u(8)
7423 Boolean constrained_set0_flag; // u(1)
7424 Boolean constrained_set1_flag; // u(1)
7425 Boolean constrained_set2_flag; // u(1)
7426 Boolean constrained_set3_flag; // u(1)
7427 unsigned int level_idc; // u(8)
7428 unsigned int seq_parameter_set_id; // ue(v)
7429 unsigned int chroma_format_idc; // ue(v)
7430
7431 Boolean seq_scaling_matrix_present_flag; // u(1)
7432 int seq_scaling_list_present_flag[8]; // u(1)
7433
7434 unsigned int bit_depth_luma_minus8; // ue(v)
7435 unsigned int bit_depth_chroma_minus8; // ue(v)
7436 unsigned int log2_max_frame_num_minus4; // ue(v)
7437 unsigned int pic_order_cnt_type;
7438 // if( pic_order_cnt_type == 0 )
7439 unsigned int log2_max_pic_order_cnt_lsb_minus4; // ue(v)
7440 // else if( pic_order_cnt_type == 1 )
7441 Boolean delta_pic_order_always_zero_flag; // u(1)
7442 int offset_for_non_ref_pic; // se(v)
7443 int offset_for_top_to_bottom_field; // se(v)
7444 unsigned int num_ref_frames_in_pic_order_cnt_cycle; // ue(v)
7445 // for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ )
7446 int offset_for_ref_frame[MAXnum_ref_frames_in_pic_order_cnt_cycle]; // se(v)
7447 unsigned int num_ref_frames; // ue(v)
7448 Boolean gaps_in_frame_num_value_allowed_flag; // u(1)
7449 unsigned int pic_width_in_mbs_minus1; // ue(v)
7450 unsigned int pic_height_in_map_units_minus1; // ue(v)
7451 Boolean frame_mbs_only_flag; // u(1)
7452 // if( !frame_mbs_only_flag )
7453 Boolean mb_adaptive_frame_field_flag; // u(1)
7454 Boolean direct_8x8_inference_flag; // u(1)
7455 Boolean frame_cropping_flag; // u(1)
7456 unsigned int frame_cropping_rect_left_offset; // ue(v)
7457 unsigned int frame_cropping_rect_right_offset; // ue(v)
7458 unsigned int frame_cropping_rect_top_offset; // ue(v)
7459 unsigned int frame_cropping_rect_bottom_offset; // ue(v)
7460 Boolean vui_parameters_present_flag; // u(1)
7461 vui_seq_parameters_t vui_seq_parameters; // vui_seq_parameters_t
7462} seq_parameter_set_rbsp_t;
7463
7464pic_parameter_set_rbsp_t *AllocPPS (void);
7465seq_parameter_set_rbsp_t *AllocSPS (void);
7466void FreePPS (pic_parameter_set_rbsp_t *pps);
7467void FreeSPS (seq_parameter_set_rbsp_t *sps);
7468
7469#endif
7470# 199 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/parsetcommon.h"
7471# 37 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 2
7472#if 0 /* expanded by -frewrite-includes */
7473#include "q_matrix.h"
7474#endif /* expanded by -frewrite-includes */
7475# 37 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
7476# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/q_matrix.h" 1
7477
7478/*!
7479 ***************************************************************************
7480 * \file
7481 * q_matrix.h
7482 *
7483 * \brief
7484 * Headerfile for q_matrix array
7485 *
7486 * \date
7487 * 07. Apr 2004
7488 ***************************************************************************
7489 */
7490
7491#ifndef _Q_MATRIX_H_
7492#define _Q_MATRIX_H_
7493
7494extern int ****LevelScale4x4Luma;
7495extern int *****LevelScale4x4Chroma;
7496extern int ****LevelScale8x8Luma;
7497
7498extern int ****InvLevelScale4x4Luma;
7499extern int *****InvLevelScale4x4Chroma;
7500extern int ****InvLevelScale8x8Luma;
7501
7502extern short ScalingList4x4input[6][16];
7503extern short ScalingList8x8input[2][64];
7504extern short ScalingList4x4[6][16];
7505extern short ScalingList8x8[2][64];
7506
7507extern short UseDefaultScalingMatrix4x4Flag[6];
7508extern short UseDefaultScalingMatrix8x8Flag[2];
7509
7510extern int *qp_per_matrix;
7511extern int *qp_rem_matrix;
7512
7513
7514void Init_QMatrix (void);
7515void CalculateQuantParam(void);
7516void CalculateQuant8Param(void);
7517void free_QMatrix(void);
7518
7519#endif
7520# 44 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/q_matrix.h"
7521# 38 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 2
7522#if 0 /* expanded by -frewrite-includes */
7523#include "q_offsets.h"
7524#endif /* expanded by -frewrite-includes */
7525# 38 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
7526# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/q_offsets.h" 1
7527
7528/*!
7529 ***************************************************************************
7530 * \file
7531 * q_offsets.h
7532 *
7533 * \brief
7534 * Headerfile for q_offsets array
7535 *
7536 * \date
7537 * 18. Nov 2004
7538 ***************************************************************************
7539 */
7540
7541#ifndef _Q_OFFSETS_H_
7542#define _Q_OFFSETS_H_
7543
7544extern int ****LevelOffset4x4Luma;
7545extern int *****LevelOffset4x4Chroma;
7546extern int ****LevelOffset8x8Luma;
7547extern short **OffsetList4x4;
7548extern short **OffsetList8x8;
7549extern const int OffsetBits;
7550
7551
7552extern int AdaptRndWeight;
7553extern int AdaptRndCrWeight;
7554
7555void Init_QOffsetMatrix (void);
7556void CalculateOffsetParam(void);
7557void CalculateOffset8Param(void);
7558void free_QOffsets (void);
7559#endif
7560# 34 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/q_offsets.h"
7561# 39 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 2
7562#if 0 /* expanded by -frewrite-includes */
7563#include "minmax.h"
7564#endif /* expanded by -frewrite-includes */
7565# 39 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
7566# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/minmax.h" 1
7567
7568/*!
7569 ************************************************************************
7570 * \file
7571 * minmax.h
7572 * \brief
7573 * defines min and max macros for non WIN32 environments
7574 ************************************************************************
7575 */
7576#ifndef _MINMAX_
7577#define _MINMAX_
7578
7579#if !defined(WIN32) || defined(__GNUC__)
7580#endif
7581# 15 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/minmax.h"
7582
7583#endif
7584# 17 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/minmax.h"
7585
7586# 40 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 2
7587#if 0 /* expanded by -frewrite-includes */
7588#include "ifunctions.h"
7589#endif /* expanded by -frewrite-includes */
7590# 40 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
7591# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/ifunctions.h" 1
7592
7593/*!
7594 ************************************************************************
7595 * \file
7596 * ifunctions.h
7597 *
7598 * \brief
7599 * define some inline functions that are used within the encoder.
7600 *
7601 * \author
7602 * Main contributors (see contributors.h for copyright, address and affiliation details)
7603 * - Karsten Sühring <suehring@hhi.de>
7604 * - Alexis Tourapis <alexismt@ieee.org>
7605 *
7606 ************************************************************************
7607 */
7608#ifndef _IFUNCTIONS_H_
7609#define _IFUNCTIONS_H_
7610
7611static inline int imin(int a, int b)
7612{
7613 return ((a) < (b)) ? (a) : (b);
7614}
7615
7616static inline int imax(int a, int b)
7617{
7618 return ((a) > (b)) ? (a) : (b);
7619}
7620
7621static inline double dmin(double a, double b)
7622{
7623 return ((a) < (b)) ? (a) : (b);
7624}
7625
7626static inline double dmax(double a, double b)
7627{
7628 return ((a) > (b)) ? (a) : (b);
7629}
7630
7631static inline int64 i64min(int64 a, int64 b)
7632{
7633 return ((a) < (b)) ? (a) : (b);
7634}
7635
7636static inline int64 i64max(int64 a, int64 b)
7637{
7638 return ((a) > (b)) ? (a) : (b);
7639}
7640
7641static inline int iabs(int x)
7642{
7643 return ((x) < 0) ? -(x) : (x);
7644}
7645
7646static inline double dabs(double x)
7647{
7648 return ((x) < 0) ? -(x) : (x);
7649}
7650
7651static inline int isign(int x)
7652{
7653 return ((x) < 0) ? -1 : 1;
7654}
7655
7656static inline int isignab(int a, int b)
7657{
7658 return ((b) < 0) ? -iabs(a) : iabs(a);
7659}
7660
7661static inline int rshift_rnd(int x, int a)
7662{
7663 return (a > 0) ? ((x + (1 << (a-1) )) >> a) : (x << (-a));
7664}
7665
7666static inline unsigned int rshift_rnd_us(unsigned int x, unsigned int a)
7667{
7668 return (a > 0) ? ((x + (1 << (a-1))) >> a) : x;
7669}
7670
7671static inline int rshift_rnd_sf(int x, int a)
7672{
7673 return ((x + (1 << (a-1) )) >> a);
7674}
7675
7676static inline unsigned int rshift_rnd_us_sf(unsigned int x, unsigned int a)
7677{
7678 return ((x + (1 << (a-1))) >> a);
7679}
7680
7681static inline int iClip1(int high, int x)
7682{
7683 x = imax(x, 0);
7684 x = imin(x, high);
7685
7686 return x;
7687}
7688
7689static inline int iClip3(int low, int high, int x)
7690{
7691 x = imax(x, low);
7692 x = imin(x, high);
7693
7694 return x;
7695}
7696
7697static inline double dClip3(double low, double high, double x)
7698{
7699 x = dmax(x, low);
7700 x = dmin(x, high);
7701
7702 return x;
7703}
7704
7705static inline int weighted_cost(int factor, int bits)
7706{
7707 return (((factor)*(bits))>>LAMBDA_ACCURACY_BITS);
7708}
7709
7710static inline int RSD(int x)
7711{
7712 return ((x&2)?(x|1):(x&(~1)));
7713}
7714
7715#endif
7716# 125 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/ifunctions.h"
7717
7718# 41 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 2
7719
7720/***********************************************************************
7721 * T y p e d e f i n i t i o n s f o r T M L
7722 ***********************************************************************
7723 */
7724
7725
7726//typedef byte imgpel;
7727//typedef unsigned short distpel;
7728typedef unsigned short imgpel;
7729typedef int distpel;
7730
7731enum {
7732 YUV400 = 0,
7733 YUV420 = 1,
7734 YUV422 = 2,
7735 YUV444 = 3
7736} color_formats;
7737
7738enum {
7739 LIST_0 = 0,
7740 LIST_1 = 1,
7741 BI_PRED = 2,
7742 BI_PRED_L0 = 3,
7743 BI_PRED_L1 = 4
7744};
7745
7746enum {
7747 ERROR_SAD = 0,
7748 ERROR_SSE = 1,
7749 ERROR_SATD = 2,
7750 ERROR_PSATD = 3
7751};
7752
7753enum {
7754 ME_Y_ONLY = 0,
7755 ME_YUV_FP = 1,
7756 ME_YUV_FP_SP = 2
7757};
7758
7759enum {
7760 DISTORTION_MSE = 0,
7761 DISTORTION_WEIGHTED_MSE = 1,
7762 DISTORTION_OVERLAP_TRANSFORM = 2,
7763 DISTORTION_EDGE_MSE = 3
7764};
7765
7766//! Data Partitioning Modes
7767typedef enum
7768{
7769 PAR_DP_1, //!< no data partitioning is supported
7770 PAR_DP_3 //!< data partitioning with 3 partitions
7771} PAR_DP_TYPE;
7772
7773
7774//! Output File Types
7775typedef enum
7776{
7777 PAR_OF_ANNEXB, //!< Annex B byte stream format
7778 PAR_OF_RTP //!< RTP packets in outfile
7779} PAR_OF_TYPE;
7780
7781//! Field Coding Types
7782typedef enum
7783{
7784 FRAME_CODING,
7785 FIELD_CODING,
7786 ADAPTIVE_CODING,
7787 FRAME_MB_PAIR_CODING
7788} CodingType;
7789
7790//! definition of H.264 syntax elements
7791typedef enum
7792{
7793 SE_HEADER,
7794 SE_PTYPE,
7795 SE_MBTYPE,
7796 SE_REFFRAME,
7797 SE_INTRAPREDMODE,
7798 SE_MVD,
7799 SE_CBP,
7800 SE_LUM_DC_INTRA,
7801 SE_CHR_DC_INTRA,
7802 SE_LUM_AC_INTRA,
7803 SE_CHR_AC_INTRA,
7804 SE_LUM_DC_INTER,
7805 SE_CHR_DC_INTER,
7806 SE_LUM_AC_INTER,
7807 SE_CHR_AC_INTER,
7808 SE_DELTA_QUANT,
7809 SE_BFRAME,
7810 SE_EOS,
7811 SE_MAX_ELEMENTS //!< number of maximum syntax elements
7812} SE_type; // substituting the definitions in elements.h
7813
7814
7815typedef enum
7816{
7817 INTER_MB,
7818 INTRA_MB_4x4,
7819 INTRA_MB_16x16
7820} IntraInterDecision;
7821
7822
7823typedef enum
7824{
7825 BITS_HEADER,
7826 BITS_TOTAL_MB,
7827 BITS_MB_MODE,
7828 BITS_INTER_MB,
7829 BITS_CBP_MB,
7830 BITS_COEFF_Y_MB,
7831 BITS_COEFF_UV_MB,
7832 BITS_DELTA_QUANT_MB,
7833 MAX_BITCOUNTER_MB
7834} BitCountType;
7835
7836
7837typedef enum
7838{
7839 NO_SLICES,
7840 FIXED_MB,
7841 FIXED_RATE,
7842 CALLBACK,
7843 FMO
7844} SliceMode;
7845
7846
7847typedef enum
7848{
7849 UVLC,
7850 CABAC
7851} SymbolMode;
7852
7853typedef enum
7854{
7855 FULL_SEARCH = -1,
7856 FAST_FULL_SEARCH = 0,
7857 UM_HEX = 1,
7858 UM_HEX_SIMPLE = 2,
7859 EPZS = 3
7860} SearchType;
7861
7862
7863typedef enum
7864{
7865 FRAME,
7866 TOP_FIELD,
7867 BOTTOM_FIELD
7868} PictureStructure; //!< New enum for field processing
7869
7870typedef enum
7871{
7872 P_SLICE = 0,
7873 B_SLICE = 1,
7874 I_SLICE = 2,
7875 SP_SLICE = 3,
7876 SI_SLICE = 4
7877} SliceType;
7878
7879//Motion Estimation levels
7880typedef enum
7881{
7882 F_PEL, //!< Full Pel refinement
7883 H_PEL, //!< Half Pel refinement
7884 Q_PEL //!< Quarter Pel refinement
7885} MELevel;
7886
7887typedef enum
7888{
7889 FAST_ACCESS = 0, //!< Fast/safe reference access
7890 UMV_ACCESS = 1 //!< unconstrained reference access
7891} REF_ACCESS_TYPE;
7892
7893typedef enum
7894{
7895 IS_LUMA = 0,
7896 IS_CHROMA = 1
7897} Component_Type;
7898
7899typedef enum
7900{
7901 RC_MODE_0 = 0,
7902 RC_MODE_1 = 1,
7903 RC_MODE_2 = 2,
7904 RC_MODE_3 = 3
7905} RCModeType;
7906
7907/***********************************************************************
7908 * D a t a t y p e s f o r C A B A C
7909 ***********************************************************************
7910 */
7911
7912//! struct to characterize the state of the arithmetic coding engine
7913typedef struct
7914{
7915 unsigned int Elow, Erange;
7916 unsigned int Ebuffer;
7917 unsigned int Ebits_to_go;
7918 unsigned int Ebits_to_follow;
7919 byte *Ecodestrm;
7920 int *Ecodestrm_len;
7921 int C;
7922 int E;
7923
7924} EncodingEnvironment;
7925
7926typedef EncodingEnvironment *EncodingEnvironmentPtr;
7927
7928//! struct for context management
7929typedef struct
7930{
7931 unsigned short state; // index into state-table CP
7932 unsigned char MPS; // Least Probable Symbol 0/1 CP
7933 unsigned long count;
7934} BiContextType;
7935
7936typedef BiContextType *BiContextTypePtr;
7937
7938
7939/**********************************************************************
7940 * C O N T E X T S F O R T M L S Y N T A X E L E M E N T S
7941 **********************************************************************
7942 */
7943
7944
7945#define NUM_MB_TYPE_CTX 11
7946#define NUM_B8_TYPE_CTX 9
7947#define NUM_MV_RES_CTX 10
7948#define NUM_REF_NO_CTX 6
7949#define NUM_DELTA_QP_CTX 4
7950#define NUM_MB_AFF_CTX 4
7951
7952#define NUM_TRANSFORM_SIZE_CTX 3
7953
7954typedef struct
7955{
7956 BiContextType mb_type_contexts [3][NUM_MB_TYPE_CTX];
7957 BiContextType b8_type_contexts [2][NUM_B8_TYPE_CTX];
7958 BiContextType mv_res_contexts [2][NUM_MV_RES_CTX];
7959 BiContextType ref_no_contexts [2][NUM_REF_NO_CTX];
7960 BiContextType delta_qp_contexts [NUM_DELTA_QP_CTX];
7961 BiContextType mb_aff_contexts [NUM_MB_AFF_CTX];
7962 BiContextType transform_size_contexts [NUM_TRANSFORM_SIZE_CTX];
7963} MotionInfoContexts;
7964
7965
7966#define NUM_IPR_CTX 2
7967#define NUM_CIPR_CTX 4
7968#define NUM_CBP_CTX 4
7969#define NUM_BCBP_CTX 4
7970#define NUM_MAP_CTX 15
7971#define NUM_LAST_CTX 15
7972#define NUM_ONE_CTX 5
7973#define NUM_ABS_CTX 5
7974
7975
7976typedef struct
7977{
7978 BiContextType ipr_contexts [NUM_IPR_CTX];
7979 BiContextType cipr_contexts[NUM_CIPR_CTX];
7980 BiContextType cbp_contexts [3][NUM_CBP_CTX];
7981 BiContextType bcbp_contexts[NUM_BLOCK_TYPES][NUM_BCBP_CTX];
7982 BiContextType map_contexts [NUM_BLOCK_TYPES][NUM_MAP_CTX];
7983 BiContextType last_contexts[NUM_BLOCK_TYPES][NUM_LAST_CTX];
7984 BiContextType one_contexts [NUM_BLOCK_TYPES][NUM_ONE_CTX];
7985 BiContextType abs_contexts [NUM_BLOCK_TYPES][NUM_ABS_CTX];
7986 BiContextType fld_map_contexts [NUM_BLOCK_TYPES][NUM_MAP_CTX];
7987 BiContextType fld_last_contexts[NUM_BLOCK_TYPES][NUM_LAST_CTX];
7988} TextureInfoContexts;
7989
7990//*********************** end of data type definition for CABAC *******************
7991
7992//! Pixel position for checking neighbors
7993typedef struct pix_pos
7994{
7995 int available;
7996 int mb_addr;
7997 int x;
7998 int y;
7999 int pos_x;
8000 int pos_y;
8001} PixelPos;
8002
8003//! Buffer structure for decoded reference picture marking commands
8004typedef struct DecRefPicMarking_s
8005{
8006 int memory_management_control_operation;
8007 int difference_of_pic_nums_minus1;
8008 int long_term_pic_num;
8009 int long_term_frame_idx;
8010 int max_long_term_frame_idx_plus1;
8011 struct DecRefPicMarking_s *Next;
8012} DecRefPicMarking_t;
8013
8014//! Syntax Element
8015typedef struct syntaxelement
8016{
8017 int type; //!< type of syntax element for data part.
8018 int value1; //!< numerical value of syntax element
8019 int value2; //!< for blocked symbols, e.g. run/level
8020 int len; //!< length of code
8021 int inf; //!< info part of UVLC code
8022 unsigned int bitpattern; //!< UVLC bitpattern
8023 int context; //!< CABAC context
8024
8025#if TRACE
8026 #define TRACESTRING_SIZE 100 //!< size of trace string
8027 char tracestring[TRACESTRING_SIZE]; //!< trace string
8028#endif
8029# 351 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
8030
8031 //!< for mapping of syntaxElement to UVLC
8032 void (*mapping)(int value1, int value2, int* len_ptr, int* info_ptr);
8033
8034} SyntaxElement;
8035
8036//! Macroblock
8037typedef struct macroblock
8038{
8039 int slice_nr;
8040 int delta_qp;
8041 int qp; //!< QP luma
8042 int qpc[2]; //!< QP chroma
8043 int qpsp ;
8044 int bitcounter[MAX_BITCOUNTER_MB];
8045
8046 struct macroblock *mb_available_up; //!< pointer to neighboring MB (CABAC)
8047 struct macroblock *mb_available_left; //!< pointer to neighboring MB (CABAC)
8048
8049 int mb_type;
8050 int mvd[2][BLOCK_MULTIPLE][BLOCK_MULTIPLE][2]; //!< indices correspond to [list][block_y][block_x][x,y]
8051 signed char intra_pred_modes[MB_BLOCK_PARTITIONS];
8052 signed char intra_pred_modes8x8[MB_BLOCK_PARTITIONS]; //!< four 8x8 blocks in a macroblock
8053 int cbp ;
8054 int64 cbp_blk ; //!< 1 bit set for every 4x4 block with coefs (not implemented for INTRA)
8055 int b8mode[4];
8056 int b8pdir[4];
8057 int64 cbp_bits;
8058
8059 int c_ipred_mode; //!< chroma intra prediction mode
8060 int IntraChromaPredModeFlag;
8061
8062 int mb_field;
8063 int is_field_mode;
8064 int list_offset;
8065
8066 int mbAddrA, mbAddrB, mbAddrC, mbAddrD;
8067 int mbAvailA, mbAvailB, mbAvailC, mbAvailD;
8068
8069 int all_blk_8x8;
8070 int luma_transform_size_8x8_flag;
8071 int NoMbPartLessThan8x8Flag;
8072
8073 short bi_pred_me;
8074
8075 // rate control
8076 double actj; // macroblock activity measure for macroblock j
8077 int prev_qp;
8078 int prev_delta_qp;
8079 int prev_cbp;
8080 int predict_qp;
8081 int predict_error;
8082
8083 int LFDisableIdc;
8084 int LFAlphaC0Offset;
8085 int LFBetaOffset;
8086
8087 int skip_flag;
8088} Macroblock;
8089
8090
8091
8092//! Bitstream
8093typedef struct
8094{
8095 int byte_pos; //!< current position in bitstream;
8096 int bits_to_go; //!< current bitcounter
8097 byte byte_buf; //!< current buffer for last written byte
8098 int stored_byte_pos; //!< storage for position in bitstream;
8099 int stored_bits_to_go; //!< storage for bitcounter
8100 byte stored_byte_buf; //!< storage for buffer of last written byte
8101
8102 byte byte_buf_skip; //!< current buffer for last written byte
8103 int byte_pos_skip; //!< storage for position in bitstream;
8104 int bits_to_go_skip; //!< storage for bitcounter
8105
8106 byte *streamBuffer; //!< actual buffer for written bytes
8107 int write_flag; //!< Bitstream contains data and needs to be written
8108
8109#if TRACE
8110 Boolean trace_enabled;
8111#endif
8112# 433 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
8113
8114} Bitstream;
8115
8116//! DataPartition
8117typedef struct datapartition
8118{
8119
8120 Bitstream *bitstream;
8121 EncodingEnvironment ee_cabac;
8122 EncodingEnvironment ee_recode;
8123} DataPartition;
8124
8125//! Slice
8126typedef struct
8127{
8128 int picture_id;
8129 int qp;
8130 int picture_type; //!< picture type
8131 int start_mb_nr;
8132 int max_part_nr; //!< number of different partitions
8133 int num_mb; //!< number of MBs in the slice
8134 DataPartition *partArr; //!< array of partitions
8135 MotionInfoContexts *mot_ctx; //!< pointer to struct of context models for use in CABAC
8136 TextureInfoContexts *tex_ctx; //!< pointer to struct of context models for use in CABAC
8137
8138 int ref_pic_list_reordering_flag_l0;
8139 int *reordering_of_pic_nums_idc_l0;
8140 int *abs_diff_pic_num_minus1_l0;
8141 int *long_term_pic_idx_l0;
8142 int ref_pic_list_reordering_flag_l1;
8143 int *reordering_of_pic_nums_idc_l1;
8144 int *abs_diff_pic_num_minus1_l1;
8145 int *long_term_pic_idx_l1;
8146
8147 Boolean (*slice_too_big)(int bits_slice); //!< for use of callback functions
8148
8149 int field_ctx[3][2]; //GB
8150
8151} Slice;
8152
8153
8154
8155#define MAXSLICEPERPICTURE 100
8156typedef struct
8157{
8158 int no_slices;
8159 int idr_flag;
8160 Slice *slices[MAXSLICEPERPICTURE];
8161 int bits_per_picture;
8162 float distortion_y;
8163 float distortion_u;
8164 float distortion_v;
8165} Picture;
8166
8167Picture *top_pic;
8168Picture *bottom_pic;
8169Picture *frame_pic;
8170Picture *frame_pic_1;
8171Picture *frame_pic_2;
8172Picture *frame_pic_3;
8173Picture *frame_pic_si;
8174
8175#ifdef _LEAKYBUCKET_
8176long *Bit_Buffer;
8177#endif
8178# 498 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
8179
8180// global picture format dependend buffers, mem allocation in image.c
8181imgpel **imgY_org; //!< Reference luma image
8182imgpel ***imgUV_org; //!< Reference chroma image
8183int **imgY_sub_tmp; //!< Y picture temporary component (Quarter pel)
8184
8185int **PicPos;
8186unsigned int log2_max_frame_num_minus4;
8187unsigned int log2_max_pic_order_cnt_lsb_minus4;
8188
8189time_t me_tot_time,me_time;
8190pic_parameter_set_rbsp_t *active_pps;
8191seq_parameter_set_rbsp_t *active_sps;
8192
8193
8194int dsr_new_search_range; //!<Dynamic Search Range.
8195//////////////////////////////////////////////////////////////////////////
8196// B pictures
8197// motion vector : forward, backward, direct
8198int mb_adaptive; //!< For MB level field/frame coding tools
8199int MBPairIsField; //!< For MB level field/frame coding tools
8200
8201
8202//Weighted prediction
8203int ***wp_weight; // weight in [list][index][component] order
8204int ***wp_offset; // offset in [list][index][component] order
8205int ****wbp_weight; // weight in [list][fwd_index][bwd_idx][component] order
8206int luma_log_weight_denom;
8207int chroma_log_weight_denom;
8208int wp_luma_round;
8209int wp_chroma_round;
8210
8211// global picture format dependend buffers, mem allocation in image.c (field picture)
8212imgpel **imgY_org_top;
8213imgpel **imgY_org_bot;
8214
8215imgpel ***imgUV_org_top;
8216imgpel ***imgUV_org_bot;
8217
8218imgpel **imgY_org_frm;
8219imgpel ***imgUV_org_frm;
8220
8221imgpel **imgY_com; //!< Encoded luma images
8222imgpel ***imgUV_com; //!< Encoded croma images
8223
8224signed char ***direct_ref_idx; //!< direct mode reference index buffer
8225signed char **direct_pdir; //!< direct mode reference index buffer
8226
8227// Buffers for rd optimization with packet losses, Dim. Kontopodis
8228byte **pixel_map; //!< Shows the latest reference frame that is reliable for each pixel
8229byte **refresh_map; //!< Stores the new values for pixel_map
8230int intras; //!< Counts the intra updates in each frame.
8231
8232int frame_ctr[5];
8233int frame_no, nextP_tr_fld, nextP_tr_frm;
8234
8235time_t tot_time;
8236
8237#define ET_SIZE 300 //!< size of error text buffer
8238char errortext[ET_SIZE]; //!< buffer for error message for exit with error()
8239
8240// Residue Color Transform
8241signed char b8_ipredmode8x8[4][4], b8_intra_pred_modes8x8[16];
8242
8243//! Info for the "decoders-in-the-encoder" used for rdoptimization with packet losses
8244typedef struct
8245{
8246 int **resY; //!< Residue of Luminance
8247 imgpel ***decY; //!< Decoded values at the simulated decoders
8248 imgpel ****decref; //!< Reference frames of the simulated decoders
8249 imgpel ***decY_best; //!< Decoded frames for the best mode for all decoders
8250 imgpel **RefBlock;
8251 byte **status_map;
8252 byte **dec_mb_mode;
8253} Decoders;
8254extern Decoders *decs;
8255
8256//! SNRParameters
8257typedef struct
8258{
8259 float snr_y; //!< current Y SNR
8260 float snr_u; //!< current U SNR
8261 float snr_v; //!< current V SNR
8262 float snr_y1; //!< SNR Y(dB) first frame
8263 float snr_u1; //!< SNR U(dB) first frame
8264 float snr_v1; //!< SNR V(dB) first frame
8265 float snr_yt[5]; //!< SNR Y(dB) based on frame type
8266 float snr_ut[5]; //!< SNR U(dB) based on frame type
8267 float snr_vt[5]; //!< SNR V(dB) based on frame type
8268 float snr_ya; //!< Average SNR Y(dB) remaining frames
8269 float snr_ua; //!< Average SNR U(dB) remaining frames
8270 float snr_va; //!< Average SNR V(dB) remaining frames
8271 float sse_y; //!< SSE Y
8272 float sse_u; //!< SSE U
8273 float sse_v; //!< SSE V
8274 float msse_y; //!< Average SSE Y
8275 float msse_u; //!< Average SSE U
8276 float msse_v; //!< Average SSE V
8277 int frame_ctr; //!< number of coded frames
8278} SNRParameters;
8279
8280#define FILE_NAME_SIZE 256
8281 //! all input parameters
8282typedef struct
8283{
8284 int ProfileIDC; //!< value of syntax element profile_idc
8285 int LevelIDC; //!< value of syntax element level_idc
8286
8287 int no_frames; //!< number of frames to be encoded
8288 int qp0; //!< QP of first frame
8289 int qpN; //!< QP of remaining frames
8290 int jumpd; //!< number of frames to skip in input sequence (e.g 2 takes frame 0,3,6,9...)
8291 int DisableSubpelME; //!< Disable sub-pixel motion estimation
8292 int search_range; /*!< search range - integer pel search and 16x16 blocks. The search window is
8293 generally around the predicted vector. Max vector is 2xmcrange. For 8x8
8294 and 4x4 block sizes the search range is 1/2 of that for 16x16 blocks. */
8295 int num_ref_frames; //!< number of reference frames to be used
8296 int P_List0_refs; //!< number of reference picture in list 0 in P pictures
8297 int B_List0_refs; //!< number of reference picture in list 0 in B pictures
8298 int B_List1_refs; //!< number of reference picture in list 1 in B pictures
8299 int Log2MaxFNumMinus4; //!< value of syntax element log2_max_frame_num
8300 int Log2MaxPOCLsbMinus4; //!< value of syntax element log2_max_pic_order_cnt_lsb_minus4
8301
8302 int img_width; //!< image width (must be a multiple of 16 pels)
8303 int img_height; //!< image height (must be a multiple of 16 pels)
8304 int yuv_format; //!< YUV format (0=4:0:0, 1=4:2:0, 2=4:2:2, 3=4:4:4)
8305 int intra_upd; /*!< For error robustness. 0: no special action. 1: One GOB/frame is intra coded
8306 as regular 'update'. 2: One GOB every 2 frames is intra coded etc.
8307 In connection with this intra update, restrictions is put on motion vectors
8308 to prevent errors to propagate from the past */
8309 int blc_size[8][2]; //!< array for different block sizes
8310 int part_size[8][2]; //!< array for different partition sizes
8311 int blocktype_lut[4][4]; //!< array for different partition sizes
8312 int slice_mode; //!< Indicate what algorithm to use for setting slices
8313 int slice_argument; //!< Argument to the specified slice algorithm
8314 int UseConstrainedIntraPred; //!< 0: Inter MB pixels are allowed for intra prediction 1: Not allowed
8315 int infile_header; //!< If input file has a header set this to the length of the header
8316 char infile[FILE_NAME_SIZE]; //!< YUV 4:2:0 input format
8317 char outfile[FILE_NAME_SIZE]; //!< H.264 compressed output bitstream
8318 char ReconFile[FILE_NAME_SIZE]; //!< Reconstructed Pictures
8319 char TraceFile[FILE_NAME_SIZE]; //!< Trace Outputs
8320 char QmatrixFile[FILE_NAME_SIZE]; //!< Q matrix cfg file
8321 int intra_period; //!< Random Access period though intra
8322 int EnableOpenGOP; //!< support for open gops.
8323
8324 int idr_enable; //!< Encode intra slices as IDR
8325 int start_frame; //!< Encode sequence starting from Frame start_frame
8326
8327 int GenerateMultiplePPS;
8328 int Generate_SEIVUI;
8329 char SEIMessageText[500];
8330 int VUISupport;
8331
8332 int ResendSPS;
8333 int ResendPPS;
8334
8335 // B pictures
8336 int successive_Bframe; //!< number of B frames that will be used
8337 int PReplaceBSlice;
8338 int qpB; //!< QP for non-reference B slice coded pictures
8339 int qpBRSOffset; //!< QP for reference B slice coded pictures
8340 int direct_spatial_mv_pred_flag; //!< Direct Mode type to be used (0: Temporal, 1: Spatial)
8341 int directInferenceFlag; //!< Direct Mode Inference Flag
8342
8343 int BiPredMotionEstimation;
8344 int BiPredMERefinements;
8345 int BiPredMESearchRange;
8346 int BiPredMESubPel;
8347
8348
8349 // SP Pictures
8350 int sp_periodicity; //!< The periodicity of SP-pictures
8351 int qpsp; //!< SP Picture QP for prediction error
8352 int qpsp_pred; //!< SP Picture QP for predicted block
8353
8354 int si_frame_indicator; //!< Flag indicating whether SI frames should be encoded rather than SP frames (0: not used, 1: used)
8355 int sp2_frame_indicator; //!< Flag indicating whether switching SP frames should be encoded rather than SP frames (0: not used, 1: used)
8356 int sp_output_indicator; //!< Flag indicating whether coefficients are output to allow future encoding of switchin SP frames (0: not used, 1: used)
8357 char sp_output_filename[FILE_NAME_SIZE]; //!<Filename where SP coefficients are output
8358 char sp2_input_filename1[FILE_NAME_SIZE]; //!<Filename of coefficients of the first bitstream when encoding SP frames to switch bitstreams
8359 char sp2_input_filename2[FILE_NAME_SIZE]; //!<Filenames of coefficients of the second bitstream when encoding SP frames to switch bitstreams
8360
8361 int WeightedPrediction; //!< Weighted prediction for P frames (0: not used, 1: explicit)
8362 int WeightedBiprediction; //!< Weighted prediction for B frames (0: not used, 1: explicit, 2: implicit)
8363 int UseWeightedReferenceME; //!< Use Weighted Reference for ME.
8364 int RDPictureDecision; //!< Perform RD optimal decision between various coded versions of same picture
8365 int RDPictureIntra; //!< Enabled RD pic decision for intra as well.
8366 int RDPSliceWeightOnly; //!< If enabled, does not check QP variations for P slices.
8367 int RDPSliceBTest; //!< Tests B slice replacement for P.
8368 int RDBSliceWeightOnly; //!< If enabled, does not check QP variations for B slices.
8369 int SkipIntraInInterSlices; //!< Skip intra type checking in inter slices if best_mode is skip/direct
8370 int BRefPictures; //!< B coded reference pictures replace P pictures (0: not used, 1: used)
8371 int HierarchicalCoding;
8372 int HierarchyLevelQPEnable;
8373 char ExplicitHierarchyFormat[1024];//!< Explicit GOP format (HierarchicalCoding==3).
8374 int ReferenceReorder; //!< Reordering based on Poc distances
8375 int PocMemoryManagement; //!< Memory management based on Poc distances for hierarchical coding
8376
8377 int symbol_mode; //!< Specifies the mode the symbols are mapped on bits
8378 int of_mode; //!< Specifies the mode of the output file
8379 int partition_mode; //!< Specifies the mode of data partitioning
8380
8381 int InterSearch16x16;
8382 int InterSearch16x8;
8383 int InterSearch8x16;
8384 int InterSearch8x8;
8385 int InterSearch8x4;
8386 int InterSearch4x8;
8387 int InterSearch4x4;
8388
8389 int IntraDisableInterOnly;
8390 int Intra4x4ParDisable;
8391 int Intra4x4DiagDisable;
8392 int Intra4x4DirDisable;
8393 int Intra16x16ParDisable;
8394 int Intra16x16PlaneDisable;
8395 int ChromaIntraDisable;
8396
8397 int EnableIPCM;
8398
8399 double FrameRate;
8400
8401 int EPZSPattern;
8402 int EPZSDual;
8403 int EPZSFixed;
8404 int EPZSTemporal;
8405 int EPZSSpatialMem;
8406 int EPZSMinThresScale;
8407 int EPZSMaxThresScale;
8408 int EPZSMedThresScale;
8409 int EPZSSubPelGrid;
8410 int EPZSSubPelME;
8411 int EPZSSubPelMEBiPred;
8412 int EPZSSubPelThresScale;
8413
8414 int chroma_qp_index_offset;
8415#ifdef _FULL_SEARCH_RANGE_
8416 int full_search;
8417#endif
8418# 737 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
8419#ifdef _ADAPT_LAST_GROUP_
8420 int last_frame;
8421#endif
8422# 740 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
8423#ifdef _CHANGE_QP_
8424 int qpN2, qpB2, qp2start;
8425 int qp02, qpBRS2Offset;
8426#endif
8427# 744 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
8428 int rdopt;
8429 int CtxAdptLagrangeMult; //!< context adaptive lagrangian multiplier
8430 int FastCrIntraDecision;
8431 int disthres;
8432 int nobskip;
8433
8434#ifdef _LEAKYBUCKET_
8435 int NumberLeakyBuckets;
8436 char LeakyBucketRateFile[FILE_NAME_SIZE];
8437 char LeakyBucketParamFile[FILE_NAME_SIZE];
8438#endif
8439# 755 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
8440
8441 int PicInterlace; //!< picture adaptive frame/field
8442 int MbInterlace; //!< macroblock adaptive frame/field
8443
8444 int IntraBottom; //!< Force Intra Bottom at GOP periods.
8445
8446 int LossRateA; //!< assumed loss probablility of partition A (or full slice), in per cent, used for loss-aware R/D optimization
8447 int LossRateB; //!< assumed loss probablility of partition B, in per cent, used for loss-aware R/D
8448 int LossRateC; //!< assumed loss probablility of partition C, in per cent, used for loss-aware R/D
8449 int NoOfDecoders;
8450 int RestrictRef;
8451 int NumFramesInELSubSeq;
8452 int NumFrameIn2ndIGOP;
8453
8454 int RandomIntraMBRefresh; //!< Number of pseudo-random intra-MBs per picture
8455
8456 int LFSendParameters;
8457 int LFDisableIdc;
8458 int LFAlphaC0Offset;
8459 int LFBetaOffset;
8460
8461 int SparePictureOption;
8462 int SPDetectionThreshold;
8463 int SPPercentageThreshold;
8464
8465 // FMO
8466 char SliceGroupConfigFileName[FILE_NAME_SIZE]; //!< Filename for config info fot type 0, 2, 6
8467 int num_slice_groups_minus1; //!< "FmoNumSliceGroups" in encoder.cfg, same as FmoNumSliceGroups, which should be erased later
8468 int slice_group_map_type;
8469
8470 int *top_left; //!< top_left and bottom_right store values indicating foregrounds
8471 int *bottom_right;
8472 byte *slice_group_id; //!< slice_group_id is for slice group type being 6
8473 int *run_length_minus1; //!< run_length_minus1 is for slice group type being 0
8474
8475 int slice_group_change_direction_flag;
8476 int slice_group_change_rate_minus1;
8477 int slice_group_change_cycle;
8478
8479 int redundant_pic_flag; //! encoding of redundant pictures
8480 int pic_order_cnt_type; //! POC type
8481
8482 int context_init_method;
8483 int model_number;
8484 int Transform8x8Mode;
8485 int ReportFrameStats;
8486 int DisplayEncParams;
8487 int Verbose;
8488
8489 //! Rate Control on JVT standard
8490 int RCEnable;
8491 int bit_rate;
8492 int SeinitialQP;
8493 unsigned int basicunit;
8494 int channel_type;
8495 int RCUpdateMode;
8496 double RCIoverPRatio;
8497 double RCBoverPRatio;
8498 double RCISliceBitRatio;
8499 double RCBSliceBitRatio[RC_MAX_TEMPORAL_LEVELS];
8500
8501 int ScalingMatrixPresentFlag;
8502 int ScalingListPresentFlag[8];
8503
8504 // Search Algorithm
8505 SearchType SearchMode;
8506
8507 int UMHexDSR;//!< Dynamic Search Range
8508 int UMHexScale;
8509//////////////////////////////////////////////////////////////////////////
8510 // Fidelity Range Extensions
8511 int BitDepthLuma;
8512 int BitDepthChroma;
8513 int img_height_cr;
8514 int img_width_cr;
8515 int rgb_input_flag;
8516 int cb_qp_index_offset;
8517 int cr_qp_index_offset;
8518
8519 // Lossless Coding
8520 int lossless_qpprime_y_zero_flag;
8521
8522 // Lambda Params
8523 int UseExplicitLambdaParams;
8524 double LambdaWeight[6];
8525 double FixedLambda[6];
8526
8527 char QOffsetMatrixFile[FILE_NAME_SIZE]; //!< Quantization Offset matrix cfg file
8528 int OffsetMatrixPresentFlag; //!< Enable Explicit Quantization Offset Matrices
8529
8530 int AdaptiveRounding; //!< Adaptive Rounding parameter based on JVT-N011
8531 int AdaptRndPeriod; //!< Set period for adaptive rounding of JVT-N011 in MBs
8532 int AdaptRndChroma;
8533 int AdaptRndWFactor[2][5]; //!< Weighting factors for luma component based on reference indicator and slice type
8534 int AdaptRndCrWFactor[2][5]; //!< Weighting factors for chroma components based on reference indicator and slice type
8535 // Fast Mode Decision
8536 int EarlySkipEnable;
8537 int SelectiveIntraEnable;
8538 int DisposableP;
8539 int DispPQPOffset;
8540
8541 //Redundant picture
8542 int NumRedundantHierarchy; //!< number of entries to allocate redundant pictures in a GOP
8543 int PrimaryGOPLength; //!< GOP length of primary pictures
8544 int NumRefPrimary; //!< number of reference frames for primary picture
8545
8546 // Chroma interpolation and buffering
8547 int ChromaMCBuffer;
8548 int ChromaMEEnable;
8549 int MEErrorMetric[3];
8550 int ModeDecisionMetric;
8551
8552} InputParameters;
8553
8554//! ImageParameters
8555typedef struct
8556{
8557 int number; //!< current image number to be encoded
8558 int pn; //!< picture number
8559 int LevelIndex; //!< mapped level idc
8560 int current_mb_nr;
8561 int current_slice_nr;
8562 int type;
8563 int structure; //!< picture structure
8564 int num_ref_frames; //!< number of reference frames to be used
8565 int max_num_references; //!< maximum number of reference pictures that may occur
8566 int qp; //!< quant for the current frame
8567 int qpsp; //!< quant for the prediction frame of SP-frame
8568 int qp_scaled;
8569 float framerate;
8570 int width; //!< Number of pels
8571 int width_padded; //!< Width in pels of padded picture
8572 int width_blk; //!< Number of columns in blocks
8573 int width_cr; //!< Number of pels chroma
8574 int height; //!< Number of lines
8575 int height_padded; //!< Number in lines of padded picture
8576 int height_blk; //!< Number of lines in blocks
8577 int height_cr; //!< Number of lines chroma
8578 int height_cr_frame; //!< Number of lines chroma frame
8579 int size; //!< Luma Picture size in pels
8580 int size_cr; //!< Chroma Picture size in pels
8581 int subblock_x; //!< current subblock horizontal
8582 int subblock_y; //!< current subblock vertical
8583 int is_intra_block;
8584 int is_v_block;
8585 int mb_y_upd;
8586 int mb_y_intra; //!< which GOB to intra code
8587 int block_c_x; //!< current block chroma vertical
8588 signed char **ipredmode; //!< intra prediction mode
8589 signed char **ipredmode8x8; //!< help storage for 8x8 modes, inserted by YV
8590
8591 int cod_counter; //!< Current count of number of skipped macroblocks in a row
8592 int ***nz_coeff; //!< number of coefficients per block (CAVLC)
8593
8594 int mb_x; //!< current MB horizontal
8595 int mb_y; //!< current MB vertical
8596 int block_x; //!< current block horizontal
8597 int block_y; //!< current block vertical
8598 int pix_x; //!< current pixel horizontal
8599 int pix_y; //!< current pixel vertical
8600 int pix_c_x; //!< current pixel chroma horizontal
8601 int pix_c_y; //!< current pixel chroma vertical
8602
8603 int opix_x; //!< current original picture pixel horizontal
8604 int opix_y; //!< current original picture pixel vertical
8605 int opix_c_x; //!< current original picture pixel chroma horizontal
8606 int opix_c_y; //!< current original picture pixel chroma vertical
8607
8608
8609 // some temporal buffers
8610 imgpel mprr[9][16][16]; //!< all 9 prediction modes? // enlarged from 4 to 16 for ABT (is that neccessary?)
8611
8612 imgpel mprr_2[5][16][16]; //!< all 4 new intra prediction modes
8613 imgpel mprr_3[9][8][8]; //!< all 9 prediction modes for 8x8 transformation
8614 imgpel mprr_c[2][4][16][16]; //!< chroma intra prediction modes
8615 imgpel mpr[16][16]; //!< current best prediction mode
8616 int m7[16][16]; //!< the diff pixel values between orginal image and prediction
8617
8618 int ****cofAC; //!< AC coefficients [8x8block][4x4block][level/run][scan_pos]
8619 int ***cofDC; //!< DC coefficients [yuv][level/run][scan_pos]
8620
8621 int ***fadjust4x4; //!< Transform coefficients for 4x4 luma. Excludes DC for I16x16
8622 int ***fadjust8x8; //!< Transform coefficients for 8x8 luma
8623 int ****fadjust4x4Cr; //!< Transform coefficients for 4x4 chroma. Excludes DC chroma.
8624 int ****fadjust8x8Cr; //!< Transform coefficients for 4x4 chroma within 8x8 inter blocks.
8625
8626
8627 Picture *currentPicture; //!< The coded picture currently in the works (typically frame_pic, top_pic, or bottom_pic)
8628 Slice *currentSlice; //!< pointer to current Slice data struct
8629 Macroblock *mb_data; //!< array containing all MBs of a whole frame
8630
8631 int *quad; //!< Array containing square values,used for snr computation */ /* Values are limited to 5000 for pixel differences over 70 (sqr(5000)).
8632 int *intra_block;
8633
8634 int tr;
8635 int fld_type; //!< top or bottom field
8636 unsigned int fld_flag;
8637 unsigned int rd_pass;
8638 int direct_intraP_ref[4][4];
8639 int pstruct_next_P;
8640 int imgtr_next_P_frm;
8641 int imgtr_last_P_frm;
8642 int imgtr_next_P_fld;
8643 int imgtr_last_P_fld;
8644
8645 // B pictures
8646 double b_interval;
8647 int p_interval;
8648 int b_frame_to_code;
8649 int fw_mb_mode;
8650 int bw_mb_mode;
8651
8652 short****** pred_mv; //!< motion vector predictors for all block types and all reference frames
8653 short****** all_mv; //!< replaces local all_mv
8654
8655 short****** bipred_mv1; //!< Biprediction MVs
8656 short****** bipred_mv2; //!< Biprediction MVs
8657 short bi_pred_me[MAXMODE];
8658
8659 int LFDisableIdc;
8660 int LFAlphaC0Offset;
8661 int LFBetaOffset;
8662
8663 int direct_spatial_mv_pred_flag; //!< Direct Mode type to be used (0: Temporal, 1: Spatial)
8664
8665 int num_ref_idx_l0_active;
8666 int num_ref_idx_l1_active;
8667
8668 int field_mode; //!< For MB level field/frame -- field mode on flag
8669 int top_field; //!< For MB level field/frame -- top field flag
8670 int mvscale[6][MAX_REFERENCE_PICTURES];
8671 int buf_cycle;
8672 int i16offset;
8673
8674 int layer; //!< which layer this picture belonged to
8675 int old_layer; //!< old layer number
8676 int NoResidueDirect;
8677 int AdaptiveRounding; //!< Adaptive Rounding parameter based on JVT-N011
8678
8679 int redundant_pic_cnt; // JVT-D101
8680
8681 int MbaffFrameFlag; //!< indicates frame with mb aff coding
8682
8683 //the following should probably go in sequence parameters
8684 unsigned int pic_order_cnt_type;
8685
8686 // for poc mode 1
8687 Boolean delta_pic_order_always_zero_flag;
8688 int offset_for_non_ref_pic;
8689 int offset_for_top_to_bottom_field;
8690 unsigned int num_ref_frames_in_pic_order_cnt_cycle;
8691 int offset_for_ref_frame[1];
8692
8693 //the following is for slice header syntax elements of poc
8694 // for poc mode 0.
8695 unsigned int pic_order_cnt_lsb;
8696 int delta_pic_order_cnt_bottom;
8697 // for poc mode 1.
8698 int delta_pic_order_cnt[2];
8699
8700
8701 unsigned int field_picture;
8702 signed int toppoc; //!< poc for this frame or field
8703 signed int bottompoc; //!< for completeness - poc of bottom field of a frame (always = poc+1)
8704 signed int framepoc; //!< min (toppoc, bottompoc)
8705 signed int ThisPOC; //!< current picture POC
8706 unsigned int frame_num; //!< frame_num for this frame
8707
8708 unsigned int PicWidthInMbs;
8709 unsigned int PicHeightInMapUnits;
8710 unsigned int FrameHeightInMbs;
8711 unsigned int PicSizeInMbs;
8712 unsigned int FrameSizeInMbs;
8713
8714 //the following should probably go in picture parameters
8715 Boolean pic_order_present_flag; // ????????
8716
8717 //the following are sent in the slice header
8718// int delta_pic_order_cnt[2];
8719 int nal_reference_idc;
8720
8721 int adaptive_ref_pic_buffering_flag;
8722 int no_output_of_prior_pics_flag;
8723 int long_term_reference_flag;
8724
8725 DecRefPicMarking_t *dec_ref_pic_marking_buffer;
8726
8727 int model_number;
8728
8729 // rate control variables
8730 int NumberofCodedMacroBlocks;
8731 int BasicUnitQP;
8732 int NumberofMBTextureBits;
8733 int NumberofMBHeaderBits;
8734 unsigned int BasicUnit;
8735 int write_macroblock;
8736 int bot_MB;
8737 int write_mbaff_frame;
8738
8739 int DeblockCall;
8740
8741 int last_pic_bottom_field;
8742 int last_has_mmco_5;
8743 int pre_frame_num;
8744
8745 int slice_group_change_cycle;
8746
8747 int pic_unit_size_on_disk;
8748 int bitdepth_luma;
8749 int bitdepth_chroma;
8750 int bitdepth_luma_qp_scale;
8751 int bitdepth_chroma_qp_scale;
8752 int bitdepth_lambda_scale;
8753 int max_bitCount;
8754 int max_qp_delta;
8755 int min_qp_delta;
8756 // Lagrangian Parameters
8757 double **lambda_md; //!< Mode decision Lambda
8758 double ***lambda_me; //!< Motion Estimation Lambda
8759 int ***lambda_mf; //!< Integer formatted Motion Estimation Lambda
8760
8761 double **lambda_mf_factor; //!< Motion Estimation Lamda Scale Factor
8762
8763 unsigned int dc_pred_value_luma; //!< luma value for DC prediction (depends on luma pel bit depth)
8764 unsigned int dc_pred_value_chroma; //!< chroma value for DC prediction (depends on chroma pel bit depth)
8765 int max_imgpel_value; //!< max value that one picture element (pixel) can take (depends on pic_unit_bitdepth)
8766 int max_imgpel_value_uv;
8767
8768 int num_blk8x8_uv;
8769 int num_cdc_coeff;
8770 int yuv_format;
8771 int lossless_qpprime_flag;
8772 int mb_cr_size_x;
8773 int mb_cr_size_y;
8774 int mb_size[3][2];
8775
8776 int chroma_qp_offset[2]; //!< offset for qp for chroma [0-Cb, 1-Cr]
8777
8778 int auto_crop_right;
8779 int auto_crop_bottom;
8780
8781 short checkref;
8782 int last_valid_reference;
8783 int bytes_in_picture;
8784
8785 int AverageFrameQP;
8786 int SumFrameQP;
8787 int GopLevels;
8788} ImageParameters;
8789
8790#define NUM_PIC_TYPE 5
8791 //!< statistics
8792typedef struct
8793{
8794 int quant0; //!< quant for the first frame
8795 int quant1; //!< average quant for the remaining frames
8796 float bitr; //!< bit rate for current frame, used only for output til terminal
8797 float bitrate; //!< average bit rate for the sequence except first frame
8798 int64 bit_ctr; //!< counter for bit usage
8799 int64 bit_ctr_n; //!< bit usage for the current frame
8800 int bit_slice; //!< number of bits in current slice
8801 int stored_bit_slice; //!< keep number of bits in current slice (to restore status in case of MB re-encoding)
8802 int bit_ctr_emulationprevention; //!< stored bits needed to prevent start code emulation
8803 int b8_mode_0_use[NUM_PIC_TYPE][2];
8804 int mode_use_transform_8x8[NUM_PIC_TYPE][MAXMODE];
8805 int mode_use_transform_4x4[NUM_PIC_TYPE][MAXMODE];
8806 int intra_chroma_mode[4];
8807
8808 // B pictures
8809 int successive_Bframe;
8810 int *mode_use_Bframe;
8811 int *bit_use_mode_Bframe;
8812 int64 bit_ctr_I;
8813 int64 bit_ctr_P;
8814 int64 bit_ctr_B;
8815 float bitrate_I;
8816 float bitrate_P;
8817 float bitrate_B;
8818
8819 int64 mode_use [NUM_PIC_TYPE][MAXMODE]; //!< Macroblock mode usage for Intra frames
8820 int64 bit_use_mode [NUM_PIC_TYPE][MAXMODE]; //!< statistics of bit usage
8821 int64 bit_use_stuffingBits[NUM_PIC_TYPE];
8822 int64 bit_use_mb_type [NUM_PIC_TYPE];
8823 int64 bit_use_header [NUM_PIC_TYPE];
8824 int64 tmp_bit_use_cbp [NUM_PIC_TYPE];
8825 int64 bit_use_coeffY [NUM_PIC_TYPE];
8826 int64 bit_use_coeffC [NUM_PIC_TYPE];
8827 int64 bit_use_delta_quant [NUM_PIC_TYPE];
8828
8829 int em_prev_bits_frm;
8830 int em_prev_bits_fld;
8831 int *em_prev_bits;
8832 int bit_ctr_parametersets;
8833 int bit_ctr_parametersets_n;
8834 } StatParameters;
8835
8836//! For MB level field/frame coding tools
8837//! temporary structure to store MB data for field/frame coding
8838typedef struct
8839{
8840 double min_rdcost;
8841
8842 imgpel rec_mbY[16][16]; // hold the Y component of reconstructed MB
8843 imgpel rec_mbU[16][16], rec_mbV[16][16];
8844 int ****cofAC;
8845 int ***cofDC;
8846 int mb_type;
8847 short bi_pred_me;
8848
8849 int b8mode[4], b8pdir[4];
8850 signed char **ipredmode;
8851 signed char intra_pred_modes[16];
8852 signed char intra_pred_modes8x8[16];
8853 int cbp;
8854 int64 cbp_blk;
8855 int mode;
8856 short ******pred_mv; //!< predicted motion vectors
8857 short ******all_mv; //!< all modes motion vectors
8858 signed char refar[2][4][4];//!< reference frame array [list][y][x]
8859 int i16offset;
8860 int c_ipred_mode;
8861
8862 int luma_transform_size_8x8_flag;
8863 int NoMbPartLessThan8x8Flag;
8864
8865 int qp;
8866 int prev_qp;
8867 int prev_delta_qp;
8868 int delta_qp;
8869 int prev_cbp;
8870} RD_DATA;
8871
8872
8873//! Set Explicit GOP Parameters.
8874//! Currently only supports Enhancement GOP but could be easily extended
8875typedef struct
8876{
8877 int slice_type; //! Slice type
8878 int display_no; //! GOP Display order
8879 int reference_idc; //! Is reference?
8880 int slice_qp; //! Assigned QP
8881 int hierarchy_layer; //! Hierarchy layer (used with GOP Hierarchy option 2)
8882 int hierarchyPocDelta; //! Currently unused
8883} GOP_DATA;
8884
8885
8886typedef struct
8887{
8888 int cost8x8;
8889 int rec_resG_8x8[16][16];
8890 int resTrans_R_8x8[16][16];
8891 int resTrans_B_8x8[16][16];
8892 int mprRGB_8x8[3][16][16];
8893 short part8x8mode[4];
8894 signed char part8x8pdir[4];
8895 signed char part8x8fwref[4];
8896 signed char part8x8bwref[4];
8897 imgpel rec_mbY8x8[16][16];
8898 imgpel mpr8x8[16][16];
8899 int lrec[16][16]; // transform and quantized coefficients will be stored here for SP frames
8900} RD_8x8DATA;
8901
8902typedef struct
8903{
8904 double lambda_md; //!< Mode decision Lambda
8905 double lambda_me[3]; //!< Motion Estimation Lambda
8906 int lambda_mf[3]; //!< Integer formatted Motion Estimation Lambda
8907
8908 short valid[MAXMODE];
8909 short list_offset[2];
8910 short curr_mb_field;
8911 short best_ref[2];
8912 int best_mcost[2];
8913} RD_PARAMS;
8914
8915GOP_DATA *gop_structure;
8916RD_DATA *rdopt;
8917RD_DATA rddata_top_frame_mb, rddata_bot_frame_mb; //!< For MB level field/frame coding tools
8918RD_DATA rddata_top_field_mb, rddata_bot_field_mb; //!< For MB level field/frame coding tools
8919
8920extern InputParameters *input;
8921extern ImageParameters *img;
8922extern StatParameters *stats;
8923
8924extern SNRParameters *snr;
8925
8926// files
8927FILE *p_stat; //!< status file for the last encoding session
8928FILE *p_log; //!< SNR file
8929FILE *p_trace; //!< Trace file
8930int p_in; //!< original YUV file handle
8931int p_dec; //!< decoded image file handle
8932
8933
8934/***********************************************************************
8935 * P r o t o t y p e s f o r T M L
8936 ***********************************************************************
8937 */
8938
8939void intrapred_luma(int CurrPixX,int CurrPixY, int *left_available, int *up_available, int *all_available);
8940int dct_luma(int pos_mb1,int pos_mb2,int *cnt_nonz, int intra);
8941int dct_luma_sp(int pos_mb1,int pos_mb2,int *cnt_nonz);
8942void copyblock_sp(int pos_mb1,int pos_mb2);
8943int dct_chroma(int uv,int i11);
8944int dct_chroma_sp(int uv,int i11);
8945
8946void intrapred_luma_16x16(void);
8947
8948int dct_luma_16x16(int);
8949
8950void init_poc(void);
8951
8952void init_img(void);
8953void report(void);
8954int get_picture_type(void);
8955void DeblockFrame(ImageParameters *img, imgpel **, imgpel ***) ;
8956
8957int distortion4x4(int*);
8958int distortion8x8(int*);
8959
8960extern int* refbits;
8961extern int**** motion_cost;
8962double *mb16x16_cost_frame;
8963
8964void Get_Direct_Motion_Vectors (void);
8965void PartitionMotionSearch (int, int, int*);
8966int BIDPartitionCost (int, int, short, short, int);
8967int writeAbpCoeffIndex (int, int, int, int);
8968
8969void estimate_weighting_factor_B_slice(void);
8970void estimate_weighting_factor_P_slice(int offset);
8971int test_wp_P_slice(int offset);
8972int test_wp_B_slice(int method);
8973void poc_based_ref_management(int current_pic_num);
8974int picture_coding_decision (Picture *picture1, Picture *picture2, int qp);
8975
8976unsigned CeilLog2( unsigned uiVal);
8977
8978int GetDirectCost8x8 (int, int*);
8979
8980int BPredPartitionCost (int, int, short, short, int, int);
8981
8982int GetDirectCostMB (void);
8983
8984int GetSkipCostMB (void);
8985void FindSkipModeMotionVector (void);
8986
8987
8988// dynamic mem allocation
8989int init_global_buffers(void);
8990void free_global_buffers(void);
8991void no_mem_exit (char *where);
8992
8993int get_mem_mv (short*******);
8994void free_mem_mv (short******);
8995void free_img (void);
8996
8997int get_mem_ACcoeff (int*****);
8998int get_mem_DCcoeff (int****);
8999void free_mem_ACcoeff (int****);
9000void free_mem_DCcoeff (int***);
9001
9002int decide_fld_frame(float snr_frame_Y, float snr_field_Y, int bit_field, int bit_frame, double lambda_picture);
9003void combine_field(void);
9004
9005Picture *malloc_picture(void);
9006void free_picture (Picture *pic);
9007
9008int encode_one_slice(int SLiceGroupId, Picture *pic, int TotalCodedMBs); //! returns the number of MBs in the slice
9009
9010void free_slice_list(Picture *currPic);
9011
9012void report_stats_on_error(void);
9013
9014#if TRACE
9015void trace2out(SyntaxElement *se);
9016void trace2out_cabac(SyntaxElement *se);
9017#endif
9018# 1333 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
9019
9020
9021void error(char *text, int code);
9022int start_sequence(void);
9023int rewrite_paramsets(void);
9024int terminate_sequence(void);
9025int start_slice(void);
9026int terminate_slice(int);
9027int write_PPS(int, int);
9028
9029// B pictures
9030int get_fwMV(int *min_fw_sad, int tot_intra_sad);
9031void get_bwMV(int *min_bw_sad);
9032void get_bid(int *bid_sad, int fw_predframe_no);
9033void get_dir(int *dir_sad);
9034void compare_sad(int tot_intra_sad, int fw_sad, int bw_sad, int bid_sad, int dir_sad, int);
9035int BlkSize2CodeNumber(int blc_size_h, int blc_size_v);
9036
9037void InitMotionVectorSearchModule(void);
9038
9039int field_flag_inference(void);
9040
9041void set_mbaff_parameters(void); // For MB AFF
9042void writeVlcByteAlign(Bitstream* currStream);
9043
9044
9045int writeMB_bits_for_4x4_luma (int, int, int);
9046int writeMB_bits_for_16x16_luma (void);
9047int writeMB_bits_for_luma (int);
9048int writeMB_bits_for_DC_chroma (int);
9049int writeMB_bits_for_AC_chroma (int);
9050int writeMB_bits_for_CBP (void);
9051
9052int SingleUnifiedMotionSearch (int, int, int**, int***, int*****, int, int*****, double);
9053
9054//============= rate-distortion optimization ===================
9055void clear_rdopt (void);
9056void init_rdopt (void);
9057void RD_Mode_Decision (void);
9058//============= rate-distortion opt with packet losses ===========
9059void decode_one_macroblock(void);
9060void decode_one_mb (int, Macroblock*);
9061void decode_one_b8block (int, int, int, int, int);
9062void Get_Reference_Block(imgpel **imY, int block_y, int block_x, int mvhor, int mvver, imgpel **out);
9063byte Get_Reference_Pixel(imgpel **imY, int y, int x);
9064int Half_Upsample(imgpel **imY, int j, int i);
9065void DecOneForthPix(imgpel **dY, imgpel ***dref);
9066void compute_residue(int mode);
9067void compute_residue_b8block (int, int);
9068void compute_residue_mb (int);
9069void UpdateDecoders(void);
9070void Build_Status_Map(byte **s_map);
9071void Error_Concealment(imgpel **inY, byte **s_map, imgpel ***refY);
9072void Conceal_Error(imgpel **inY, int mb_y, int mb_x, imgpel ***refY, byte **s_map);
9073//============= restriction of reference frames based on the latest intra-refreshes==========
9074void UpdatePixelMap(void);
9075
9076//============= fast full integer search =======================
9077void ClearFastFullIntegerSearch (void);
9078void ResetFastFullIntegerSearch (void);
9079
9080void process_2nd_IGOP(void);
9081void SetImgType(void);
9082
9083// Tian Dong: for IGOPs
9084extern Boolean In2ndIGOP;
9085extern int start_frame_no_in_this_IGOP;
9086extern int start_tr_in_this_IGOP;
9087extern int FirstFrameIn2ndIGOP;
9088#define IMG_NUMBER (img->number - start_frame_no_in_this_IGOP)
9089
9090void AllocNalPayloadBuffer(void);
9091void FreeNalPayloadBuffer(void);
9092void SODBtoRBSP(Bitstream *currStream);
9093int RBSPtoEBSP(byte *streamBuffer, int begin_bytepos, int end_bytepos, int min_num_bytes);
9094int Bytes_After_Header;
9095
9096// Fast ME enable
9097int BlockMotionSearch (short,int,int,int,int,int, int*);
9098void low_complexity_encode_md (void);
9099void encode_one_macroblock_low (void);
9100void encode_one_macroblock_high (void);
9101void encode_one_macroblock_highfast (void);
9102void encode_one_macroblock_highloss (void);
9103void (*encode_one_macroblock) (void);
9104
9105
9106void set_chroma_qp(Macroblock *currMB);
9107
9108
9109#if 0 /* expanded by -frewrite-includes */
9110#include "context_ini.h"
9111#endif /* expanded by -frewrite-includes */
9112# 1423 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
9113# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/context_ini.h" 1
9114
9115/*!
9116 *************************************************************************************
9117 * \file context_ini.h
9118 *
9119 * \brief
9120 * CABAC context initializations
9121 *
9122 * \author
9123 * Main contributors (see contributors.h for copyright, address and affiliation details)
9124 * - Detlev Marpe <marpe@hhi.de>
9125 * - Heiko Schwarz <hschwarz@hhi.de>
9126 **************************************************************************************
9127 */
9128
9129#ifndef _CONTEXT_INI_
9130#define _CONTEXT_INI_
9131
9132
9133void create_context_memory (void);
9134void free_context_memory (void);
9135
9136void init_contexts (void);
9137void store_contexts (void);
9138
9139void update_field_frame_contexts (int);
9140void update_rd_picture_contexts (int);
9141
9142void SetCtxModelNumber (void);
9143
9144#endif
9145# 32 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/context_ini.h"
9146
9147# 1424 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h" 2
9148
9149void store_coding_state_cs_cm(void);
9150void reset_coding_state_cs_cm(void);
9151
9152int writeIPCMBytes(Bitstream *currStream);
9153int writePCMByteAlign(Bitstream *currStream);
9154
9155
9156int dct_luma_sp2(int pos_mb1,int pos_mb2,int *cnt_nonz);
9157int dct_chroma_sp2(int ,int);
9158
9159int check_for_SI16(void);
9160int **lrec ;
9161int ***lrec_uv;
9162int si_frame_indicator;
9163
9164int sp2_frame_indicator;
9165int number_sp2_frames;
9166//#define sp_output_indicator 0 //will be in the config file
9167//#define sp_output_filename "sp_stored.txt" // will be in the config file
9168void output_SP_coefficients(void);
9169void read_SP_coefficients(void);
9170
9171int giRDOpt_B8OnlyFlag;
9172
9173#ifdef BEST_NZ_COEFF
9174int gaaiMBAFF_NZCoeff[4][12];
9175#endif
9176# 1452 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
9177
9178// Redundant picture
9179imgpel **imgY_tmp;
9180imgpel **imgUV_tmp[2];
9181int frameNuminGOP;
9182int redundant_coding;
9183int key_frame;
9184int redundant_ref_idx;
9185void Init_redundant_frame(void);
9186void Set_redundant_frame(void);
9187void encode_one_redundant_frame(void);
9188
9189int img_pad_size_uv_x;
9190int img_pad_size_uv_y;
9191
9192unsigned char chroma_mask_mv_y;
9193unsigned char chroma_mask_mv_x;
9194int chroma_shift_y, chroma_shift_x;
9195int shift_cr_x, shift_cr_y;
9196int img_padded_size_x;
9197int img_cr_padded_size_x;
9198
9199// struct with pointers to the sub-images
9200typedef struct {
9201 imgpel ****luma; // component 0 (usually Y, X, or R)
9202 imgpel ****crcb[2]; // component 2 (usually U/V, Y/Z, or G/B)
9203} SubImageContainer;
9204
9205int start_me_refinement_hp; // if set then recheck the center position when doing half-pel motion refinement
9206int start_me_refinement_qp; // if set then recheck the center position when doing quarter-pel motion refinement
9207
9208#endif
9209# 1484 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/global.h"
9210
9211# 27 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
9212
9213#if 0 /* expanded by -frewrite-includes */
9214#include "rdopt_coding_state.h"
9215#endif /* expanded by -frewrite-includes */
9216# 28 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
9217# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt_coding_state.h" 1
9218
9219/*!
9220 ***************************************************************************
9221 * \file
9222 * rdopt_coding_state.h
9223 *
9224 * \author
9225 * Heiko Schwarz
9226 *
9227 * \date
9228 * 17. April 2001
9229 *
9230 * \brief
9231 * Headerfile for storing/restoring coding state
9232 * (for rd-optimized mode decision)
9233 **************************************************************************
9234 */
9235
9236#ifndef _RD_OPT_CS_H_
9237#define _RD_OPT_CS_H_
9238
9239typedef struct {
9240
9241 // important variables of data partition array
9242 int no_part;
9243 EncodingEnvironment *encenv;
9244 Bitstream *bitstream;
9245
9246 // contexts for binary arithmetic coding
9247 int symbol_mode;
9248 MotionInfoContexts *mot_ctx;
9249 TextureInfoContexts *tex_ctx;
9250
9251 // bit counter
9252 int bitcounter[MAX_BITCOUNTER_MB];
9253
9254 // elements of current macroblock
9255 int mvd[2][BLOCK_MULTIPLE][BLOCK_MULTIPLE][2];
9256 int64 cbp_bits;
9257} CSobj;
9258typedef CSobj* CSptr;
9259
9260
9261void delete_coding_state (CSptr); //!< delete structure
9262CSptr create_coding_state (void); //!< create structure
9263
9264void store_coding_state (CSptr); //!< store parameters
9265void reset_coding_state (CSptr); //!< restore parameters
9266
9267
9268#endif
9269# 52 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt_coding_state.h"
9270
9271# 29 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
9272#if 0 /* expanded by -frewrite-includes */
9273#include "memalloc.h"
9274#endif /* expanded by -frewrite-includes */
9275# 29 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
9276# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/memalloc.h" 1
9277
9278/*!
9279 ************************************************************************
9280 * \file memalloc.h
9281 *
9282 * \brief
9283 * Memory allocation and free helper funtions
9284 *
9285 * \author
9286 * Main contributors (see contributors.h for copyright, address and affiliation details)
9287 ************************************************************************
9288 */
9289
9290#ifndef _MEMALLOC_H_
9291#define _MEMALLOC_H_
9292
9293int get_mem2D(byte ***array2D, int rows, int columns);
9294int get_mem3D(byte ****array2D, int frames, int rows, int columns);
9295
9296int get_mem2Dint(int ***array2D, int rows, int columns);
9297int get_mem3Dint(int ****array3D, int frames, int rows, int columns);
9298int get_mem4Dint(int *****array4D, int idx, int frames, int rows, int columns );
9299int get_mem5Dint(int ******array5D, int refs, int blocktype, int rows, int columns, int component);
9300
9301int get_mem2Dint64(int64 ***array2D, int rows, int columns);
9302int get_mem3Dint64(int64 ****array3D, int frames, int rows, int columns);
9303
9304int get_mem2Dshort(short ***array2D, int rows, int columns);
9305int get_mem3Dshort(short ****array3D, int frames, int rows, int columns);
9306int get_mem4Dshort(short *****array4D, int idx, int frames, int rows, int columns );
9307int get_mem5Dshort(short ******array5D, int refs, int blocktype, int rows, int columns, int component);
9308int get_mem6Dshort(short *******array6D, int list, int refs, int blocktype, int rows, int columns, int component);
9309
9310int get_mem2Dpel(imgpel ***array2D, int rows, int columns);
9311int get_mem3Dpel(imgpel ****array3D, int frames, int rows, int columns);
9312int get_mem4Dpel(imgpel *****array4D, int sub_x, int sub_y, int rows, int columns);
9313int get_mem5Dpel(imgpel ******array5D, int dims, int sub_x, int sub_y, int rows, int columns);
9314
9315int get_mem2Ddouble(double ***array2D, int rows, int columns);
9316int get_mem2Ddb_offset(double ***array2D, int rows, int columns, int offset);
9317int get_mem3Ddb_offset(double ****array2D, int rows, int columns, int pels, int offset);
9318
9319int get_mem2Dint_offset(int ***array2D, int rows, int columns, int offset);
9320int get_mem3Dint_offset(int ****array3D, int rows, int columns, int pels, int offset);
9321
9322void free_mem2D(byte **array2D);
9323void free_mem3D(byte ***array2D, int frames);
9324
9325void free_mem2Dint(int **array2D);
9326void free_mem3Dint(int ***array3D, int frames);
9327void free_mem4Dint(int ****array4D, int idx, int frames);
9328void free_mem5Dint(int *****array5D, int refs, int blocktype, int rows);
9329
9330void free_mem2Dint64(int64 **array2D);
9331void free_mem3Dint64(int64 ***array3D64, int frames);
9332
9333void free_mem2Dshort(short **array2D);
9334void free_mem3Dshort(short ***array3D, int frames);
9335void free_mem4Dshort(short ****array4D, int idx, int frames);
9336void free_mem5Dshort(short *****array5D, int refs, int blocktype, int height);
9337void free_mem6Dshort(short ******array5D, int list, int refs, int blocktype, int height);
9338
9339void free_mem2Dpel(imgpel **array2D);
9340void free_mem3Dpel(imgpel ***array3D, int frames);
9341void free_mem4Dpel(imgpel ****array4D, int sub_x, int sub_y);
9342void free_mem5Dpel(imgpel *****array5D, int dims, int sub_x, int sub_y);
9343
9344void free_mem2Ddouble(double **array2D);
9345void free_mem2Ddb_offset(double **array2D, int offset);
9346void free_mem2Dint_offset(int **array2D, int offset);
9347void free_mem3Ddb_offset(double ***array3D, int rows, int columns, int offset);
9348void free_mem3Dint_offset(int ***array3D, int rows, int columns, int offset);
9349
9350int init_top_bot_planes(imgpel **imgFrame, int rows, int columns, imgpel ***imgTopField, imgpel ***imgBotField);
9351void free_top_bot_planes(imgpel **imgTopField, imgpel **imgBotField);
9352
9353
9354void no_mem_exit(char *where);
9355
9356#endif
9357# 81 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/memalloc.h"
9358# 30 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
9359#if 0 /* expanded by -frewrite-includes */
9360#include "mb_access.h"
9361#endif /* expanded by -frewrite-includes */
9362# 30 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
9363# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/mb_access.h" 1
9364
9365/*!
9366 *************************************************************************************
9367 * \file mb_access.h
9368 *
9369 * \brief
9370 * Functions for macroblock neighborhoods
9371 *
9372 * \author
9373 * Main contributors (see contributors.h for copyright, address and affiliation details)
9374 * - Karsten Sühring <suehring@hhi.de>
9375 *************************************************************************************
9376 */
9377
9378#ifndef _MB_ACCESS_H_
9379#define _MB_ACCESS_H_
9380
9381void CheckAvailabilityOfNeighbors(void);
9382
9383void (*getNeighbour)(unsigned int curr_mb_nr, int xN, int yN, int is_chroma, PixelPos *pix);
9384void getAffNeighbour(unsigned int curr_mb_nr, int xN, int yN, int is_chroma, PixelPos *pix);
9385void getNonAffNeighbour(unsigned int curr_mb_nr, int xN, int yN, int is_chroma, PixelPos *pix);
9386void getLuma4x4Neighbour (int curr_mb_nr, int block_x, int block_y, PixelPos *pix);
9387void getChroma4x4Neighbour (int curr_mb_nr, int block_x, int block_y, PixelPos *pix);
9388int mb_is_available(int mbAddr, int currMbAddr);
9389void get_mb_pos (int mb_addr, int *x, int*y, int is_chroma);
9390void (*get_mb_block_pos) (int mb_addr, int *x, int*y);
9391void get_mb_block_pos_normal (int mb_addr, int *x, int*y);
9392void get_mb_block_pos_mbaff (int mb_addr, int *x, int*y);
9393
9394
9395
9396#endif
9397# 34 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/mb_access.h"
9398# 31 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
9399#if 0 /* expanded by -frewrite-includes */
9400#include "elements.h"
9401#endif /* expanded by -frewrite-includes */
9402# 31 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
9403# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/elements.h" 1
9404
9405/*!
9406 **************************************************************************
9407 * \file elements.h
9408 * \brief Header file for elements in H.264 streams
9409 * \date 6.10.2000,
9410 * \version
9411 * 1.1
9412 *
9413 * \note
9414 * Version 1.0 included three partition modes, no DP, 2 partitionsper slice
9415 * and 4 partitions per slice. As per document VCEG-N72 this is changed
9416 * in version 1.1 to only two partition modes, one without DP and one with
9417 * 3 partition per slice
9418 *
9419 * \author Sebastian Purreiter <sebastian.purreiter@mch.siemens.de>
9420 * \author Stephan Wenger <stewe@cs.tu-berlin.de>
9421 *
9422 **************************************************************************
9423 */
9424
9425#ifndef _ELEMENTS_H_
9426#define _ELEMENTS_H_
9427
9428/*!
9429 * definition of H.264 syntax elements
9430 * order of elements follow dependencies for picture reconstruction
9431 */
9432
9433#define MAXPARTITIONMODES 2 //!< maximum possible partition modes as defined in assignSE2partition[][]
9434
9435/*!
9436 * \brief lookup-table to assign different elements to partition
9437 *
9438 * \note here we defined up to 6 different partitions similar to
9439 * document Q15-k-18 described in the PROGFRAMEMODE.
9440 * The Sliceheader contains the PSYNC information. \par
9441 *
9442 * Elements inside a partition are not ordered. They are
9443 * ordered by occurence in the stream.
9444 * Assumption: Only partitionlosses are considered. \par
9445 *
9446 * The texture elements luminance and chrominance are
9447 * not ordered in the progressive form
9448 * This may be changed in image.c \par
9449 *
9450 * -IMPORTANT:
9451 * Picture- or Sliceheaders must be assigned to partition 0. \par
9452 * Furthermore partitions must follow syntax dependencies as
9453 * outlined in document Q15-J-23.
9454 */
9455
9456
9457// A note on this table:
9458//
9459// While the assignment of values in enum data types is specified in C, it is not
9460// very ood style to have an "elementnumber", not even as a comment.
9461//
9462// Hence a copy of the relevant structure from global.h here
9463/*
9464typedef enum {
9465 0 SE_HEADER,
9466 1 SE_PTYPE,
9467 2 SE_MBTYPE,
9468 3 SE_REFFRAME,
9469 4 SE_INTRAPREDMODE,
9470 5 SE_MVD,
9471 6 SE_CBP
9472 7 SE_LUM_DC_INTRA,
9473 8 SE_CHR_DC_INTRA,
9474 9 SE_LUM_AC_INTRA,
947510 SE_CHR_AC_INTRA,
947612 SE_LUM_DC_INTER,
947713 SE_CHR_DC_INTER,
947814 SE_LUM_AC_INTER,
947915 SE_CHR_AC_INTER,
948016 SE_DELTA_QUANT,
948118 SE_BFRAME,
948219 SE_EOS,
948320 SE_MAX_ELEMENTS */ // number of maximum syntax elements
9484//} SE_type;
9485
9486
9487extern int * assignSE2partition[2];
9488extern int assignSE2partition_NoDP[SE_MAX_ELEMENTS];
9489extern int assignSE2partition_DP[SE_MAX_ELEMENTS];
9490
9491#endif
9492# 89 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/elements.h"
9493
9494# 32 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
9495#if 0 /* expanded by -frewrite-includes */
9496#include "intrarefresh.h"
9497#endif /* expanded by -frewrite-includes */
9498# 32 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
9499# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/intrarefresh.h" 1
9500
9501/*!
9502 ***************************************************************************
9503 *
9504 * \file intrarefresh.h
9505 *
9506 * \brief
9507 * Pseudo-Raqndom Intra macroblock refresh support
9508 *
9509 * \date
9510 * 16 June 2002
9511 *
9512 * \author
9513 * Stephan Wenger stewe@cs.tu-berlin.de
9514 **************************************************************************/
9515
9516#ifndef _INTRAREFRESH_H_
9517#define _INTRAREFRESH_H_
9518
9519void RandomIntraInit(int xsize, int ysize, int refresh);
9520void RandomIntraUninit(void);
9521int RandomIntra (int mb); //! returns 1 for MBs that need forced Intra
9522void RandomIntraNewPicture (void); //! to be called once per picture
9523
9524
9525#endif //_INTRAREFRESH_H_
9526# 27 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/intrarefresh.h"
9527# 33 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
9528#if 0 /* expanded by -frewrite-includes */
9529#include "image.h"
9530#endif /* expanded by -frewrite-includes */
9531# 33 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
9532# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/image.h" 1
9533
9534/*!
9535 ************************************************************************
9536 * \file image.h
9537 *
9538 * \brief
9539 * headers for image processing
9540 *
9541 * \author
9542 * Inge Lille-Langoy <inge.lille-langoy@telenor.com>
9543 * Copyright (C) 1999 Telenor Satellite Services, Norway
9544 ************************************************************************
9545 */
9546#ifndef _IMAGE_H_
9547#define _IMAGE_H_
9548
9549#if 0 /* expanded by -frewrite-includes */
9550#include "mbuffer.h"
9551#endif /* expanded by -frewrite-includes */
9552# 17 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/image.h"
9553# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/mbuffer.h" 1
9554
9555/*!
9556 ***********************************************************************
9557 * \file
9558 * mbuffer.h
9559 *
9560 * \brief
9561 * Frame buffer functions
9562 *
9563 * \author
9564 * Main contributors (see contributors.h for copyright, address and affiliation details)
9565 * - Karsten Sühring <suehring@hhi.de>
9566 ***********************************************************************
9567 */
9568#ifndef _MBUFFER_H_
9569#define _MBUFFER_H_
9570
9571#define MAX_LIST_SIZE 33
9572
9573//! definition a picture (field or frame)
9574typedef struct storable_picture
9575{
9576 PictureStructure structure;
9577
9578 int poc;
9579 int top_poc;
9580 int bottom_poc;
9581 int frame_poc;
9582 int order_num;
9583 int64 ref_pic_num[6][MAX_LIST_SIZE];
9584 int64 frm_ref_pic_num[6][MAX_LIST_SIZE];
9585 int64 top_ref_pic_num[6][MAX_LIST_SIZE];
9586 int64 bottom_ref_pic_num[6][MAX_LIST_SIZE];
9587 unsigned frame_num;
9588 int pic_num;
9589 int long_term_pic_num;
9590 int long_term_frame_idx;
9591
9592 int is_long_term;
9593 int used_for_reference;
9594 int is_output;
9595 int non_existing;
9596
9597 int size_x, size_y, size_x_cr, size_y_cr;
9598 int size_x_pad, size_y_pad;
9599 int size_x_cr_pad, size_y_cr_pad;
9600 int chroma_vector_adjustment;
9601 int coded_frame;
9602 int MbaffFrameFlag;
9603
9604 imgpel ** imgY; //!< Y picture component
9605 imgpel **** imgY_sub; //!< Y picture component upsampled (Quarter pel)
9606 imgpel **** imgY_sub_w; //!< Y picture component upsampled (Quarter pel) for weighted prediction
9607 imgpel ***** imgUV_sub; //!< UV picture component upsampled (Quarter/One-Eighth pel)
9608 imgpel *** imgUV; //!< U and V picture components
9609
9610 byte * mb_field; //!< field macroblock indicator
9611
9612 signed char *** ref_idx; //!< reference picture [list][subblock_y][subblock_x]
9613
9614 int64 *** ref_pic_id; //!< reference picture identifier [list][subblock_y][subblock_x]
9615 // (not simply index)
9616
9617 int64 *** ref_id; //!< reference picture identifier [list][subblock_y][subblock_x]
9618 // (not simply index)
9619
9620 short **** mv; //!< motion vector [list][subblock_x][subblock_y][component]
9621
9622 byte ** moving_block;
9623 byte ** field_frame; //!< indicates if co_located is field or frame.
9624
9625 struct storable_picture *top_field; // for mb aff, if frame for referencing the top field
9626 struct storable_picture *bottom_field; // for mb aff, if frame for referencing the bottom field
9627 struct storable_picture *frame; // for mb aff, if field for referencing the combined frame
9628
9629 int chroma_format_idc;
9630 int frame_mbs_only_flag;
9631 int frame_cropping_flag;
9632 int frame_cropping_rect_left_offset;
9633 int frame_cropping_rect_right_offset;
9634 int frame_cropping_rect_top_offset;
9635 int frame_cropping_rect_bottom_offset;
9636} StorablePicture;
9637
9638
9639//! definition a picture (field or frame)
9640typedef struct colocated_params
9641{
9642 int mb_adaptive_frame_field_flag;
9643 int size_x, size_y;
9644
9645 int64 ref_pic_num[6][MAX_LIST_SIZE];
9646
9647 signed char *** ref_idx; //!< reference picture [list][subblock_y][subblock_x]
9648 int64 *** ref_pic_id; //!< reference picture identifier [list][subblock_y][subblock_x]
9649 short **** mv; //!< motion vector [list][subblock_x][subblock_y][component]
9650 byte ** moving_block;
9651
9652 // Top field params
9653 int64 top_ref_pic_num[6][MAX_LIST_SIZE];
9654 signed char *** top_ref_idx; //!< reference picture [list][subblock_y][subblock_x]
9655 int64 *** top_ref_pic_id; //!< reference picture identifier [list][subblock_y][subblock_x]
9656 short **** top_mv; //!< motion vector [list][subblock_x][subblock_y][component]
9657 byte ** top_moving_block;
9658
9659 // Bottom field params
9660 int64 bottom_ref_pic_num[6][MAX_LIST_SIZE];
9661 signed char *** bottom_ref_idx; //!< reference picture [list][subblock_y][subblock_x]
9662 int64 *** bottom_ref_pic_id; //!< reference picture identifier [list][subblock_y][subblock_x]
9663 short **** bottom_mv; //!< motion vector [list][subblock_x][subblock_y][component]
9664 byte ** bottom_moving_block;
9665
9666 byte is_long_term;
9667 byte ** field_frame; //!< indicates if co_located is field or frame.
9668
9669} ColocatedParams;
9670
9671//! Frame Stores for Decoded Picture Buffer
9672typedef struct frame_store
9673{
9674 int is_used; //!< 0=empty; 1=top; 2=bottom; 3=both fields (or frame)
9675 int is_reference; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
9676 int is_long_term; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
9677 int is_orig_reference; //!< original marking by nal_ref_idc: 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
9678
9679 int is_non_existent;
9680
9681 unsigned frame_num;
9682 int frame_num_wrap;
9683 int long_term_frame_idx;
9684 int is_output;
9685 int poc;
9686
9687 StorablePicture *frame;
9688 StorablePicture *top_field;
9689 StorablePicture *bottom_field;
9690
9691} FrameStore;
9692
9693
9694//! Decoded Picture Buffer
9695typedef struct decoded_picture_buffer
9696{
9697 FrameStore **fs;
9698 FrameStore **fs_ref;
9699 FrameStore **fs_ltref;
9700 unsigned size;
9701 unsigned used_size;
9702 unsigned ref_frames_in_buffer;
9703 unsigned ltref_frames_in_buffer;
9704 int last_output_poc;
9705 int max_long_term_pic_idx;
9706
9707 int init_done;
9708
9709 FrameStore *last_picture;
9710} DecodedPictureBuffer;
9711
9712
9713extern DecodedPictureBuffer dpb;
9714extern StorablePicture **listX[6];
9715extern int listXsize[6];
9716
9717void init_dpb(void);
9718void free_dpb(void);
9719FrameStore* alloc_frame_store(void);
9720void free_frame_store(FrameStore* f);
9721StorablePicture* alloc_storable_picture(PictureStructure type, int size_x, int size_y, int size_x_cr, int size_y_cr);
9722void free_storable_picture(StorablePicture* p);
9723void store_picture_in_dpb(StorablePicture* p);
9724void replace_top_pic_with_frame(StorablePicture* p);
9725void flush_dpb(void);
9726
9727void dpb_split_field(FrameStore *fs);
9728void dpb_combine_field(FrameStore *fs);
9729void dpb_combine_field_yuv(FrameStore *fs);
9730
9731void init_lists(int currSliceType, PictureStructure currPicStructure);
9732void reorder_ref_pic_list(StorablePicture **list, int *list_size,
9733 int num_ref_idx_lX_active_minus1, int *reordering_of_pic_nums_idc,
9734 int *abs_diff_pic_num_minus1, int *long_term_pic_idx);
9735
9736void init_mbaff_lists(void);
9737void alloc_ref_pic_list_reordering_buffer(Slice *currSlice);
9738void free_ref_pic_list_reordering_buffer(Slice *currSlice);
9739
9740void fill_frame_num_gap(ImageParameters *img);
9741
9742ColocatedParams* alloc_colocated(int size_x, int size_y,int mb_adaptive_frame_field_flag);
9743void free_colocated(ColocatedParams* p);
9744void compute_colocated(ColocatedParams* p, StorablePicture **listX[6]);
9745
9746#endif
9747# 194 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/mbuffer.h"
9748
9749# 18 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/image.h" 2
9750
9751extern StorablePicture *enc_picture;
9752extern StorablePicture *enc_frame_picture;
9753extern StorablePicture *enc_frame_picture2;
9754extern StorablePicture *enc_frame_picture3;
9755extern StorablePicture *enc_top_picture;
9756extern StorablePicture *enc_bottom_picture;
9757
9758int encode_one_frame (void);
9759void report_frame_statistic(void);
9760Boolean dummy_slice_too_big(int bits_slice);
9761void copy_rdopt_data (int field_type); // For MB level field/frame coding tools
9762
9763void UnifiedOneForthPix (StorablePicture *s);
9764
9765#endif
9766# 34 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/image.h"
9767
9768# 34 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
9769#if 0 /* expanded by -frewrite-includes */
9770#include "transform8x8.h"
9771#endif /* expanded by -frewrite-includes */
9772# 34 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
9773# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/transform8x8.h" 1
9774
9775/*!
9776 ***************************************************************************
9777 *
9778 * \file transform8x8.h
9779 *
9780 * \brief
9781* prototypes of 8x8 transform functions
9782 *
9783 * \date
9784 * 9. October 2003
9785 *
9786 * \author
9787 * Main contributors (see contributors.h for copyright, address and affiliation details)
9788 * Yuri Vatis vatis@hhi.de
9789 **************************************************************************/
9790
9791#ifndef _TRANSFORM8X8_H_
9792#define _TRANSFORM8X8_H_
9793
9794int Mode_Decision_for_new_Intra8x8Macroblock (double lambda, int *min_cost);
9795int Mode_Decision_for_new_8x8IntraBlocks (int b8, double lambda, int *min_cost);
9796
9797void intrapred_luma8x8(int img_x,int img_y, int *left_available, int *up_available, int *all_available);
9798
9799double RDCost_for_8x8IntraBlocks(int *c_nz, int b8, int ipmode, double lambda, double min_rdcost, int mostProbableMode);
9800
9801int dct_luma8x8(int b8,int *coeff_cost, int intra);
9802
9803void LowPassForIntra8x8Pred(imgpel *PredPel, int block_up_left, int block_up, int block_left);
9804
9805#endif //_TRANSFORM8X8_H_
9806# 33 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/transform8x8.h"
9807# 35 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
9808#if 0 /* expanded by -frewrite-includes */
9809#include "cabac.h"
9810#endif /* expanded by -frewrite-includes */
9811# 35 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
9812# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/cabac.h" 1
9813
9814/*!
9815 ***************************************************************************
9816 * \file
9817 * cabac.h
9818 *
9819 * \brief
9820 * Headerfile for entropy coding routines
9821 *
9822 * \author
9823 * Detlev Marpe \n
9824 * Copyright (C) 2000 HEINRICH HERTZ INSTITUTE All Rights Reserved.
9825 *
9826 * \date
9827 * 21. Oct 2000 (Changes by Tobias Oelbaum 28.08.2001)
9828 ***************************************************************************
9829 */
9830
9831
9832#ifndef _CABAC_H_
9833#define _CABAC_H_
9834
9835// CABAC
9836int get_pic_bin_count(void);
9837void reset_pic_bin_count(void);
9838
9839void arienco_start_encoding(EncodingEnvironmentPtr eep, unsigned char *code_buffer, int *code_len);
9840int arienco_bits_written(EncodingEnvironmentPtr eep);
9841void arienco_done_encoding(EncodingEnvironmentPtr eep);
9842void biari_init_context (BiContextTypePtr ctx, const int* ini);
9843void rescale_cum_freq(BiContextTypePtr bi_ct);
9844void biari_encode_symbol(EncodingEnvironmentPtr eep, signed short symbol, BiContextTypePtr bi_ct );
9845void biari_encode_symbol_eq_prob(EncodingEnvironmentPtr eep, signed short symbol);
9846void biari_encode_symbol_final(EncodingEnvironmentPtr eep, signed short symbol);
9847MotionInfoContexts* create_contexts_MotionInfo(void);
9848TextureInfoContexts* create_contexts_TextureInfo(void);
9849void init_contexts_MotionInfo (MotionInfoContexts *enco_ctx);
9850void init_contexts_TextureInfo(TextureInfoContexts *enco_ctx);
9851void delete_contexts_MotionInfo(MotionInfoContexts *enco_ctx);
9852void delete_contexts_TextureInfo(TextureInfoContexts *enco_ctx);
9853void writeHeaderToBuffer(void);
9854void writeMB_typeInfo_CABAC(SyntaxElement *se, DataPartition *dp);
9855void writeIntraPredMode_CABAC(SyntaxElement *se, DataPartition *dp);
9856void writeB8_typeInfo_CABAC(SyntaxElement *se, DataPartition *dp);
9857void writeRefFrame_CABAC(SyntaxElement *se, DataPartition *dp);
9858void writeMVD_CABAC(SyntaxElement *se, DataPartition *dp);
9859void writeCBP_CABAC(SyntaxElement *se, DataPartition *dp);
9860void writeDquant_CABAC(SyntaxElement *se, DataPartition *dp);
9861void writeRunLevel_CABAC(SyntaxElement *se, DataPartition *dp);
9862void writeCIPredMode_CABAC(SyntaxElement *se, DataPartition *dp);
9863void print_ctx_TextureInfo(TextureInfoContexts *enco_ctx);
9864void writeMB_skip_flagInfo_CABAC(SyntaxElement *se, DataPartition *dp);
9865void writeFieldModeInfo_CABAC(SyntaxElement *se, DataPartition *dp); //GB
9866void writeCBP_BIT_CABAC (int b8, int bit, int cbp, Macroblock* currMB, int inter, EncodingEnvironmentPtr eep_dp);
9867void cabac_new_slice(void);
9868void CheckAvailabilityOfNeighborsCABAC(void);
9869
9870void writeMB_transform_size_CABAC(SyntaxElement *se, DataPartition *dp);
9871
9872
9873#endif // CABAC_H
9874# 62 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/cabac.h"
9875
9876# 36 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
9877#if 0 /* expanded by -frewrite-includes */
9878#include "vlc.h"
9879#endif /* expanded by -frewrite-includes */
9880# 36 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
9881# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/vlc.h" 1
9882
9883/*!
9884 *************************************************************************************
9885 * \file vlc.h
9886 *
9887 * \brief
9888 * Prototypes for VLC coding funtions
9889 * \author
9890 * Karsten Suehring
9891 *************************************************************************************
9892 */
9893
9894#ifndef _VLC_H_
9895#define _VLC_H_
9896
9897Boolean u_1 (char *tracestring, int value, Bitstream *bitstream);
9898int se_v (char *tracestring, int value, Bitstream *bitstream);
9899int ue_v (char *tracestring, int value, Bitstream *bitstream);
9900int u_v (int n, char *tracestring, int value, Bitstream *bitstream);
9901
9902
9903void levrun_linfo_c2x2(int level,int run,int *len,int *info);
9904void levrun_linfo_inter(int level,int run,int *len,int *info);
9905
9906void writeSE_UVLC (SyntaxElement *se, DataPartition *dp);
9907void writeSE_SVLC (SyntaxElement *se, DataPartition *dp);
9908void writeSE_Fix (SyntaxElement *se, DataPartition *dp);
9909void writeSE_Flag (SyntaxElement *se, DataPartition *dp);
9910void writeSE_invFlag(SyntaxElement *se, DataPartition *dp);
9911void writeSE_Dummy (SyntaxElement *se, DataPartition *dp);
9912
9913void writeCBP_VLC (SyntaxElement *se, DataPartition *dp);
9914void writeIntraPredMode_CAVLC(SyntaxElement *se, DataPartition *dp);
9915
9916int writeSyntaxElement2Buf_UVLC(SyntaxElement *se, Bitstream* this_streamBuffer );
9917void writeUVLC2buffer(SyntaxElement *se, Bitstream *currStream);
9918int writeSyntaxElement2Buf_Fixed(SyntaxElement *se, Bitstream* this_streamBuffer );
9919int symbol2uvlc(SyntaxElement *se);
9920void ue_linfo(int n, int dummy, int *len,int *info);
9921void se_linfo(int mvd, int dummy, int *len,int *info);
9922void cbp_linfo_intra(int cbp, int dummy, int *len,int *info);
9923void cbp_linfo_inter(int cbp, int dummy, int *len,int *info);
9924
9925// CAVLC
9926void CAVLC_init(void);
9927
9928int writeSyntaxElement_VLC(SyntaxElement *se, DataPartition *this_dataPart);
9929int writeSyntaxElement_TotalZeros(SyntaxElement *se, DataPartition *this_dataPart);
9930int writeSyntaxElement_TotalZerosChromaDC(SyntaxElement *se, DataPartition *this_dataPart);
9931int writeSyntaxElement_Run(SyntaxElement *se, DataPartition *this_dataPart);
9932int writeSyntaxElement_NumCoeffTrailingOnes(SyntaxElement *se, DataPartition *this_dataPart);
9933int writeSyntaxElement_NumCoeffTrailingOnesChromaDC(SyntaxElement *se, DataPartition *this_dataPart);
9934int writeSyntaxElement_Level_VLC1(SyntaxElement *se, DataPartition *this_dataPart, int profile_idc);
9935int writeSyntaxElement_Level_VLCN(SyntaxElement *se, int vlc, DataPartition *this_dataPart, int profile_idc);
9936
9937#endif
9938# 57 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/vlc.h"
9939
9940# 37 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
9941#if 0 /* expanded by -frewrite-includes */
9942#include "me_umhex.h"
9943#endif /* expanded by -frewrite-includes */
9944# 37 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
9945# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/me_umhex.h" 1
9946
9947/*!
9948 ************************************************************************
9949 *
9950 * \file me_umhex.h
9951 *
9952 * \brief
9953 * Macro definitions and global variables for UMHEX fast
9954 * integer pel motion estimation and fractional pel motion estimation
9955 *
9956 * \author
9957 * Main contributors: (see contributors.h for copyright, address and affiliation details)
9958 * - Zhibo Chen <chenzhibo@tsinghua.org.cn>
9959 * - JianFeng Xu <fenax@video.mdc.tsinghua.edu.cn>
9960 * - Wenfang Fu <fwf@video.mdc.tsinghua.edu.cn>
9961 * - Xiaozhong Xu <xxz@video.mdc.tsinghua.edu.cn>
9962 *
9963 * \date
9964 * 2006.1
9965 ************************************************************************
9966 */
9967
9968#ifndef _ME_UMHEX_H_
9969#define _ME_UMHEX_H_
9970
9971#if 0 /* expanded by -frewrite-includes */
9972#include "mbuffer.h"
9973#endif /* expanded by -frewrite-includes */
9974# 26 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/me_umhex.h"
9975# 27 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/me_umhex.h"
9976
9977#define EARLY_TERMINATION \
9978 if ((min_mcost-pred_SAD)<pred_SAD*betaFourth_2) \
9979 goto fourth_2_step; \
9980 else if((min_mcost-pred_SAD)<pred_SAD*betaFourth_1) \
9981 goto fourth_1_step;
9982
9983#define SEARCH_ONE_PIXEL \
9984 if(iabs(cand_x - center_x) <=search_range && iabs(cand_y - center_y)<= search_range)\
9985 { \
9986 if(!McostState[cand_y-center_y+search_range][cand_x-center_x+search_range]) \
9987 { \
9988 mcost = MV_COST (lambda_factor, mvshift, cand_x, cand_y, pred_x, pred_y); \
9989 if(mcost<min_mcost) \
9990 { \
9991 mcost += computeUniPred[dist_method](orig_pic, \
9992 blocksize_y,blocksize_x, min_mcost - mcost, \
9993 (cand_x << 2) + IMG_PAD_SIZE_TIMES4, (cand_y << 2) + IMG_PAD_SIZE_TIMES4); \
9994 McostState[cand_y-center_y+search_range][cand_x-center_x+search_range] = 1; \
9995 if (mcost < min_mcost) \
9996 { \
9997 best_x = cand_x; \
9998 best_y = cand_y; \
9999 min_mcost = mcost; \
10000 } \
10001 } \
10002 } \
10003 }
10004
10005#define SEARCH_ONE_PIXEL_BIPRED \
10006if(iabs(cand_x - center2_x) <=search_range && iabs(cand_y - center2_y)<= search_range)\
10007{ \
10008 if(!McostState[cand_y-center2_y+search_range][cand_x-center2_x+search_range]) \
10009 { \
10010 mcost = MV_COST (lambda_factor, mvshift, center1_x, center1_y, pred_x1, pred_y1);\
10011 mcost += MV_COST (lambda_factor, mvshift, cand_x, cand_y, pred_x2, pred_y2); \
10012 if(mcost<min_mcost) \
10013 { \
10014 mcost += computeBiPred(cur_pic, blocksize_y, blocksize_x, \
10015 min_mcost - mcost, \
10016 (center1_x << 2) + IMG_PAD_SIZE_TIMES4, \
10017 (center1_y << 2) + IMG_PAD_SIZE_TIMES4, \
10018 (cand_x << 2) + IMG_PAD_SIZE_TIMES4, \
10019 (cand_y << 2) + IMG_PAD_SIZE_TIMES4); \
10020 McostState[cand_y-center2_y+search_range][cand_x-center2_x+search_range] = 1; \
10021 if (mcost < min_mcost) \
10022 { \
10023 best_x = cand_x; \
10024 best_y = cand_y; \
10025 min_mcost = mcost; \
10026 } \
10027 } \
10028 } \
10029}
10030
10031byte **McostState; //!< state for integer pel search
10032byte **SearchState; //!< state for fractional pel search
10033
10034int ****fastme_ref_cost; //!< store SAD information needed for forward ref-frame prediction
10035int ***fastme_l0_cost; //!< store SAD information needed for forward median and uplayer prediction
10036int ***fastme_l1_cost; //!< store SAD information needed for backward median and uplayer prediction
10037int ***fastme_l0_cost_bipred; //!< store SAD information for bipred mode
10038int ***fastme_l1_cost_bipred; //!< store SAD information for bipred mode
10039int bipred_flag; //!< flag for bipred
10040int **fastme_best_cost; //!< for multi ref early termination threshold
10041int pred_SAD; //!< SAD prediction in use.
10042int pred_MV_ref[2], pred_MV_uplayer[2]; //!< pred motion vector by space or temporal correlation,Median is provided
10043
10044int UMHEX_blocktype; //!< blocktype for UMHEX SetMotionVectorPredictor
10045int predict_point[5][2];
10046int SAD_a,SAD_b,SAD_c,SAD_d;
10047int Threshold_DSR_MB[8]; //!< Threshold for usage of DSR. DSR refer to JVT-Q088
10048//for early termination
10049float Bsize[8];
10050float AlphaFourth_1[8];
10051float AlphaFourth_2[8];
10052byte *flag_intra;
10053int flag_intra_SAD;
10054
10055void UMHEX_DefineThreshold(void);
10056void UMHEX_DefineThresholdMB(void);
10057int UMHEX_get_mem(void);
10058void UMHEX_free_mem(void);
10059
10060void UMHEX_decide_intrabk_SAD(void);
10061void UMHEX_skip_intrabk_SAD(int best_mode, int ref_max);
10062void UMHEX_setup(short ref, int list, int block_y, int block_x, int blocktype, short ******all_mv);
10063
10064int // ==> minimum motion cost after search
10065UMHEXIntegerPelBlockMotionSearch (
10066 imgpel *orig_pic, // <-- not used
10067 short ref, // <-- reference frame (0... or -1 (backward))
10068 int list, // <-- reference picture list
10069 int pic_pix_x, // <-- absolute x-coordinate of regarded AxB block
10070 int pic_pix_y, // <-- absolute y-coordinate of regarded AxB block
10071 int blocktype, // <-- block type (1-16x16 ... 7-4x4)
10072 short pred_mv_x, // <-- motion vector predictor (x) in sub-pel units
10073 short pred_mv_y, // <-- motion vector predictor (y) in sub-pel units
10074 short* mv_x, // --> motion vector (x) - in pel units
10075 short* mv_y, // --> motion vector (y) - in pel units
10076 int search_range, // <-- 1-d search range in pel units
10077 int min_mcost, // <-- minimum motion cost (cost for center or huge value)
10078 int lambda_factor);// <-- lagrangian parameter for determining motion cost
10079
10080int // ==> minimum motion cost after search
10081UMHEXSubPelBlockMotionSearch (
10082 imgpel* orig_pic, // <-- original pixel values for the AxB block
10083 short ref, // <-- reference frame (0... or -1 (backward))
10084 int list, // <-- reference picture list
10085 int pic_pix_x, // <-- absolute x-coordinate of regarded AxB block
10086 int pic_pix_y, // <-- absolute y-coordinate of regarded AxB block
10087 int blocktype, // <-- block type (1-16x16 ... 7-4x4)
10088 short pred_mv_x, // <-- motion vector predictor (x) in sub-pel units
10089 short pred_mv_y, // <-- motion vector predictor (y) in sub-pel units
10090 short* mv_x, // <--> in: search center (x) / out: motion vector (x) - in pel units
10091 short* mv_y, // <--> in: search center (y) / out: motion vector (y) - in pel units
10092 int search_pos2, // <-- search positions for half-pel search (default: 9)
10093 int search_pos4, // <-- search positions for quarter-pel search (default: 9)
10094 int min_mcost, // <-- minimum motion cost (cost for center or huge value)
10095 int lambda_factor);// <-- lagrangian parameter for determining motion cost
10096
10097
10098extern int // ==> minimum motion cost after search
10099SubPelBlockMotionSearch (imgpel* orig_pic, // <-- original pixel values for the AxB block
10100 short ref, // <-- reference frame (0... or -1 (backward))
10101 int list,
10102 int pic_pix_x, // <-- absolute x-coordinate of regarded AxB block
10103 int pic_pix_y, // <-- absolute y-coordinate of regarded AxB block
10104 int blocktype, // <-- block type (1-16x16 ... 7-4x4)
10105 short pred_mv_x, // <-- motion vector predictor (x) in sub-pel units
10106 short pred_mv_y, // <-- motion vector predictor (y) in sub-pel units
10107 short* mv_x, // <--> in: search center (x) / out: motion vector (x) - in pel units
10108 short* mv_y, // <--> in: search center (y) / out: motion vector (y) - in pel units
10109 int search_pos2, // <-- search positions for half-pel search (default: 9)
10110 int search_pos4, // <-- search positions for quarter-pel search (default: 9)
10111 int min_mcost, // <-- minimum motion cost (cost for center or huge value)
10112 int *lambda_factor // <-- lagrangian parameter for determining motion cost
10113 );
10114
10115int // ==> minimum motion cost after search
10116UMHEXBipredIntegerPelBlockMotionSearch (
10117 imgpel* orig_pic, // <-- original pixel values for the AxB block
10118 short ref, // <-- reference frame (0... or -1 (backward))
10119 int list,
10120 int pic_pix_x, // <-- absolute x-coordinate of regarded AxB block
10121 int pic_pix_y, // <-- absolute y-coordinate of regarded AxB block
10122 int blocktype, // <-- block type (1-16x16 ... 7-4x4)
10123 short pred_mv_x1, // <-- motion vector predictor (x) in sub-pel units
10124 short pred_mv_y1, // <-- motion vector predictor (y) in sub-pel units
10125 short pred_mv_x2, // <-- motion vector predictor (x) in sub-pel units
10126 short pred_mv_y2, // <-- motion vector predictor (y) in sub-pel units
10127 short* mv_x, // <--> in: search center (x) / out: motion vector (x) - in pel units
10128 short* mv_y, // <--> in: search center (y) / out: motion vector (y) - in pel units
10129 short* s_mv_x, // <--> in: search center (x) / out: motion vector (x) - in pel units
10130 short* s_mv_y, // <--> in: search center (y) / out: motion vector (y) - in pel units
10131 int search_range, // <-- 1-d search range in pel units
10132 int min_mcost, // <-- minimum motion cost (cost for center or huge value)
10133 int lambda_factor // <-- lagrangian parameter for determining motion cost
10134 );
10135
10136void UMHEXSetMotionVectorPredictor (short pmv[2], signed char **refPic, short ***tmp_mv,
10137 short ref_frame, int list, int block_x, int block_y,
10138 int blockshape_x, int blockshape_y, int *search_range);
10139
10140#endif
10141# 192 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/me_umhex.h"
10142# 38 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
10143#if 0 /* expanded by -frewrite-includes */
10144#include "ratectl.h" // head file for rate control
10145#endif /* expanded by -frewrite-includes */
10146# 38 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
10147# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/ratectl.h" 1
10148
10149/*!
10150 ***************************************************************************
10151 * \file
10152 * ratectl.h
10153 *
10154 * \author
10155 * Zhengguo LI
10156 *
10157 * \date
10158 * 14 Jan 2003
10159 *
10160 * \brief
10161 * Headerfile for rate control
10162 **************************************************************************
10163 */
10164
10165#ifndef _RATE_CTL_H_
10166#define _RATE_CTL_H_
10167
10168/* generic rate control variables */
10169typedef struct {
10170 // RC flags
10171 int TopFieldFlag;
10172 int FieldControl;
10173 int FieldFrame;
10174 int NoGranularFieldRC;
10175 // bits stats
10176 int NumberofHeaderBits;
10177 int NumberofTextureBits;
10178 int NumberofBasicUnitHeaderBits;
10179 int NumberofBasicUnitTextureBits;
10180 // frame stats
10181 int NumberofCodedBFrame;
10182 int NumberofCodedPFrame;
10183 int NumberofGOP;
10184 int TotalQpforPPicture;
10185 int NumberofPPicture;
10186 // MAD stats
10187 int64 TotalMADBasicUnit;
10188 int *MADofMB;
10189 // buffer and budget
10190 int64 CurrentBufferFullness; //LIZG 25/10/2002
10191 int RemainingBits;
10192 // bit allocations for RC_MODE_3
10193 int RCPSliceBits;
10194 int RCISliceBits;
10195 int RCBSliceBits[RC_MAX_TEMPORAL_LEVELS];
10196 int temporal_levels;
10197 int hierNb[RC_MAX_TEMPORAL_LEVELS];
10198 int NPslice;
10199 int NIslice;
10200} rc_generic;
10201
10202// macroblock activity
10203int diffy[16][16];
10204int qp_mbaff[2][2], qp_mbaff[2][2];
10205int delta_qp_mbaff[2][2], delta_qp_mbaff[2][2];
10206
10207// generic functions
10208int Qstep2QP( double Qstep );
10209double QP2Qstep( int QP );
10210int calc_MAD( void );
10211double ComputeFrameMAD( void );
10212void update_rc(Macroblock *currMB, short best_mode);
10213
10214// rate control functions
10215// init/copy
10216void generic_alloc( rc_generic **prc );
10217void generic_free( rc_generic **prc );
10218void copy_rc_generic( rc_generic *dst, rc_generic *src );
10219
10220// rate control CURRENT pointers
10221rc_generic *generic_RC;
10222// rate control object pointers for RDPictureDecision buffering...
10223rc_generic *generic_RC_init, *generic_RC_best;
10224
10225
10226#endif
10227# 80 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/ratectl.h"
10228
10229# 39 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
10230#if 0 /* expanded by -frewrite-includes */
10231#include "mode_decision.h"
10232#endif /* expanded by -frewrite-includes */
10233# 39 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
10234# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/mode_decision.h" 1
10235/*!
10236 ***************************************************************************
10237 * \file
10238 * mode_decision.h
10239 *
10240 * \author
10241 * Alexis Michael Tourapis
10242 *
10243 * \date
10244 * 21. February 2005
10245 *
10246 * \brief
10247 * Headerfile for mode decision
10248 **************************************************************************
10249 */
10250
10251#ifndef _MODE_DECISION_H_
10252#define _MODE_DECISION_H_
10253
10254extern CSptr cs_mb, cs_b8, cs_cm, cs_imb, cs_ib8, cs_ib4, cs_pc;
10255//extern imgpel mpr_8x8ts[16][16];
10256//extern imgpel rec_mbY[16][16], rec_mbU[16][16], rec_mbV[16][16]; // reconstruction values
10257extern RD_8x8DATA tr4x4, tr8x8;
10258
10259// Adaptive Lagrangian variables
10260extern double mb16x16_cost;
10261extern double lambda_mf_factor;
10262
10263extern const int LEVELMVLIMIT[17][6];
10264extern int ****cofAC_8x8ts; // [8x8block][4x4block][level/run][scan_pos]
10265extern int ****cofAC, ****cofAC8x8; // [8x8block][4x4block][level/run][scan_pos]
10266extern int QP2QUANT[40];
10267extern int cbp_blk8x8;
10268extern int cbp, cbp8x8, cnt_nonz_8x8;
10269extern int64 cbp_blk;
10270extern int64 cbp_blk8_8x8ts;
10271extern int cbp8_8x8ts;
10272extern int cnt_nonz8_8x8ts;
10273extern int qp_mbaff[2][2], qp_mbaff[2][2];
10274extern int delta_qp_mbaff[2][2],delta_qp_mbaff[2][2];
10275
10276// Residue Color Transform
10277extern signed char b4_ipredmode[16], b4_intra_pred_modes[16];
10278
10279extern short bi_pred_me;
10280extern short best_mode;
10281extern short best8x8mode [4]; // [block]
10282extern signed char best8x8pdir [MAXMODE][4]; // [mode][block]
10283extern signed char best8x8fwref[MAXMODE][4]; // [mode][block]
10284extern signed char best8x8bwref[MAXMODE][4]; // [mode][block]
10285extern imgpel pred[16][16];
10286
10287extern void set_stored_macroblock_parameters (void);
10288extern void StoreMV8x8(int);
10289extern void RestoreMV8x8(int);
10290extern void store_macroblock_parameters (int);
10291extern void SetModesAndRefframeForBlocks (int);
10292extern void SetRefAndMotionVectors (int, int, int, int, int);
10293extern void StoreNewMotionVectorsBlock8x8(int, int, int, int, int, int, int);
10294extern void assign_enc_picture_params(int, signed char, int, int, int, int, int);
10295extern void update_refresh_map(int intra, int intra1, Macroblock *currMB);
10296extern void SetMotionVectorsMB (Macroblock*, int);
10297extern void SetCoeffAndReconstruction8x8 (Macroblock*);
10298extern void fast_mode_intra_decision(short *intra_skip, double min_rate);
10299
10300extern int GetBestTransformP8x8(void);
10301extern int I16Offset (int, int);
10302extern int CheckReliabilityOfRef (int, int, int, int);
10303extern int Mode_Decision_for_Intra4x4Macroblock (double, int*);
10304extern int RDCost_for_macroblocks (double, int, double*, double*, int);
10305extern double RDCost_for_8x8blocks (int*, int64*, double, int, int, short, short, short);
10306extern double *mb16x16_cost_frame;
10307
10308extern const int b8_mode_table[6];
10309extern const int mb_mode_table[9];
10310
10311void rc_store_diff(int cpix_x, int cpix_y, imgpel prediction[16][16]);
10312void submacroblock_mode_decision(RD_PARAMS, RD_8x8DATA *, Macroblock *,int ***, int *, short, int, int *, int *, int *, int);
10313void init_enc_mb_params(Macroblock* currMB, RD_PARAMS *enc_mb, int intra, int bslice);
10314void list_prediction_cost(int list, int block, int mode, RD_PARAMS enc_mb, int bmcost[5], signed char best_ref[2]);
10315void determine_prediction_list(int, int [5], signed char [2], signed char *, int *, short *);
10316void compute_mode_RD_cost(int mode, Macroblock *currMB, RD_PARAMS enc_mb,
10317 double *min_rdcost, double *min_rate,
10318 int i16mode, short bslice, short *inter_skip);
10319
10320
10321void get_initial_mb16x16_cost(void);
10322void adjust_mb16x16_cost(int);
10323
10324#endif
10325# 91 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/mode_decision.h"
10326
10327# 40 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
10328#if 0 /* expanded by -frewrite-includes */
10329#include "fmo.h"
10330#endif /* expanded by -frewrite-includes */
10331# 40 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
10332# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/fmo.h" 1
10333
10334/*!
10335 ***************************************************************************
10336 *
10337 * \file fmo.h
10338 *
10339 * \brief
10340 * Support for Flexible Macroblock Ordering
10341 *
10342 * \date
10343 * 16 June 2002
10344 *
10345 * \author
10346 * Stephan Wenger stewe@cs.tu-berlin.de
10347 **************************************************************************/
10348
10349#ifndef _FMO_H_
10350#define _FMO_H_
10351
10352#define MAXSLICEGROUPIDS 8
10353
10354int FmoInit(ImageParameters * img, pic_parameter_set_rbsp_t * pps, seq_parameter_set_rbsp_t * sps);
10355void FmoUninit (void);
10356int FmoFinit (seq_parameter_set_rbsp_t * sps);
10357int FmoMB2SliceGroup (int mb);
10358int FmoGetFirstMBOfSliceGroup (int SliceGroupID);
10359int FmoGetFirstMacroblockInSlice (int SliceGroup);
10360int FmoGetNextMBNr (int CurrentMbNr);
10361int FmoGetLastCodedMBOfSliceGroup (int SliceGroupID);
10362int FmoStartPicture (void);
10363int FmoEndPicture(void);
10364int FmoSliceGroupCompletelyCoded(int SliceGroupID);
10365void FmoSetLastMacroblockInSlice (int mb);
10366
10367int FmoGetPreviousMBNr (int CurrentMbNr);
10368
10369extern byte *MBAmap;
10370
10371#endif
10372# 40 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/fmo.h"
10373# 41 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
10374#if 0 /* expanded by -frewrite-includes */
10375#include "macroblock.h"
10376#endif /* expanded by -frewrite-includes */
10377# 41 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
10378# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/macroblock.h" 1
10379
10380/*!
10381 ************************************************************************
10382 * \file
10383 * macroblock.h
10384 *
10385 * \brief
10386 * Arrays for macroblock processing
10387 *
10388 * \author
10389 * Inge Lille-Langoy <inge.lille-langoy@telenor.com> \n
10390 * Telenor Satellite Services \n
10391 * P.O.Box 6914 St.Olavs plass \n
10392 * N-0130 Oslo, Norway
10393 *
10394 ************************************************************************/
10395
10396#ifndef _MACROBLOCK_H_
10397#define _MACROBLOCK_H_
10398
10399void proceed2nextMacroblock(void);
10400
10401void start_macroblock(int mb_addr, int mb_field);
10402void terminate_macroblock(Boolean *end_of_slice, Boolean *recode_macroblock);
10403
10404void write_one_macroblock(int eos_bit);
10405
10406void LumaPrediction4x4 (int, int, int, int, int, short, short);
10407void LumaPrediction4x4Bi (int, int, int, int, short, short, int );
10408
10409int LumaResidualCoding8x8 (int*, int64*, int, short, int, int, short, short);
10410void LumaResidualCoding (void);
10411
10412void ChromaResidualCoding (int*);
10413
10414void IntraChromaPrediction (int*, int*, int*);
10415void IntraChromaRDDecision (RD_PARAMS);
10416
10417int TransformDecision(int, int*);
10418
10419int B8Mode2Value (int b8mode, int b8pdir);
10420
10421int writeMBLayer (int rdopt, int *coeff_rate);
10422void write_terminating_bit (short bit);
10423
10424int writeReferenceFrame (int mode, int i, int j, int fwd_flag, int ref);
10425int writeMotionVector8x8 (int i0, int j0, int i1, int j1, int refframe, int list_idx, int mv_mode);
10426
10427int writeLumaCoeff4x4_CABAC (int, int, int);
10428int writeLumaCoeff8x8_CABAC (int, int);
10429int writeLumaCoeff8x8 (int, int, int);
10430
10431int writeCoeff4x4_CAVLC (int block_type, int b8, int b4, int param);
10432
10433int find_sad_16x16 (int *intra_mode);
10434
10435#endif
10436# 58 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/macroblock.h"
10437
10438# 42 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
10439#if 0 /* expanded by -frewrite-includes */
10440#include "symbol.h"
10441#endif /* expanded by -frewrite-includes */
10442# 42 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
10443# 1 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/symbol.h" 1
10444
10445/*!
10446***************************************************************************
10447*
10448* \file symbol.h
10449*
10450* \brief
10451* Generic Symbol writing interface
10452*
10453* \date
10454* 18 Jan 2006
10455*
10456* \author
10457* Karsten Suehring suehring@hhi.de
10458**************************************************************************/
10459
10460extern void (*writeMB_typeInfo) (SyntaxElement *se, DataPartition *dP);
10461extern void (*writeIntraPredMode) (SyntaxElement *se, DataPartition *dP);
10462extern void (*writeB8_typeInfo) (SyntaxElement *se, DataPartition *dP);
10463extern void (*writeRefFrame[6]) (SyntaxElement *se, DataPartition *dP);
10464extern void (*writeMVD) (SyntaxElement *se, DataPartition *dP);
10465extern void (*writeCBP) (SyntaxElement *se, DataPartition *dP);
10466extern void (*writeDquant) (SyntaxElement *se, DataPartition *dP);
10467extern void (*writeCIPredMode) (SyntaxElement *se, DataPartition *dP);
10468extern void (*writeFieldModeInfo) (SyntaxElement *se, DataPartition *dP);
10469extern void (*writeMB_transform_size)(SyntaxElement *se, DataPartition *dP);
10470# 43 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c" 2
10471
10472
10473imgpel pred[16][16];
10474
10475#define FASTMODE 1
10476//#define RESET_STATE
10477
10478extern const int LEVELMVLIMIT[17][6];
10479extern int QP2QUANT[40];
10480
10481const int AdaptRndCrPos[2][5] =
10482{
10483 // P, B, I, SP, SI
10484 { 4, 7, 1, 4, 1}, // Intra MB
10485 { 10, 13, 10, 10, 10} // Inter MB
10486};
10487
10488const int AdaptRndPos[4][5] =
10489{
10490 // P, B, I, SP, SI
10491 { 3, 6, 0, 3, 0}, // 4x4 Intra MB
10492 { 1, 2, 0, 1, 2}, // 8x8 Intra MB
10493 { 9, 12, 9, 9, 9}, // 4x4 Inter MB
10494 { 3, 4, 3, 3, 3}, // 8x8 Inter MB
10495};
10496
10497imgpel rec_mbY[16][16], rec_mbU[16][16], rec_mbV[16][16]; // reconstruction values
10498
10499int lrec_rec[16][16],lrec_rec_U[16][16],lrec_rec_V[16][16]; // store the transf. and quantized coefficients for SP frames
10500
10501static int diff[16];
10502static int diff4x4[64];
10503static int diff8x8[64];
10504RD_8x8DATA tr4x4, tr8x8;
10505
10506int **bestInterFAdjust4x4=NULL, **bestIntraFAdjust4x4=NULL;
10507int **bestInterFAdjust8x8=NULL, **bestIntraFAdjust8x8=NULL;
10508int ***bestInterFAdjust4x4Cr=NULL, ***bestIntraFAdjust4x4Cr=NULL;
10509int **fadjust8x8=NULL, **fadjust4x4=NULL, ***fadjust4x4Cr=NULL, ***fadjust8x8Cr=NULL;
10510
10511int ****cofAC=NULL, ****cofAC8x8=NULL; // [8x8block][4x4block][level/run][scan_pos]
10512int ***cofDC=NULL; // [yuv][level/run][scan_pos]
10513int **cofAC4x4=NULL, ****cofAC4x4intern=NULL; // [level/run][scan_pos]
10514int cbp, cbp8x8, cnt_nonz_8x8;
10515int64 cbp_blk;
10516int cbp_blk8x8;
10517signed char frefframe[4][4], brefframe[4][4];
10518int b8mode[4], b8pdir[4];
10519short best8x8mode [4]; // [block]
10520signed char best8x8pdir [MAXMODE][4]; // [mode][block]
10521signed char best8x8fwref [MAXMODE][4]; // [mode][block]
10522signed char best8x8bwref [MAXMODE][4]; // [mode][block]
10523
10524
10525CSptr cs_mb=NULL, cs_b8=NULL, cs_cm=NULL, cs_imb=NULL, cs_ib8=NULL, cs_ib4=NULL, cs_pc=NULL;
10526int best_c_imode;
10527int best_i16offset;
10528short best_mode;
10529short bi_pred_me;
10530
10531//mixed transform sizes definitions
10532int luma_transform_size_8x8_flag;
10533
10534short all_mv8x8[2][2][4][4][2]; //[8x8_data/temp_data][LIST][block_x][block_y][MVx/MVy]
10535short pred_mv8x8[2][2][4][4][2];
10536
10537int ****cofAC_8x8ts = NULL; // [8x8block][4x4block][level/run][scan_pos]
10538
10539int64 cbp_blk8_8x8ts;
10540int cbp8_8x8ts;
10541int cost8_8x8ts;
10542int cnt_nonz8_8x8ts;
10543
10544// adaptive langrangian parameters
10545double mb16x16_cost;
10546double lambda_mf_factor;
10547
10548void StoreMV8x8(int dir);
10549void RestoreMV8x8(int dir);
10550// end of mixed transform sizes definitions
10551
10552//Adaptive Rounding update function
10553void update_offset_params(int mode, int luma_transform_size_8x8_flag);
10554
10555signed char b4_ipredmode[16], b4_intra_pred_modes[16];
10556
10557/*!
10558 ************************************************************************
10559 * \brief
10560 * delete structure for RD-optimized mode decision
10561 ************************************************************************
10562 */
10563void clear_rdopt ()
10564{
10565 free_mem_DCcoeff (cofDC);
10566 free_mem_ACcoeff (cofAC);
10567 free_mem_ACcoeff (cofAC8x8);
10568 free_mem_ACcoeff (cofAC4x4intern);
10569
10570 if (input->Transform8x8Mode)
10571 {
10572 free_mem_ACcoeff (cofAC_8x8ts);
10573 }
10574
10575 if (input->AdaptiveRounding)
10576 {
10577 free_mem2Dint(bestInterFAdjust4x4);
10578 free_mem2Dint(bestIntraFAdjust4x4);
10579 free_mem2Dint(bestInterFAdjust8x8);
10580 free_mem2Dint(bestIntraFAdjust8x8);
10581 free_mem3Dint(bestInterFAdjust4x4Cr, 2);
10582 free_mem3Dint(bestIntraFAdjust4x4Cr, 2);
10583 free_mem2Dint(fadjust8x8);
10584 free_mem2Dint(fadjust4x4);
10585 free_mem3Dint(fadjust4x4Cr, 2);
10586 free_mem3Dint(fadjust8x8Cr, 2);
10587 }
10588
10589 // structure for saving the coding state
10590 delete_coding_state (cs_mb);
10591 delete_coding_state (cs_b8);
10592 delete_coding_state (cs_cm);
10593 delete_coding_state (cs_imb);
10594 delete_coding_state (cs_ib8);
10595 delete_coding_state (cs_ib4);
10596 delete_coding_state (cs_pc);
10597}
10598
10599
10600/*!
10601 ************************************************************************
10602 * \brief
10603 * create structure for RD-optimized mode decision
10604 ************************************************************************
10605 */
10606void init_rdopt ()
10607{
10608 rdopt = NULL;
10609
10610 get_mem_DCcoeff (&cofDC);
10611 get_mem_ACcoeff (&cofAC);
10612 get_mem_ACcoeff (&cofAC8x8);
10613 get_mem_ACcoeff (&cofAC4x4intern);
10614 cofAC4x4 = cofAC4x4intern[0][0];
10615
10616 if (input->Transform8x8Mode)
10617 {
10618 get_mem_ACcoeff (&cofAC_8x8ts);
10619 }
10620
10621 switch (input->rdopt)
10622 {
10623 case 0:
10624 encode_one_macroblock = encode_one_macroblock_low;
10625 break;
10626 case 1:
10627 encode_one_macroblock = encode_one_macroblock_high;
10628 break;
10629 case 2:
10630 encode_one_macroblock = encode_one_macroblock_highfast;
10631 break;
10632 case 3:
10633 encode_one_macroblock = encode_one_macroblock_highloss;
10634 break;
10635 default:
10636 encode_one_macroblock = encode_one_macroblock_high;
10637 break;
10638 }
10639 if (input->AdaptiveRounding)
10640 {
10641 get_mem2Dint(&bestInterFAdjust4x4, 16, 16);
10642 get_mem2Dint(&bestIntraFAdjust4x4, 16, 16);
10643 get_mem2Dint(&bestInterFAdjust8x8, 16, 16);
10644 get_mem2Dint(&bestIntraFAdjust8x8, 16, 16);
10645 get_mem3Dint(&bestInterFAdjust4x4Cr, 2, img->mb_cr_size_y, img->mb_cr_size_x);
10646 get_mem3Dint(&bestIntraFAdjust4x4Cr, 2, img->mb_cr_size_y, img->mb_cr_size_x);
10647 get_mem2Dint(&fadjust8x8, 16, 16);
10648 get_mem2Dint(&fadjust4x4, 16, 16);
10649 get_mem3Dint(&fadjust4x4Cr, 2, img->mb_cr_size_y, img->mb_cr_size_x);
10650 get_mem3Dint(&fadjust8x8Cr, 2, img->mb_cr_size_y, img->mb_cr_size_x);
10651 }
10652
10653 // structure for saving the coding state
10654 cs_mb = create_coding_state ();
10655 cs_b8 = create_coding_state ();
10656 cs_cm = create_coding_state ();
10657 cs_imb = create_coding_state ();
10658 cs_ib8 = create_coding_state ();
10659 cs_ib4 = create_coding_state ();
10660 cs_pc = create_coding_state ();
10661
10662 if (input->CtxAdptLagrangeMult == 1)
10663 {
10664 mb16x16_cost = CALM_MF_FACTOR_THRESHOLD;
10665 lambda_mf_factor = 1.0;
10666 }
10667}
10668
10669
10670
10671/*!
10672 *************************************************************************************
10673 * \brief
10674 * Updates the pixel map that shows, which reference frames are reliable for
10675 * each MB-area of the picture.
10676 *
10677 * \note
10678 * The new values of the pixel_map are taken from the temporary buffer refresh_map
10679 *
10680 *************************************************************************************
10681 */
10682void UpdatePixelMap()
10683{
10684 int mx,my,y,x,i,j;
10685 if (img->type==I_SLICE)
10686 {
10687 for (y=0; y<img->height; y++)
10688 for (x=0; x<img->width; x++)
10689 {
10690 pixel_map[y][x]=1;
10691 }
10692 }
10693 else
10694 {
10695 for (my=0; my<img->height >> 3; my++)
10696 for (mx=0; mx<img->width >> 3; mx++)
10697 {
10698 j = my*8 + 8;
10699 i = mx*8 + 8;
10700 if (refresh_map[my][mx])
10701 {
10702 for (y=my*8; y<j; y++)
10703 for (x=mx*8; x<i; x++)
10704 pixel_map[y][x] = 1;
10705 }
10706 else
10707 {
10708 for (y=my*8; y<j; y++)
10709 for (x=mx*8; x<i; x++)
10710 {
10711 pixel_map[y][x] = imin(pixel_map[y][x] + 1, input->num_ref_frames+1);
10712 }
10713 }
10714 }
10715 }
10716}
10717
10718/*!
10719 *************************************************************************************
10720 * \brief
10721 * Checks if a given reference frame is reliable for the current
10722 * macroblock, given the motion vectors that the motion search has
10723 * returned.
10724 *
10725 * \return
10726 * If the return value is 1, the reference frame is reliable. If it
10727 * is 0, then it is not reliable.
10728 *
10729 * \note
10730 * A specific area in each reference frame is assumed to be unreliable
10731 * if the same area has been intra-refreshed in a subsequent frame.
10732 * The information about intra-refreshed areas is kept in the pixel_map.
10733 *
10734 *************************************************************************************
10735 */
10736int CheckReliabilityOfRef (int block, int list_idx, int ref, int mode)
10737{
10738 int y,x, block_y, block_x, dy, dx, y_pos, x_pos, yy, xx, pres_x, pres_y;
10739 int maxold_x = img->width-1;
10740 int maxold_y = img->height-1;
10741 int ref_frame = ref+1;
10742
10743 int by0 = (mode>=4?2*(block >> 1):mode==2?2*block:0);
10744 int by1 = by0 + (mode>=4||mode==2?2:4);
10745 int bx0 = (mode>=4?2*(block & 0x01):mode==3?2*block:0);
10746 int bx1 = bx0 + (mode>=4||mode==3?2:4);
10747
10748 for (block_y=by0; block_y<by1; block_y++)
10749 {
10750 for (block_x=bx0; block_x<bx1; block_x++)
10751 {
10752 y_pos = img->all_mv[block_y][block_x][list_idx][ref][mode][1];
10753 y_pos += (img->block_y + block_y) * BLOCK_SIZE * 4;
10754 x_pos = img->all_mv[block_y][block_x][list_idx][ref][mode][0];
10755 x_pos += (img->block_x + block_x) * BLOCK_SIZE * 4;
10756
10757 /* Here we specify which pixels of the reference frame influence
10758 the reference values and check their reliability. This is
10759 based on the function Get_Reference_Pixel */
10760
10761 dy = y_pos & 3;
10762 dx = x_pos & 3;
10763
10764 y_pos = (y_pos-dy) >> 2;
10765 x_pos = (x_pos-dx) >> 2;
10766
10767 if (dy==0 && dx==0) //full-pel
10768 {
10769 for (y=y_pos ; y < y_pos + BLOCK_SIZE ; y++)
10770 for (x=x_pos ; x < x_pos + BLOCK_SIZE ; x++)
10771 if (pixel_map[iClip3(0,maxold_y,y)][iClip3(0,maxold_x,x)] < ref_frame)
10772 return 0;
10773 }
10774 else /* other positions */
10775 {
10776 if (dy == 0)
10777 {
10778 for (y = y_pos ; y < y_pos + BLOCK_SIZE ; y++)
10779 {
10780 pres_y = iClip3(0,maxold_y,y);
10781 for (x = x_pos ; x < x_pos + BLOCK_SIZE ; x++)
10782 {
10783 for(xx = -2 ; xx < 4 ; xx++) {
10784 pres_x = iClip3(0, maxold_x, x + xx);
10785 if (pixel_map[pres_y][pres_x] < ref_frame)
10786 return 0;
10787 }
10788 }
10789 }
10790 }
10791 else if (dx == 0)
10792 {
10793 for (y = y_pos ; y < y_pos + BLOCK_SIZE ; y++)
10794 for (x=x_pos ; x < x_pos + BLOCK_SIZE ; x++)
10795 {
10796 pres_x = iClip3(0,maxold_x,x);
10797 for(yy=-2;yy<4;yy++) {
10798 pres_y = iClip3(0,maxold_y, yy + y);
10799 if (pixel_map[pres_y][pres_x] < ref_frame)
10800 return 0;
10801 }
10802 }
10803 }
10804 else if (dx == 2)
10805 {
10806 for (y = y_pos ; y < y_pos + BLOCK_SIZE ; y++)
10807 for (x = x_pos ; x < x_pos + BLOCK_SIZE ; x++)
10808 {
10809 for(yy=-2;yy<4;yy++) {
10810 pres_y = iClip3(0,maxold_y, yy + y);
10811 for(xx=-2;xx<4;xx++) {
10812 pres_x = iClip3(0,maxold_x, xx + x);
10813 if (pixel_map[pres_y][pres_x] < ref_frame)
10814 return 0;
10815 }
10816 }
10817 }
10818 }
10819 else if (dy == 2)
10820 {
10821 for (y = y_pos ; y < y_pos + BLOCK_SIZE ; y++)
10822 for (x = x_pos ; x < x_pos + BLOCK_SIZE ; x++)
10823 {
10824 for(xx=-2;xx<4;xx++) {
10825 pres_x = iClip3(0,maxold_x, xx + x);
10826 for(yy=-2;yy<4;yy++) {
10827 pres_y = iClip3(0,maxold_y, yy + y);
10828 if (pixel_map[pres_y][pres_x] < ref_frame)
10829 return 0;
10830 }
10831 }
10832 }
10833 }
10834 else
10835 {
10836 for (y = y_pos ; y < y_pos + BLOCK_SIZE ; y++)
10837 {
10838 for (x = x_pos ; x < x_pos + BLOCK_SIZE ; x++)
10839 {
10840 pres_y = dy == 1 ? y : y + 1;
10841 pres_y = iClip3(0,maxold_y,pres_y);
10842
10843 for(xx=-2;xx<4;xx++)
10844 {
10845 pres_x = iClip3(0,maxold_x,xx + x);
10846 if (pixel_map[pres_y][pres_x] < ref_frame)
10847 return 0;
10848 }
10849
10850 pres_x = dx == 1 ? x : x + 1;
10851 pres_x = iClip3(0,maxold_x,pres_x);
10852
10853 for(yy=-2;yy<4;yy++)
10854 {
10855 pres_y = iClip3(0,maxold_y, yy + y);
10856 if (pixel_map[pres_y][pres_x] < ref_frame)
10857 return 0;
10858 }
10859 }
10860 }
10861 }
10862 }
10863 }
10864 }
10865 return 1;
10866}
10867
10868
10869
10870/*!
10871 *************************************************************************************
10872 * \brief
10873 * R-D Cost for an 4x4 Intra block
10874 *************************************************************************************
10875 */
10876double RDCost_for_4x4IntraBlocks (int* nonzero,
10877 int b8,
10878 int b4,
10879 int ipmode,
10880 double lambda,
10881 double min_rdcost,
10882 int mostProbableMode)
10883{
10884 double rdcost;
10885 int dummy, x, y, rate;
10886 int64 distortion = 0;
10887 int block_x = 8*(b8 & 0x01)+4*(b4 & 0x01);
10888 int block_y = 8*(b8 >> 1)+4*(b4 >> 1);
10889 int pic_pix_x = img->pix_x+block_x;
10890 int pic_pix_y = img->pix_y+block_y;
10891 int pic_opix_y = img->opix_y+block_y;
10892 imgpel **imgY = enc_picture->imgY;
10893
10894 Slice *currSlice = img->currentSlice;
10895 SyntaxElement se;
10896 const int *partMap = assignSE2partition[input->partition_mode];
10897 DataPartition *dataPart;
10898
10899 //===== perform DCT, Q, IQ, IDCT, Reconstruction =====
10900 dummy = 0;
10901
10902 if(img->type!=SP_SLICE)
10903 *nonzero = dct_luma (block_x, block_y, &dummy, 1);
10904 else if(!si_frame_indicator && !sp2_frame_indicator)
10905 {
10906 *nonzero = dct_luma_sp(block_x, block_y, &dummy);
10907 }
10908 else
10909 {
10910 *nonzero = dct_luma_sp2(block_x, block_y, &dummy);
10911 }
10912
10913 //===== get distortion (SSD) of 4x4 block =====
10914 for (y=0; y<4; y++)
10915 {
10916 for (x=pic_pix_x; x<pic_pix_x+4; x++)
10917 {
10918 distortion += img->quad [imgY_org[pic_opix_y+y][x] - imgY[pic_pix_y+y][x]];
10919 }
10920 }
10921
10922 //===== RATE for INTRA PREDICTION MODE (SYMBOL MODE MUST BE SET TO UVLC) =====
10923 se.value1 = (mostProbableMode == ipmode) ? -1 : ipmode < mostProbableMode ? ipmode : ipmode-1;
10924
10925 //--- set position and type ---
10926 se.context = 4*b8 + b4;
10927 se.type = SE_INTRAPREDMODE;
10928
10929 //--- choose data partition ---
10930 dataPart = &(currSlice->partArr[partMap[SE_INTRAPREDMODE]]);
10931 //--- encode and update rate ---
10932 writeIntraPredMode (&se, dataPart);
10933 rate = se.len;
10934
10935 //===== RATE for LUMINANCE COEFFICIENTS =====
10936 if (input->symbol_mode == UVLC)
10937 {
10938 rate += writeCoeff4x4_CAVLC (LUMA, b8, b4, 0);
10939 }
10940 else
10941 {
10942 rate += writeLumaCoeff4x4_CABAC (b8, b4, 1);
10943 }
10944 //reset_coding_state (cs_cm);
10945 rdcost = (double)distortion + lambda*(double)rate;
10946
10947 return rdcost;
10948}
10949
10950
10951/*!
10952 *************************************************************************************
10953 * \brief
10954 * Mode Decision for an 4x4 Intra block
10955 *************************************************************************************
10956 */
10957int Mode_Decision_for_4x4IntraBlocks (int b8, int b4, double lambda, int* min_cost)
10958{
10959 int ipmode, best_ipmode = 0, i, j, k, y, cost, dummy;
10960 int c_nz, nonzero = 0;
10961 imgpel rec4x4[4][4];
10962 double rdcost;
10963 int block_x = 8 * (b8 & 0x01) + 4 * (b4 & 0x01);
10964 int block_y = 8 * (b8 >> 1) + 4 * (b4 >> 1);
10965 int pic_pix_x = img->pix_x + block_x;
10966 int pic_pix_y = img->pix_y + block_y;
10967 int pic_opix_x = img->opix_x + block_x;
10968 int pic_opix_y = img->opix_y + block_y;
10969 int pic_block_x = pic_pix_x >> 2;
10970 int pic_block_y = pic_pix_y >> 2;
10971 double min_rdcost = 1e30;
10972
10973 int left_available, up_available, all_available;
10974
10975 signed char upMode;
10976 signed char leftMode;
10977 int mostProbableMode;
10978
10979 PixelPos left_block;
10980 PixelPos top_block;
10981
10982 int lrec4x4[4][4];
10983 int fixedcost = (int) floor(4 * lambda );
10984
10985#ifdef BEST_NZ_COEFF
10986 int best_nz_coeff = 0;
10987 int best_coded_block_flag = 0;
10988 int bit_pos = 1 + ((((b8>>1)<<1)+(b4>>1))<<2) + (((b8&1)<<1)+(b4&1));
10989 static int64 cbp_bits;
10990
10991 if (b8==0 && b4==0)
10992 cbp_bits = 0;
10993#endif
10994# 566 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
10995
10996 getLuma4x4Neighbour(img->current_mb_nr, block_x - 1, block_y, &left_block);
10997 getLuma4x4Neighbour(img->current_mb_nr, block_x, block_y-1, &top_block);
10998
10999 // constrained intra pred
11000 if (input->UseConstrainedIntraPred)
11001 {
11002 left_block.available = left_block.available ? img->intra_block[left_block.mb_addr] : 0;
11003 top_block.available = top_block.available ? img->intra_block[top_block.mb_addr] : 0;
11004 }
11005
11006 upMode = top_block.available ? img->ipredmode[top_block.pos_y ][top_block.pos_x ] : -1;
11007 leftMode = left_block.available ? img->ipredmode[left_block.pos_y][left_block.pos_x] : -1;
11008
11009 mostProbableMode = (upMode < 0 || leftMode < 0) ? DC_PRED : upMode < leftMode ? upMode : leftMode;
11010
11011 *min_cost = INT_MAX;
11012
11013 //===== INTRA PREDICTION FOR 4x4 BLOCK =====
11014 intrapred_luma (pic_pix_x, pic_pix_y, &left_available, &up_available, &all_available);
11015
11016 //===== LOOP OVER ALL 4x4 INTRA PREDICTION MODES =====
11017 for (ipmode=0; ipmode<NO_INTRA_PMODE; ipmode++)
11018 {
11019 int available_mode = (ipmode==DC_PRED) ||
11020 ((ipmode==VERT_PRED||ipmode==VERT_LEFT_PRED||ipmode==DIAG_DOWN_LEFT_PRED) && up_available ) ||
11021 ((ipmode==HOR_PRED||ipmode==HOR_UP_PRED) && left_available ) ||(all_available);
11022
11023 if (input->IntraDisableInterOnly==0 || img->type != I_SLICE)
11024 {
11025 if (input->Intra4x4ParDisable && (ipmode==VERT_PRED||ipmode==HOR_PRED))
11026 continue;
11027
11028 if (input->Intra4x4DiagDisable && (ipmode==DIAG_DOWN_LEFT_PRED||ipmode==DIAG_DOWN_RIGHT_PRED))
11029 continue;
11030
11031 if (input->Intra4x4DirDisable && ipmode>=VERT_RIGHT_PRED)
11032 continue;
11033 }
11034
11035 if( available_mode)
11036 {
11037 if (!input->rdopt)
11038 {
11039 for (k=j=0; j<4; j++)
11040 {
11041 int jj = pic_opix_y+j;
11042 for (i=0; i<4; i++, k++)
11043 {
11044 diff[k] = imgY_org[jj][pic_opix_x+i] - img->mprr[ipmode][j][i];
11045 }
11046 }
11047 cost = (ipmode == mostProbableMode) ? 0 : fixedcost;
11048 cost += distortion4x4 (diff);
11049 if (cost < *min_cost)
11050 {
11051 best_ipmode = ipmode;
11052 *min_cost = cost;
11053 }
11054 }
11055 else
11056 {
11057 // get prediction and prediction error
11058 for (j=0; j<4; j++)
11059 {
11060 memcpy(&img->mpr[block_y+j][block_x], img->mprr[ipmode][j], BLOCK_SIZE * sizeof(imgpel));
11061 for (i=0; i<4; i++)
11062 {
11063 img->m7[j][i] = (int) (imgY_org[pic_opix_y+j][pic_opix_x+i] - img->mprr[ipmode][j][i]);
11064 }
11065 }
11066
11067 //===== store the coding state =====
11068 //store_coding_state (cs_cm);
11069 // get and check rate-distortion cost
11070#ifdef BEST_NZ_COEFF
11071 img->mb_data[img->current_mb_nr].cbp_bits = cbp_bits;
11072#endif
11073# 644 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
11074 if ((rdcost = RDCost_for_4x4IntraBlocks (&c_nz, b8, b4, ipmode, lambda, min_rdcost, mostProbableMode)) < min_rdcost)
11075 {
11076 //--- set coefficients ---
11077 memcpy(cofAC4x4[0],img->cofAC[b8][b4][0], 18 * sizeof(int));
11078 memcpy(cofAC4x4[1],img->cofAC[b8][b4][1], 18 * sizeof(int));
11079
11080 //--- set reconstruction ---
11081 for (y=0; y<4; y++)
11082 {
11083 memcpy(rec4x4[y],&enc_picture->imgY[pic_pix_y+y][pic_pix_x], BLOCK_SIZE * sizeof(imgpel));
11084 if(img->type==SP_SLICE &&(!si_frame_indicator && !sp2_frame_indicator))
11085 memcpy(lrec4x4[y],&lrec[pic_pix_y+y][pic_pix_x], BLOCK_SIZE * sizeof(int));// stores the mode coefficients
11086 }
11087 //--- flag if dct-coefficients must be coded ---
11088 nonzero = c_nz;
11089
11090 //--- set best mode update minimum cost ---
11091 min_rdcost = rdcost;
11092 best_ipmode = ipmode;
11093#ifdef BEST_NZ_COEFF
11094 best_nz_coeff = img->nz_coeff [img->current_mb_nr][block_x4][block_y4];
11095 best_coded_block_flag = (int)((img->mb_data[img->current_mb_nr].cbp_bits>>bit_pos)&(int64)(1));
11096#endif
11097# 667 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
11098 //store_coding_state (cs_ib4);
11099 if (img->AdaptiveRounding)
11100 {
11101 for (j=0; j<4; j++)
11102 memcpy(&fadjust4x4[block_y+j][block_x],&img->fadjust4x4[1][block_y+j][block_x], BLOCK_SIZE * sizeof(int));
11103 }
11104 }
11105
11106#ifndef RESET_STATE
11107 reset_coding_state (cs_cm);
11108#endif
11109# 678 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
11110 }
11111 }
11112 }
11113
11114#ifdef BEST_NZ_COEFF
11115 img->nz_coeff [img->current_mb_nr][block_x4][block_y4] = best_nz_coeff;
11116 cbp_bits &= (~(int64)(1<<bit_pos));
11117 cbp_bits |= (int64)(best_coded_block_flag<<bit_pos);
11118#endif
11119# 687 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
11120 //===== set intra mode prediction =====
11121 img->ipredmode[pic_block_y][pic_block_x] = (signed char) best_ipmode;
11122 img->mb_data[img->current_mb_nr].intra_pred_modes[4*b8+b4] =
11123 (signed char) (mostProbableMode == best_ipmode ? -1 : (best_ipmode < mostProbableMode ? best_ipmode : best_ipmode-1));
11124
11125 if (!input->rdopt)
11126 {
11127 // get prediction and prediction error
11128 for (j=0; j<4; j++)
11129 {
11130 int jj = pic_opix_y+j;
11131 for (i=0; i<4; i++)
11132 {
11133 img->mpr[block_y+j][block_x+i] = img->mprr[best_ipmode][j][i];
11134 img->m7[j][i] = imgY_org[jj][pic_opix_x+i] - img->mprr[best_ipmode][j][i];
11135 }
11136 }
11137 nonzero = dct_luma (block_x, block_y, &dummy, 1);
11138 }
11139 else
11140 {
11141 //===== restore coefficients =====
11142 for (j=0; j<2; j++)
11143 {
11144 memcpy (img->cofAC[b8][b4][j],cofAC4x4[j], 18 * sizeof(int));
11145 }
11146
11147 //===== restore reconstruction and prediction (needed if single coeffs are removed) =====
11148 for (y=0; y<BLOCK_SIZE; y++)
11149 {
11150 memcpy (&enc_picture->imgY[pic_pix_y+y][pic_pix_x],rec4x4[y], BLOCK_SIZE * sizeof(imgpel));
11151 memcpy (&img->mpr[block_y+y][block_x],img->mprr[best_ipmode][y], BLOCK_SIZE * sizeof(imgpel));
11152 if(img->type==SP_SLICE &&(!si_frame_indicator && !sp2_frame_indicator))
11153 memcpy (&lrec[pic_pix_y+y][pic_pix_x],lrec4x4[y], BLOCK_SIZE * sizeof(int));//restore coefficients when encoding primary SP frame
11154 }
11155
11156 if (img->AdaptiveRounding)
11157 {
11158 for (j=0; j<BLOCK_SIZE; j++)
11159 memcpy (&img->fadjust4x4[1][block_y+j][block_x],&fadjust4x4[block_y+j][block_x], BLOCK_SIZE * sizeof(int));
11160 }
11161
11162 }
11163 return nonzero;
11164}
11165
11166
11167/*!
11168 *************************************************************************************
11169 * \brief
11170 * Mode Decision for an 8x8 Intra block
11171 *************************************************************************************
11172 */
11173int Mode_Decision_for_8x8IntraBlocks(int b8,double lambda,int *cost)
11174{
11175 int nonzero=0, b4;
11176 int cost4x4;
11177
11178 *cost = (int)floor(6.0 * lambda + 0.4999);
11179
11180 for (b4=0; b4<4; b4++)
11181 {
11182 if (Mode_Decision_for_4x4IntraBlocks (b8, b4, lambda, &cost4x4))
11183 {
11184 nonzero = 1;
11185 }
11186 *cost += cost4x4;
11187 }
11188#ifdef RESET_STATE
11189 //reset_coding_state (cs_cm);
11190#endif
11191# 758 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
11192
11193 return nonzero;
11194}
11195
11196/*!
11197 *************************************************************************************
11198 * \brief
11199 * 4x4 Intra mode decision for an macroblock
11200 *************************************************************************************
11201 */
11202int Mode_Decision_for_Intra4x4Macroblock (double lambda, int* cost)
11203{
11204 int cbp=0, b8, cost8x8;
11205
11206 for (*cost=0, b8=0; b8<4; b8++)
11207 {
11208 if (Mode_Decision_for_8x8IntraBlocks (b8, lambda, &cost8x8))
11209 {
11210 cbp |= (1<<b8);
11211 }
11212 *cost += cost8x8;
11213 }
11214
11215 return cbp;
11216}
11217
11218
11219/*!
11220 *************************************************************************************
11221 * \brief
11222 * R-D Cost for an 8x8 Partition
11223 *************************************************************************************
11224 */
11225double RDCost_for_8x8blocks (int* cnt_nonz, // --> number of nonzero coefficients
11226 int64* cbp_blk, // --> cbp blk
11227 double lambda, // <-- lagrange multiplier
11228 int block, // <-- 8x8 block number
11229 int mode, // <-- partitioning mode
11230 short pdir, // <-- prediction direction
11231 short l0_ref, // <-- L0 reference picture
11232 short l1_ref) // <-- L1 reference picture
11233{
11234 int i, j, k;
11235 int rate=0;
11236 int64 distortion=0;
11237 int dummy = 0, mrate;
11238 int fw_mode, bw_mode;
11239 int cbp = 0;
11240 int pax = 8*(block & 0x01);
11241 int pay = 8*(block >> 1);
11242 int i0 = pax >> 2;
11243 int j0 = pay >> 2;
11244 int bframe = (img->type==B_SLICE);
11245 int direct = (bframe && mode==0);
11246 int b8value = B8Mode2Value (mode, pdir);
11247
11248 Macroblock *currMB = &img->mb_data[img->current_mb_nr];
11249 SyntaxElement se;
11250 Slice *currSlice = img->currentSlice;
11251 DataPartition *dataPart;
11252 const int *partMap = assignSE2partition[input->partition_mode];
11253
11254 EncodingEnvironmentPtr eep_dp;
11255
11256 //=====
11257 //===== GET COEFFICIENTS, RECONSTRUCTIONS, CBP
11258 //=====
11259 currMB->bi_pred_me=0;
11260
11261 if (direct)
11262 {
11263 if (direct_pdir[img->block_y+j0][img->block_x+i0]<0) // mode not allowed
11264 return (1e20);
11265 else
11266 *cnt_nonz = LumaResidualCoding8x8 (&cbp, cbp_blk, block, direct_pdir[img->block_y+j0][img->block_x+i0], 0, 0,
11267 (short)imax(0,direct_ref_idx[LIST_0][img->block_y+j0][img->block_x+i0]),
11268 direct_ref_idx[LIST_1][img->block_y+j0][img->block_x+i0]);
11269 }
11270 else
11271 {
11272 if (pdir == 2 && active_pps->weighted_bipred_idc == 1)
11273 {
11274 int weight_sum = (active_pps->weighted_bipred_idc == 1)? wbp_weight[0][l0_ref][l1_ref][0] + wbp_weight[1][l0_ref][l1_ref][0] : 0;
11275 if (weight_sum < -128 || weight_sum > 127)
11276 {
11277 return (1e20);
11278 }
11279 }
11280
11281 fw_mode = (pdir==0||pdir==2 ? mode : 0);
11282 bw_mode = (pdir==1||pdir==2 ? mode : 0);
11283 *cnt_nonz = LumaResidualCoding8x8 (&cbp, cbp_blk, block, pdir, fw_mode, bw_mode, l0_ref, l1_ref);
11284 }
11285
11286 //===== get residue =====
11287 if (input->rdopt==3 && img->type!=B_SLICE)
11288 {
11289 // We need the reconstructed prediction residue for the simulated decoders.
11290 compute_residue_b8block (block, -1);
11291 }
11292
11293 //=====
11294 //===== GET DISTORTION
11295 //=====
11296 if (input->rdopt==3 && img->type!=B_SLICE)
11297 {
11298 for (k=0; k<input->NoOfDecoders ;k++)
11299 {
11300 decode_one_b8block (k, P8x8, block, mode, l0_ref);
11301 for (j=img->opix_y+pay; j<img->opix_y+pay+8; j++)
11302 for (i=img->opix_x+pax; i<img->opix_x+pax+8; i++)
11303 {
11304 distortion += img->quad[imgY_org[j][i] - decs->decY[k][j][i]];
11305 }
11306 }
11307 distortion /= input->NoOfDecoders;
11308 }
11309 else
11310 {
11311 for (j=pay; j<pay+8; j++)
11312 for (i=img->pix_x+pax; i<img->pix_x+pax+8; i++)
11313 {
11314 distortion += img->quad [imgY_org[img->opix_y+j][i] - enc_picture->imgY[img->pix_y+j][i]];
11315 }
11316 }
11317
11318 //=====
11319 //===== GET RATE
11320 //=====
11321 //----- block 8x8 mode -----
11322 if (input->symbol_mode == UVLC)
11323 {
11324 ue_linfo (b8value, dummy, &mrate, &dummy);
11325 rate += mrate;
11326 }
11327 else
11328 {
11329 se.value1 = b8value;
11330 se.type = SE_MBTYPE;
11331 dataPart = &(currSlice->partArr[partMap[se.type]]);
11332 writeB8_typeInfo(&se, dataPart);
11333 rate += se.len;
11334 }
11335
11336 //----- motion information -----
11337 if (!direct)
11338 {
11339 if ((img->num_ref_idx_l0_active > 1 ) && (pdir==0 || pdir==2))
11340 rate += writeReferenceFrame (mode, i0, j0, 1, l0_ref);
11341 if(img->num_ref_idx_l1_active > 1 && img->type== B_SLICE)
11342 {
11343 if (pdir==1 || pdir==2)
11344 {
11345 rate += writeReferenceFrame (mode, i0, j0, 0, l1_ref);
11346 }
11347 }
11348
11349 if (pdir==0 || pdir==2)
11350 {
11351 rate += writeMotionVector8x8 (i0, j0, i0+2, j0+2, l0_ref,LIST_0, mode);
11352 }
11353 if (pdir==1 || pdir==2)
11354 {
11355 rate += writeMotionVector8x8 (i0, j0, i0+2, j0+2, l1_ref, LIST_1, mode);
11356 }
11357 }
11358
11359 //----- coded block pattern (for CABAC only) -----
11360 if (input->symbol_mode == CABAC)
11361 {
11362 dataPart = &(currSlice->partArr[partMap[SE_CBP]]);
11363 eep_dp = &(dataPart->ee_cabac);
11364 mrate = arienco_bits_written (eep_dp);
11365 writeCBP_BIT_CABAC (block, ((*cnt_nonz>0)?1:0), cbp8x8, currMB, 1, eep_dp);
11366 mrate = arienco_bits_written (eep_dp) - mrate;
11367 rate += mrate;
11368 }
11369
11370 //----- luminance coefficients -----
11371 if (*cnt_nonz)
11372 {
11373 rate += writeLumaCoeff8x8 (block, mode, currMB->luma_transform_size_8x8_flag);
11374 }
11375
11376 return (double)distortion + lambda * (double)rate;
11377}
11378
11379
11380/*!
11381 *************************************************************************************
11382 * \brief
11383 * Gets mode offset for intra16x16 mode
11384 *************************************************************************************
11385 */
11386int I16Offset (int cbp, int i16mode)
11387{
11388 return (cbp&15?13:1) + i16mode + ((cbp&0x30)>>2);
11389}
11390
11391
11392/*!
11393 *************************************************************************************
11394 * \brief
11395 * Sets modes and reference frames for a macroblock
11396 *************************************************************************************
11397 */
11398void SetModesAndRefframeForBlocks (int mode)
11399{
11400 int i,j,k,l;
11401 Macroblock *currMB = &img->mb_data[img->current_mb_nr];
11402 int bframe = (img->type==B_SLICE);
11403 int block_x, block_y;
11404 int cur_ref[2];
11405
11406 //--- macroblock type ---
11407 currMB->mb_type = mode;
11408 currMB->bi_pred_me= (mode == 1 ? img->bi_pred_me[mode] : 0);
11409
11410 //--- block 8x8 mode and prediction direction ---
11411 switch (mode)
11412 {
11413 case 0:
11414 for(i=0;i<4;i++)
11415 {
11416 currMB->b8mode[i] = 0;
11417 currMB->b8pdir[i] = (bframe ? direct_pdir[img->block_y + (i >> 1)*2][img->block_x + (i & 0x01)*2] : 0);
11418 }
11419 break;
11420 case 1:
11421 case 2:
11422 case 3:
11423 for(i=0;i<4;i++)
11424 {
11425 currMB->b8mode[i] = mode;
11426 currMB->b8pdir[i] = best8x8pdir[mode][i];
11427 }
11428 break;
11429 case P8x8:
11430 for(i=0;i<4;i++)
11431 {
11432 currMB->b8mode[i] = best8x8mode[i];
11433 currMB->b8pdir[i] = best8x8pdir[mode][i];
11434 }
11435 break;
11436 case I4MB:
11437 for(i=0;i<4;i++)
11438 {
11439 currMB->b8mode[i] = IBLOCK;
11440 currMB->b8pdir[i] = -1;
11441 }
11442 break;
11443 case I16MB:
11444 for(i=0;i<4;i++)
11445 {
11446 currMB->b8mode[i] = 0;
11447 currMB->b8pdir[i] = -1;
11448 }
11449 break;
11450 case I8MB:
11451 for(i=0;i<4;i++)
11452 {
11453 currMB->b8mode[i] = I8MB;
11454 currMB->b8pdir[i] = -1;
11455 }
11456 //switch to 8x8 transform
11457 currMB->luma_transform_size_8x8_flag = 1;
11458 break;
11459 case IPCM:
11460 for(i=0;i<4;i++)
11461 {
11462 currMB->b8mode[i] = IPCM;
11463 currMB->b8pdir[i] = -1;
11464 }
11465 currMB->luma_transform_size_8x8_flag = 0;
11466 break;
11467 default:
11468 printf ("Unsupported mode in SetModesAndRefframeForBlocks!\n");
11469 exit (1);
11470 }
11471
11472#define IS_FW ((best8x8pdir[mode][k]==0 || best8x8pdir[mode][k]==2) && (mode!=P8x8 || best8x8mode[k]!=0 || !bframe))
11473#define IS_BW ((best8x8pdir[mode][k]==1 || best8x8pdir[mode][k]==2) && (mode!=P8x8 || best8x8mode[k]!=0))
11474 //--- reference frame arrays ---
11475 if (mode==0 || mode==I4MB || mode==I16MB || mode==I8MB)
11476 {
11477 if (bframe)
11478 {
11479 if (!mode)
11480 {
11481 for (j = img->block_y; j < img->block_y + 4; j++)
11482 {
11483 memcpy(&enc_picture->ref_idx[LIST_0][j][img->block_x],&direct_ref_idx[LIST_0][j][img->block_x], 4 * sizeof(char));
11484 memcpy(&enc_picture->ref_idx[LIST_1][j][img->block_x],&direct_ref_idx[LIST_1][j][img->block_x], 4 * sizeof(char));
11485 }
11486 }
11487 else
11488 {
11489 for (j = img->block_y; j < img->block_y + 4; j++)
11490 {
11491 memset(&enc_picture->ref_idx[LIST_0][j][img->block_x],-1, 4 * sizeof(char));
11492 memset(&enc_picture->ref_idx[LIST_1][j][img->block_x],-1, 4 * sizeof(char));
11493 }
11494 }
11495 }
11496 else
11497 {
11498 if (!mode)
11499 {
11500 for (j = img->block_y; j < img->block_y + 4; j++)
11501 memset(&enc_picture->ref_idx[LIST_0][j][img->block_x],0, 4 * sizeof(char));
11502 }
11503 else
11504 {
11505 for (j = img->block_y; j < img->block_y + 4; j++)
11506 memset(&enc_picture->ref_idx[LIST_0][j][img->block_x],-1, 4 * sizeof(char));
11507 }
11508 }
11509 }
11510 else
11511 {
11512 if (bframe)
11513 {
11514 for (j=0;j<4;j++)
11515 {
11516 block_y = img->block_y + j;
11517 for (i=0;i<4;i++)
11518 {
11519 block_x = img->block_x + i;
11520 k = 2*(j >> 1) + (i >> 1);
11521 l = 2*(j & 0x01) + (i & 0x01);
11522
11523 if(mode == P8x8 && best8x8mode[k]==0)
11524 {
11525 enc_picture->ref_idx[LIST_0][block_y][block_x] = direct_ref_idx[LIST_0][block_y][block_x];
11526 enc_picture->ref_idx[LIST_1][block_y][block_x] = direct_ref_idx[LIST_1][block_y][block_x];
11527 }
11528 else if (mode ==1 && currMB->bi_pred_me && IS_FW && IS_BW)
11529 {
11530 enc_picture->ref_idx[LIST_0][block_y][block_x] = 0;
11531 enc_picture->ref_idx[LIST_1][block_y][block_x] = 0;
11532 }
11533 else
11534 {
11535 enc_picture->ref_idx[LIST_0][block_y][block_x] = (IS_FW ? best8x8fwref[mode][k] : -1);
11536 enc_picture->ref_idx[LIST_1][block_y][block_x] = (IS_BW ? best8x8bwref[mode][k] : -1);
11537 }
11538 }
11539 }
11540 }
11541 else
11542 {
11543 for (j=0;j<4;j++)
11544 {
11545 block_y = img->block_y + j;
11546 for (i=0;i<4;i++)
11547 {
11548 block_x = img->block_x + i;
11549 k = 2*(j >> 1) + (i >> 1);
11550 l = 2*(j & 0x01) + (i & 0x01);
11551 enc_picture->ref_idx[LIST_0][block_y][block_x] = (IS_FW ? best8x8fwref[mode][k] : -1);
11552 }
11553 }
11554 }
11555 }
11556
11557 if (bframe)
11558 {
11559
11560 for (j = img->block_y; j < img->block_y + 4; j++)
11561 for (i = img->block_x; i < img->block_x + 4;i++)
11562 {
11563 cur_ref[LIST_0] = (int) enc_picture->ref_idx[LIST_0][j][i];
11564 cur_ref[LIST_1] = (int) enc_picture->ref_idx[LIST_1][j][i];
11565
11566 enc_picture->ref_pic_id [LIST_0][j][i] = (cur_ref[LIST_0]>=0
11567 ? enc_picture->ref_pic_num[LIST_0 + currMB->list_offset][cur_ref[LIST_0]]
11568 : -1);
11569 enc_picture->ref_pic_id [LIST_1][j][i] = (cur_ref[LIST_1]>=0
11570 ? enc_picture->ref_pic_num[LIST_1 + currMB->list_offset][cur_ref[LIST_1]]
11571 : -1);
11572 }
11573 }
11574 else
11575 {
11576 for (j = img->block_y; j < img->block_y + 4; j++)
11577 for (i = img->block_x; i < img->block_x + 4;i++)
11578 {
11579 cur_ref[LIST_0] = (int) enc_picture->ref_idx[LIST_0][j][i];
11580 enc_picture->ref_pic_id [LIST_0][j][i] = (cur_ref[LIST_0]>=0
11581 ? enc_picture->ref_pic_num[LIST_0 + currMB->list_offset][cur_ref[LIST_0]]
11582 : -1);
11583 }
11584 }
11585
11586#undef IS_FW
11587#undef IS_BW
11588}
11589
11590
11591/*!
11592 *************************************************************************************
11593 * \brief
11594 * Intra 16x16 mode decision
11595 *************************************************************************************
11596 */
11597void Intra16x16_Mode_Decision (Macroblock* currMB, int* i16mode)
11598{
11599 intrapred_luma_16x16 (); /* make intra pred for all 4 new modes */
11600
11601 find_sad_16x16 (i16mode); /* get best new intra mode */
11602
11603 currMB->cbp = dct_luma_16x16 (*i16mode);
11604}
11605
11606
11607
11608/*!
11609 *************************************************************************************
11610 * \brief
11611 * Sets Coefficients and reconstruction for an 8x8 block
11612 *************************************************************************************
11613 */
11614void SetCoeffAndReconstruction8x8 (Macroblock* currMB)
11615{
11616 int block, k, j, i;
11617 int cur_ref[2];
11618
11619 //============= MIXED TRANSFORM SIZES FOR 8x8 PARTITION ==============
11620 //--------------------------------------------------------------------
11621 int l;
11622 int bframe = img->type==B_SLICE;
11623
11624 if (currMB->luma_transform_size_8x8_flag)
11625 {
11626
11627 //============= set mode and ref. frames ==============
11628 for(i = 0;i<4;i++)
11629 {
11630 currMB->b8mode[i] = tr8x8.part8x8mode[i];
11631 currMB->b8pdir[i] = tr8x8.part8x8pdir[i];
11632 }
11633
11634 if (bframe)
11635 {
11636 for (j = 0;j<4;j++)
11637 for (i = 0;i<4;i++)
11638 {
11639 k = 2*(j >> 1)+(i >> 1);
11640 l = 2*(j & 0x01)+(i & 0x01);
11641 enc_picture->ref_idx[LIST_0][img->block_y+j][img->block_x+i] = ((currMB->b8pdir[k] & 0x01) == 0) ? tr8x8.part8x8fwref[k] : - 1;
11642 enc_picture->ref_idx[LIST_1][img->block_y+j][img->block_x+i] = (currMB->b8pdir[k] > 0) ? tr8x8.part8x8bwref[k] : - 1;
11643 }
11644 }
11645 else
11646 {
11647 for (j = 0;j<4;j++)
11648 for (i = 0;i<4;i++)
11649 {
11650 k = 2*(j >> 1)+(i >> 1);
11651 l = 2*(j & 0x01)+(i & 0x01);
11652 enc_picture->ref_idx[LIST_0][img->block_y+j][img->block_x+i] = tr8x8.part8x8fwref[k];
11653 }
11654 }
11655
11656
11657 for (j = img->block_y;j<img->block_y + BLOCK_MULTIPLE;j++)
11658 {
11659 for (i = img->block_x;i<img->block_x + BLOCK_MULTIPLE;i++)
11660 {
11661 cur_ref[LIST_0] = (int) enc_picture->ref_idx[LIST_0][j][i];
11662
11663 enc_picture->ref_pic_id [LIST_0][j][i] =(cur_ref[LIST_0]>=0
11664 ? enc_picture->ref_pic_num[LIST_0 + currMB->list_offset][cur_ref[LIST_0]]
11665 : -1);
11666 }
11667 }
11668
11669 if (bframe)
11670 {
11671 for (j = img->block_y; j < img->block_y + BLOCK_MULTIPLE; j++)
11672 {
11673 for (i = img->block_x;i<img->block_x + BLOCK_MULTIPLE;i++)
11674 {
11675 cur_ref[LIST_1] = (int) enc_picture->ref_idx[LIST_1][j][i];
11676
11677 enc_picture->ref_pic_id [LIST_1][j][i] = (cur_ref[LIST_1]>=0
11678 ? enc_picture->ref_pic_num[LIST_1 + currMB->list_offset][cur_ref[LIST_1]]
11679 : -1);
11680 }
11681
11682 }
11683 }
11684
11685 //====== set the mv's for 8x8 partition with transform size 8x8 ======
11686 //save the mv data for 4x4 transform
11687
11688 StoreMV8x8(1);
11689 //set new mv data for 8x8 transform
11690 RestoreMV8x8(0);
11691
11692 //============= get pre-calculated data ==============
11693 //restore coefficients from 8x8 transform
11694
11695 for (block = 0; block<4; block++)
11696 {
11697 for (k = 0; k<4; k++)
11698 for (j = 0; j<2; j++)
11699 memcpy (img->cofAC[block][k][j],cofAC_8x8ts[block][k][j], 65 * sizeof(int));
11700 }
11701 //restore reconstruction
11702 if (cnt_nonz8_8x8ts <= _LUMA_8x8_COEFF_COST_ &&
11703 ((img->qp_scaled)!=0 || img->lossless_qpprime_flag==0) &&
11704 (img->type!=SP_SLICE))// modif ES added last condition (we probably never go there so is the next modification useful ? check)
11705 {
11706 currMB->cbp = 0;
11707 currMB->cbp_blk = 0;
11708 for (j = 0; j < MB_BLOCK_SIZE; j++)
11709 {
11710 memcpy(&enc_picture->imgY[img->pix_y+j][img->pix_x], tr8x8.mpr8x8[j], MB_BLOCK_SIZE * sizeof(imgpel));
11711 if(img->type==SP_SLICE &&(!si_frame_indicator && !sp2_frame_indicator ))
11712 memcpy(&lrec[img->pix_y+j][img->pix_x],tr8x8.lrec[j], MB_BLOCK_SIZE * sizeof(int));
11713 }
11714 }
11715 else
11716 {
11717 currMB->cbp = cbp8_8x8ts;
11718 currMB->cbp_blk = cbp_blk8_8x8ts;
11719 for (j = 0; j < MB_BLOCK_SIZE; j++)
11720 {
11721 memcpy (&enc_picture->imgY[img->pix_y+j][img->pix_x],tr8x8.rec_mbY8x8[j], MB_BLOCK_SIZE * sizeof(imgpel));
11722 if(img->type==SP_SLICE &&(!si_frame_indicator && !sp2_frame_indicator))
11723 memcpy (&lrec[img->pix_y+j][img->pix_x],tr8x8.lrec[j], MB_BLOCK_SIZE * sizeof(int));
11724 }
11725 }
11726 }
11727 else
11728 {
11729 //============= get pre-calculated data ==============
11730 //---------------------------------------------------
11731 //--- restore coefficients ---
11732 for (block = 0; block<4+img->num_blk8x8_uv; block++)
11733 {
11734 for (k = 0; k<4; k++)
11735 for (j = 0; j<2; j++)
11736 memcpy (img->cofAC[block][k][j],cofAC8x8[block][k][j], 65 * sizeof(int));
11737 }
11738
11739 if (cnt_nonz_8x8<=5 && img->type!=SP_SLICE &&
11740 ((img->qp_scaled)!=0 || img->lossless_qpprime_flag==0))
11741 {
11742 currMB->cbp = 0;
11743 currMB->cbp_blk = 0;
11744 for (j = 0; j < MB_BLOCK_SIZE; j++)
11745 {
11746 memcpy (&enc_picture->imgY[img->pix_y+j][img->pix_x],tr4x4.mpr8x8[j], MB_BLOCK_SIZE * sizeof(imgpel));
11747 if(img->type ==SP_SLICE &&(!si_frame_indicator && !sp2_frame_indicator))
11748 memcpy (&lrec[img->pix_y+j][img->pix_x],tr4x4.lrec[j], MB_BLOCK_SIZE * sizeof(int)); // restore coeff. SP frame
11749 }
11750 }
11751 else
11752 {
11753 currMB->cbp = cbp8x8;
11754 currMB->cbp_blk = cbp_blk8x8;
11755 for (j = 0; j < MB_BLOCK_SIZE; j++)
11756 {
11757 memcpy (&enc_picture->imgY[img->pix_y+j][img->pix_x],tr4x4.rec_mbY8x8[j], MB_BLOCK_SIZE * sizeof(imgpel));
11758 if(img->type==SP_SLICE &&(!si_frame_indicator && !sp2_frame_indicator))
11759 memcpy (&lrec[img->pix_y+j][img->pix_x],tr4x4.lrec[j], MB_BLOCK_SIZE * sizeof(int));
11760 }
11761 }
11762 }
11763}
11764
11765
11766/*!
11767 *************************************************************************************
11768 * \brief
11769 * Sets motion vectors for a macroblock
11770 *************************************************************************************
11771 */
11772void SetMotionVectorsMB (Macroblock* currMB, int bframe)
11773{
11774 int i, j, k, l, m, mode8, pdir8, ref, by, bx;
11775 short ******all_mv = img->all_mv;
11776 short ******pred_mv = img->pred_mv;
11777 int bw_ref;
11778 int jdiv, jmod;
11779
11780 if (!bframe)
11781 {
11782 for (j = 0; j<4; j++)
11783 {
11784 jmod = j & 0x01;
11785 jdiv = j >> 1;
11786 by = img->block_y+j;
11787 for (i = 0; i<4; i++)
11788 {
11789 mode8 = currMB->b8mode[k=2*jdiv+(i>>1)];
11790 l = 2*jmod + (i & 0x01);
11791
11792 bx = img->block_x+i;
11793
11794 pdir8 = currMB->b8pdir[k];
11795 ref = enc_picture->ref_idx[LIST_0][by][bx];
11796
11797 if (pdir8>=0)
11798 {
11799 enc_picture->mv[LIST_0][by][bx][0] = all_mv [j][i][LIST_0][ ref][mode8][0];
11800 enc_picture->mv[LIST_0][by][bx][1] = all_mv [j][i][LIST_0][ ref][mode8][1];
11801 }
11802 else
11803 {
11804 enc_picture->mv[LIST_0][by][bx][0] = 0;
11805 enc_picture->mv[LIST_0][by][bx][1] = 0;
11806 }
11807 }
11808 }
11809 }
11810else
11811{
11812 for (j = 0; j<4; j++)
11813 {
11814 jmod = j & 0x01;
11815 jdiv = j >> 1;
11816 by = img->block_y+j;
11817 for (i = 0; i<4; i++)
11818 {
11819 mode8 = currMB->b8mode[k=2*jdiv+(i>>1)];
11820 l = 2*jmod + (i & 0x01);
11821
11822 bx = img->block_x+i;
11823
11824 pdir8 = currMB->b8pdir[k];
11825 ref = enc_picture->ref_idx[LIST_0][by][bx];
11826 bw_ref = enc_picture->ref_idx[LIST_1][by][bx];
11827
11828 if (currMB->bi_pred_me && (pdir8 == 2) && currMB->mb_type==1)
11829 {
11830 all_mv = currMB->bi_pred_me == 1 ? img->bipred_mv1 : img->bipred_mv2;
11831 ref = 0;
11832 bw_ref = 0;
11833 }
11834
11835 if (pdir8==-1) // intra
11836 {
11837 enc_picture->mv[LIST_0][by][bx][0] = 0;
11838 enc_picture->mv[LIST_0][by][bx][1] = 0;
11839 enc_picture->mv[LIST_1][by][bx][0] = 0;
11840 enc_picture->mv[LIST_1][by][bx][1] = 0;
11841 }
11842 else if (pdir8==0) // list 0
11843 {
11844 enc_picture->mv[LIST_0][by][bx][0] = all_mv [j][i][LIST_0][ ref][mode8][0];
11845 enc_picture->mv[LIST_0][by][bx][1] = all_mv [j][i][LIST_0][ ref][mode8][1];
11846 enc_picture->mv[LIST_1][by][bx][0] = 0;
11847 enc_picture->mv[LIST_1][by][bx][1] = 0;
11848 enc_picture->ref_idx[LIST_1][by][bx] = -1;
11849 }
11850 else if (pdir8==1) // list 1
11851 {
11852 enc_picture->mv[LIST_0][by][bx][0] = 0;
11853 enc_picture->mv[LIST_0][by][bx][1] = 0;
11854 enc_picture->ref_idx[LIST_0][by][bx] = -1;
11855 enc_picture->mv[LIST_1][by][bx][0] = all_mv [j][i][LIST_1][bw_ref][mode8][0];
11856 enc_picture->mv[LIST_1][by][bx][1] = all_mv [j][i][LIST_1][bw_ref][mode8][1];
11857 }
11858 else if (pdir8==2) // bipredictive
11859 {
11860 enc_picture->mv[LIST_0][by][bx][0] = all_mv [j][i][LIST_0][ ref][mode8][0];
11861 enc_picture->mv[LIST_0][by][bx][1] = all_mv [j][i][LIST_0][ ref][mode8][1];
11862 enc_picture->mv[LIST_1][by][bx][0] = all_mv [j][i][LIST_1][bw_ref][mode8][0];
11863 enc_picture->mv[LIST_1][by][bx][1] = all_mv [j][i][LIST_1][bw_ref][mode8][1];
11864 }
11865 else
11866 {
11867 error("invalid direction mode", 255);
11868 }
11869 }
11870 }
11871}
11872
11873 // copy all the motion vectors into rdopt structure
11874 // Can simplify this by copying the MV's of the best mode (TBD)
11875 if(img->MbaffFrameFlag)
11876 {
11877 for(i = 0;i<4;i++)
11878 {
11879 for(j = 0;j<4;j++)
11880 {
11881 for (k = 0;k<2;k++)
11882 {
11883 for(l = 0;l<img->max_num_references;l++)
11884 {
11885 for(m = 0;m<9;m++)
11886 {
11887 rdopt->all_mv [j][i][k][l][m][0] = all_mv [j][i][k][l][m][0];
11888 rdopt->pred_mv[j][i][k][l][m][0] = pred_mv[j][i][k][l][m][0];
11889
11890 rdopt->all_mv [j][i][k][l][m][1] = all_mv [j][i][k][l][m][1];
11891 rdopt->pred_mv[j][i][k][l][m][1] = pred_mv[j][i][k][l][m][1];
11892 }
11893 }
11894 }
11895 }
11896 }
11897 }
11898}
11899
11900
11901
11902/*!
11903 *************************************************************************************
11904 * \brief
11905 * R-D Cost for a macroblock
11906 *************************************************************************************
11907 */
11908int RDCost_for_macroblocks (double lambda, // <-- lagrange multiplier
11909 int mode, // <-- modus (0-COPY/DIRECT, 1-16x16, 2-16x8, 3-8x16, 4-8x8(+), 5-Intra4x4, 6-Intra16x16)
11910 double* min_rdcost, // <-> minimum rate-distortion cost
11911 double* min_rate, // --> bitrate of mode which has minimum rate-distortion cost.
11912 int i16mode )
11913{
11914 int i, j, k; //, k, ****ip4;
11915 int j1, j2;
11916 int rate = 0, coeff_rate = 0;
11917 int64 distortion = 0;
11918 double rdcost;
11919 int prev_mb_nr = FmoGetPreviousMBNr(img->current_mb_nr);
11920 Macroblock *currMB = &img->mb_data[img->current_mb_nr];
11921 Macroblock *prevMB = (prev_mb_nr >= 0) ? &img->mb_data[prev_mb_nr] : NULL;
11922 int bframe = (img->type==B_SLICE);
11923 int tmp_cc;
11924 int use_of_cc = (img->type!=I_SLICE && input->symbol_mode!=CABAC);
11925 int cc_rate, dummy;
11926
11927 //=====
11928 //===== SET REFERENCE FRAMES AND BLOCK MODES
11929 //=====
11930 SetModesAndRefframeForBlocks (mode);
11931
11932 //=====
11933 //===== GET COEFFICIENTS, RECONSTRUCTIONS, CBP
11934 //=====
11935 if (bframe && mode==0)
11936 {
11937 int block_x=img->pix_x>>2;
11938 int block_y=img->pix_y>>2;
11939 for (j = block_y;j< block_y + 4;j++)
11940 for (i = block_x;i<block_x + 4;i++)
11941 if (direct_pdir[j][i] < 0)
11942 return 0;
11943 }
11944
11945 // Test MV limits for Skip Mode. This could be necessary for MBAFF case Frame MBs.
11946 if ((img->MbaffFrameFlag) && (!currMB->mb_field) && (img->type==P_SLICE) && (mode==0) )
11947 {
11948 if ( img->all_mv[0][0][0][0][0][0] < -8192
11949 || img->all_mv[0][0][0][0][0][0] > 8191
11950 || img->all_mv[0][0][0][0][0][1] < LEVELMVLIMIT[img->LevelIndex][4]
11951 || img->all_mv[0][0][0][0][0][1] > LEVELMVLIMIT[img->LevelIndex][5])
11952 return 0;
11953 }
11954
11955 if (img->AdaptiveRounding)
11956 {
11957 memset(&(img->fadjust4x4[0][0][0]), 0, MB_PIXELS * sizeof(int));
11958 memset(&(img->fadjust8x8[0][0][0]), 0, MB_PIXELS * sizeof(int));
11959 memset(&(img->fadjust4x4Cr[0][0][0][0]), 0, img->mb_cr_size_y * img->mb_cr_size_x * sizeof(int));
11960 memset(&(img->fadjust4x4Cr[0][1][0][0]), 0, img->mb_cr_size_y * img->mb_cr_size_x * sizeof(int));
11961 }
11962
11963 if (mode<P8x8)
11964 {
11965 LumaResidualCoding ();
11966
11967 if(mode==0 && currMB->cbp!=0 && (img->type != B_SLICE || img->NoResidueDirect==1))
11968 return 0;
11969 if(mode==0 && currMB->cbp==0 && currMB->luma_transform_size_8x8_flag==1) //for B_skip, luma_transform_size_8x8_flag=0 only
11970 return 0;
11971 }
11972 else if (mode==P8x8)
11973 {
11974 SetCoeffAndReconstruction8x8 (currMB);
11975 }
11976 else if (mode==I4MB)
11977 {
11978 currMB->cbp = Mode_Decision_for_Intra4x4Macroblock (lambda, &dummy);
11979 }
11980 else if (mode==I16MB)
11981 {
11982 Intra16x16_Mode_Decision (currMB, &i16mode);
11983 }
11984 else if(mode==I8MB)
11985 {
11986 currMB->cbp = Mode_Decision_for_new_Intra8x8Macroblock(lambda, &dummy);
11987 }
11988 else if(mode==IPCM)
11989 {
11990 for (j = 0; j < MB_BLOCK_SIZE; j++)
11991 {
11992 j1 = j + img->opix_y;
11993 j2 = j + img->pix_y;
11994 for (i=img->opix_x; i<img->opix_x+MB_BLOCK_SIZE; i++)
11995 enc_picture->imgY[j2][i] = imgY_org[j1][i];
11996 }
11997 if (img->yuv_format != YUV400)
11998 {
11999 // CHROMA
12000 for (j = 0; j<img->mb_cr_size_y; j++)
12001 {
12002 j1 = j + img->opix_c_y;
12003 j2 = j + img->pix_c_y;
12004 for (i=img->opix_c_x; i<img->opix_c_x+img->mb_cr_size_x; i++)
12005 {
12006 enc_picture->imgUV[0][j2][i] = imgUV_org[0][j1][i];
12007 enc_picture->imgUV[1][j2][i] = imgUV_org[1][j1][i];
12008 }
12009 }
12010 }
12011 for (j=0;j<4;j++)
12012 for (i=0; i<(4+img->num_blk8x8_uv); i++)
12013 img->nz_coeff[img->current_mb_nr][j][i] = 16;
12014
12015 }
12016
12017 if (input->rdopt==3 && img->type!=B_SLICE)
12018 {
12019 // We need the reconstructed prediction residue for the simulated decoders.
12020 compute_residue_mb (mode==I16MB?i16mode:-1);
12021 }
12022
12023 //Rate control
12024 if (input->RCEnable)
12025 {
12026 if (mode == I16MB)
12027 memcpy(pred,img->mprr_2[i16mode],MB_PIXELS * sizeof(imgpel));
12028 else
12029 memcpy(pred,img->mpr,MB_PIXELS * sizeof(imgpel));
12030 }
12031
12032 img->i16offset = 0;
12033 dummy = 0;
12034 if ((img->yuv_format!=YUV400) && (mode != IPCM))
12035 ChromaResidualCoding (&dummy);
12036
12037 if (mode==I16MB)
12038 img->i16offset = I16Offset (currMB->cbp, i16mode);
12039
12040 //=====
12041 //===== GET DISTORTION
12042 //=====
12043 // LUMA
12044 if (input->rdopt==3 && img->type!=B_SLICE)
12045 {
12046 for (k = 0; k<input->NoOfDecoders ;k++)
12047 {
12048 decode_one_mb (k, currMB);
12049 for (j = 0; j<MB_BLOCK_SIZE; j++)
12050 {
12051 for (i=img->opix_x; i<img->opix_x+MB_BLOCK_SIZE; i++)
12052 distortion += img->quad [imgY_org[img->opix_y+j][i] - decs->decY[k][img->opix_y+j][i]];
12053 }
12054 }
12055 distortion /= input->NoOfDecoders;
12056
12057 if (img->yuv_format != YUV400)
12058 {
12059 // CHROMA
12060 for (j = 0; j<img->mb_cr_size_y; j++)
12061 {
12062 j1 = j + img->opix_c_y;
12063 j2 = j + img->pix_c_y;
12064 for (i=img->opix_c_x; i<img->opix_c_x+img->mb_cr_size_x; i++)
12065 {
12066 distortion += img->quad [imgUV_org[0][j1][i] - enc_picture->imgUV[0][j2][i]];
12067 distortion += img->quad [imgUV_org[1][j1][i] - enc_picture->imgUV[1][j2][i]];
12068 }
12069 }
12070 }
12071 }
12072 else
12073 {
12074 // LUMA
12075 for (j = 0; j < MB_BLOCK_SIZE; j++)
12076 {
12077 j1 = j + img->opix_y;
12078 j2 = j + img->pix_y;
12079 for (i=img->opix_x; i<img->opix_x+MB_BLOCK_SIZE; i++)
12080 distortion += img->quad [imgY_org[j1][i] - enc_picture->imgY[j2][i]];
12081 }
12082
12083 if (img->yuv_format != YUV400)
12084 {
12085 // CHROMA
12086 for (j = 0; j<img->mb_cr_size_y; j++)
12087 {
12088 j1 = j + img->opix_c_y;
12089 j2 = j + img->pix_c_y;
12090 for (i=img->opix_c_x; i<img->opix_c_x+img->mb_cr_size_x; i++)
12091 {
12092 distortion += img->quad [imgUV_org[0][j1][i] - enc_picture->imgUV[0][j2][i]];
12093 distortion += img->quad [imgUV_org[1][j1][i] - enc_picture->imgUV[1][j2][i]];
12094 }
12095 }
12096 }
12097 }
12098
12099 //===== S T O R E C O D I N G S T A T E =====
12100 //---------------------------------------------------
12101 store_coding_state (cs_cm);
12102
12103 //=====
12104 //===== GET RATE
12105 //=====
12106 //----- macroblock header -----
12107 if (use_of_cc)
12108 {
12109 if (currMB->mb_type!=0 || (bframe && currMB->cbp!=0))
12110 {
12111 // cod counter and macroblock mode are written ==> do not consider code counter
12112 tmp_cc = img->cod_counter;
12113 rate = writeMBLayer (1, &coeff_rate);
12114 ue_linfo (tmp_cc, dummy, &cc_rate, &dummy);
12115 rate -= cc_rate;
12116 img->cod_counter = tmp_cc;
12117 }
12118 else
12119 {
12120 // cod counter is just increased ==> get additional rate
12121 ue_linfo (img->cod_counter+1, dummy, &rate, &dummy);
12122 ue_linfo (img->cod_counter, dummy, &cc_rate, &dummy);
12123 rate -= cc_rate;
12124 }
12125 }
12126 else
12127 {
12128 rate = writeMBLayer (1, &coeff_rate);
12129 }
12130
12131 //===== R E S T O R E C O D I N G S T A T E =====
12132 //-------------------------------------------------------
12133 reset_coding_state (cs_cm);
12134
12135 rdcost = (double)distortion + lambda * dmax(0.5,(double)rate);
12136
12137 if (rdcost >= *min_rdcost ||
12138 ((img->qp_scaled)==0 && img->lossless_qpprime_flag==1 && distortion!=0))
12139 {
12140#if FASTMODE
12141 // Reordering RDCost comparison order of mode 0 and mode 1 in P_SLICE
12142 // if RDcost of mode 0 and mode 1 is same, we choose best_mode is 0
12143 // This might not always be good since mode 0 is more biased towards rate than quality.
12144 if((img->type!=P_SLICE || mode != 0 || rdcost != *min_rdcost) || input->ProfileIDC>=FREXT_HP)
12145#endif
12146# 1712 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
12147 return 0;
12148 }
12149
12150
12151 if ((img->MbaffFrameFlag) && (mode ? 0: ((img->type == B_SLICE) ? !currMB->cbp:1))) // AFF and current is skip
12152 {
12153 if (img->current_mb_nr & 0x01) //bottom
12154 {
12155 if (prevMB->mb_type ? 0:((img->type == B_SLICE) ? !prevMB->cbp:1)) //top is skip
12156 {
12157 if (!(field_flag_inference() == currMB->mb_field)) //skip only allowed when correct inference
12158 return 0;
12159 }
12160 }
12161 }
12162
12163 //===== U P D A T E M I N I M U M C O S T =====
12164 //-----------------------------------------------------
12165 *min_rdcost = rdcost;
12166 *min_rate = lambda * (double)coeff_rate;
12167
12168#ifdef BEST_NZ_COEFF
12169 for (j=0;j<4;j++)
12170 for (i=0; i<(4+img->num_blk8x8_uv); i++)
12171 gaaiMBAFF_NZCoeff[j][i] = img->nz_coeff[img->current_mb_nr][j][i];
12172#endif
12173# 1738 "/local/scratch/alr48/cheri/llvm-test-suite/MultiSource/Applications/JM/lencod/rdopt.c"
12174
12175 return 1;
12176}
12177
12178/*!
12179 *************************************************************************************
12180 * \brief
12181 * Store adaptive rounding parameters
12182 *************************************************************************************
12183 */
12184void store_adaptive_rounding_parameters (int mode, Macroblock *currMB)
12185{
12186 int j;
12187 int is_inter = (mode != I4MB)&&(mode != I16MB)&&(mode != I8MB);
12188
12189 if (currMB->luma_transform_size_8x8_flag)
12190 {
12191 if ((mode == P8x8))
12192 memcpy(&(bestInterFAdjust8x8[0][0]),&(img->fadjust8x8[2][0][0]),MB_PIXELS * sizeof(int));
12193 else if (is_inter)
12194 memcpy(&(bestInterFAdjust8x8[0][0]),&(img->fadjust8x8[0][0][0]),MB_PIXELS * sizeof(int));
12195 else
12196 memcpy(&(bestIntraFAdjust8x8[0][0]),&(img->fadjust8x8[1][0][0]),MB_PIXELS * sizeof(int));
12197 }
12198 else
12199 {
12200 if ((mode == P8x8))
12201 memcpy(&(bestInterFAdjust4x4[0][0]),&(img->fadjust4x4[3][0][0]),MB_PIXELS * sizeof(int));
12202 else if (is_inter)
12203 memcpy(&(bestInterFAdjust4x4[0][0]),&(img->fadjust4x4[0][0][0]),MB_PIXELS * sizeof(int));
12204 else
12205 memcpy(&(bestIntraFAdjust4x4[0][0]),&(img->fadjust4x4[1 + mode == I16MB][0][0]),MB_PIXELS * sizeof(int));
12206 }
12207 if (input->AdaptRndChroma)
12208 {
12209 if (currMB->luma_transform_size_8x8_flag && mode == P8x8)
12210 {
12211 for (j = 0; j < img->mb_cr_size_y; j++)
12212 {
12213 memcpy(bestInterFAdjust4x4Cr[0][j],img->fadjust8x8Cr[0][0][j],img->mb_cr_size_x * sizeof(int));
12214 memcpy(bestInterFAdjust4x4Cr[1][j],img->fadjust8x8Cr[0][1][j],img->mb_cr_size_x * sizeof(int));
12215 }
12216 }
12217 else if (mode == P8x8)
12218 {
12219 for (j = 0; j < img->mb_cr_size_y; j++)
12220 {
12221 memcpy(bestInterFAdjust4x4Cr[0][j],img->fadjust4x4Cr[2][0][j],img->mb_cr_size_x * sizeof(int));
12222 memcpy(bestInterFAdjust4x4Cr[1][j],img->fadjust4x4Cr[2][1][j],img->mb_cr_size_x * sizeof(int));
12223 }
12224 }
12225 else if (is_inter)
12226 {
12227 for (j = 0; j < img->mb_cr_size_y; j++)
12228 {
12229 memcpy(bestInterFAdjust4x4Cr[0][j],img->fadjust4x4Cr[0][0][j],img->mb_cr_size_x * sizeof(int));
12230 memcpy(bestInterFAdjust4x4Cr[1][j],img->fadjust4x4Cr[0][1][j],img->mb_cr_size_x * sizeof(int));
12231 }
12232 }
12233 else
12234 {
12235 for (j = 0; j < img->mb_cr_size_y; j++)
12236 {
12237 memcpy(bestIntraFAdjust4x4Cr[0][j],img->fadjust4x4Cr[1][0][j],img->mb_cr_size_x * sizeof(int));
12238 memcpy(bestIntraFAdjust4x4Cr[1][j],img->fadjust4x4Cr[1][1][j],img->mb_cr_size_x * sizeof(int));
12239 }
12240 }
12241 }
12242}
12243
12244/*!
12245 *************************************************************************************
12246 * \brief
12247 * Store macroblock parameters
12248 *************************************************************************************
12249 */
12250void store_macroblock_parameters (int mode)
12251{
12252 int i, j, k, ****i4p, ***i3p;
12253 Macroblock *currMB = &img->mb_data[img->current_mb_nr];
12254 int bframe = (img->type==B_SLICE);
12255
12256 //--- store best mode ---
12257 best_mode = mode;
12258 best_c_imode = currMB->c_ipred_mode;
12259 best_i16offset = img->i16offset;
12260
12261 // If condition is not really necessary.
12262 bi_pred_me = (mode == 1) ? currMB->bi_pred_me : 0;
12263
12264 memcpy(b8mode, currMB->b8mode, BLOCK_MULTIPLE * sizeof(int));
12265 memcpy(b8pdir, currMB->b8pdir, BLOCK_MULTIPLE * sizeof(int));
12266 memcpy(b4_intra_pred_modes,currMB->intra_pred_modes, MB_BLOCK_PARTITIONS * sizeof(char));
12267 memcpy(b8_intra_pred_modes8x8,currMB->intra_pred_modes8x8, MB_BLOCK_PARTITIONS * sizeof(char));
12268
12269 for (j = 0 ; j < BLOCK_MULTIPLE; j++)
12270 {
12271 memcpy(&b4_ipredmode[j * BLOCK_MULTIPLE],&img->ipredmode[img->block_y + j][img->block_x],BLOCK_MULTIPLE * sizeof(char));
12272 memcpy(b8_ipredmode8x8[j],&img->ipredmode8x8[img->block_y + j][img->block_x],BLOCK_MULTIPLE * sizeof(char));
12273 }
12274 //--- reconstructed blocks ----
12275 for (j = 0; j < MB_BLOCK_SIZE; j++)
12276 {
12277 memcpy(rec_mbY[j],&enc_picture->imgY[img->pix_y+j][img->pix_x], MB_BLOCK_SIZE * sizeof(imgpel));
12278 }
12279 if((img->type==SP_SLICE) && (si_frame_indicator==0 && sp2_frame_indicator==0))
12280 {
12281 for (j = 0; j < MB_BLOCK_SIZE; j++)
12282 {
12283 memcpy(lrec_rec[j],&lrec[img->pix_y+j][img->pix_x], MB_BLOCK_SIZE * sizeof(int));//store coefficients SP frame
12284 }
12285 }
12286
12287 if (img->AdaptiveRounding)
12288 store_adaptive_rounding_parameters (mode, currMB);
12289
12290 if (img->yuv_format != YUV400)
12291 {
12292 for (j = 0; j<img->mb_cr_size_y; j++)
12293 {
12294 memcpy(rec_mbU[j],&enc_picture->imgUV[0][img->pix_c_y+j][img->pix_c_x], img->mb_cr_size_x * sizeof(imgpel));
12295 memcpy(rec_mbV[j],&enc_picture->imgUV[1][img->pix_c_y+j][img->pix_c_x], img->mb_cr_size_x * sizeof(imgpel));
12296 }
12297 if((img->type==SP_SLICE) && (si_frame_indicator==0 && sp2_frame_indicator==0))
12298 {
12299 //store uv coefficients SP frame
12300 for (j = 0; j<img->mb_cr_size_y; j++)
12301 {
12302 memcpy(lrec_rec_U[j],&lrec_uv[0][img->pix_c_y+j][img->pix_c_x], img->mb_cr_size_x * sizeof(int));
12303 memcpy(lrec_rec_V[j],&lrec_uv[1][img->pix_c_y+j][img->pix_c_x], img->mb_cr_size_x * sizeof(int));
12304 }
12305 }
12306 }
12307
12308 //--- store results of decoders ---
12309 if (input->rdopt==3 && img->type!=B_SLICE)
12310 {
12311 for (k = 0; k<input->NoOfDecoders; k++)
12312 {
12313 for (j=img->pix_y; j<img->pix_y+16; j++)
12314 for (i=img->pix_x; i<img->pix_x+16; i++)
12315 {
12316 // Keep the decoded values of each MB for updating the ref frames
12317 decs->decY_best[k][j][i] = decs->decY[k][j][i];
12318 }
12319 }
12320 }
12321
12322 //--- coeff, cbp, kac ---
12323 if (mode || bframe)
12324 {
12325 i4p=cofAC; cofAC=img->cofAC; img->cofAC=i4p;
12326 i3p=cofDC; cofDC=img->cofDC; img->cofDC=i3p;
12327 cbp = currMB->cbp;
12328 cbp_blk = currMB->cbp_blk;
12329 }
12330 else
12331 {
12332 cbp_blk = cbp = 0;
12333 }
12334
12335 //--- store transform size ---
12336 luma_transform_size_8x8_flag = currMB->luma_transform_size_8x8_flag;
12337
12338
12339 for (j = 0; j<4; j++)
12340 memcpy(frefframe[j],&enc_picture->ref_idx[LIST_0][img->block_y+j][img->block_x], BLOCK_MULTIPLE * sizeof(char));
12341
12342 if (bframe)
12343 {
12344 for (j = 0; j<4; j++)
12345 memcpy(brefframe[j],&enc_picture->ref_idx[LIST_1][img->block_y+j][img->block_x], BLOCK_MULTIPLE * sizeof(char));
12346 }
12347}
12348
12349
12350/*!
12351 *************************************************************************************
12352 * \brief
12353 * Set stored macroblock parameters
12354 *************************************************************************************
12355 */
12356void set_stored_macroblock_parameters ()
12357{
12358 Macroblock *currMB = &img->mb_data[img->current_mb_nr];
12359 imgpel **imgY = enc_picture->imgY;
12360 imgpel ***imgUV = enc_picture->imgUV;
12361
12362 int mode = best_mode;
12363 int bframe = (img->type==B_SLICE);
12364 int i, j, k, ****i4p, ***i3p;
12365 int block_x, block_y;
12366 signed char **ipredmodes = img->ipredmode;
12367 short *cur_mv;
12368
12369 //===== reconstruction values =====
12370 for (j = 0; j < MB_BLOCK_SIZE; j++)
12371 {
12372 memcpy(&imgY[img->pix_y+j][img->pix_x],rec_mbY[j], MB_BLOCK_SIZE * sizeof(imgpel));
12373 }
12374 if((img->type==SP_SLICE) &&(si_frame_indicator==0 && sp2_frame_indicator==0 ))
12375 {
12376 for (j = 0; j < MB_BLOCK_SIZE; j++)
12377 memcpy(&lrec[img->pix_y+j][img->pix_x],lrec_rec[j], MB_BLOCK_SIZE * sizeof(int)); //restore coeff SP frame
12378 }
12379 if(img->MbaffFrameFlag)
12380 {
12381 for (j = 0; j < MB_BLOCK_SIZE; j++)
12382 memcpy(rdopt->rec_mbY[j],rec_mbY[j], MB_BLOCK_SIZE * sizeof(imgpel));
12383 }
12384
12385 if (img->AdaptiveRounding)
12386 {
12387 update_offset_params(mode,luma_transform_size_8x8_flag);
12388 }
12389
12390 if (img->yuv_format != YUV400)
12391 {
12392 for (j = 0; j<img->mb_cr_size_y; j++)
12393 {
12394 memcpy(&imgUV[0][img->pix_c_y+j][img->pix_c_x],rec_mbU[j], img->mb_cr_size_x * sizeof(imgpel));
12395 memcpy(&imgUV[1][img->pix_c_y+j][img->pix_c_x],rec_mbV[j], img->mb_cr_size_x * sizeof(imgpel));
12396 if((img->type==SP_SLICE) &&(!si_frame_indicator && !sp2_frame_indicator))
12397 {
12398 memcpy(&lrec_uv[0][img->pix_c_y+j][img->pix_c_x],lrec_rec_U[j], img->mb_cr_size_x * sizeof(int));
12399 memcpy(&lrec_uv[1][img->pix_c_y+j][img->pix_c_x],lrec_rec_V[j], img->mb_cr_size_x * sizeof(int));
12400 }
12401 if(img->MbaffFrameFlag)
12402 {
12403 memcpy(rdopt->rec_mbU[j],rec_mbU[j], img->mb_cr_size_x * sizeof(imgpel));
12404 memcpy(rdopt->rec_mbV[j],rec_mbV[j], img->mb_cr_size_x * sizeof(imgpel));
12405 }
12406 }
12407
12408 if((img->type==SP_SLICE) &&(!si_frame_indicator && !sp2_frame_indicator))
12409 {
12410 for (j = 0; j<img->mb_cr_size_y; j++)
12411 {
12412 memcpy(&lrec_uv[0][img->pix_c_y+j][img->pix_c_x],lrec_rec_U[j], img->mb_cr_size_x * sizeof(int));
12413 memcpy(&lrec_uv[1][img->pix_c_y+j][img->pix_c_x],lrec_rec_V[j], img->mb_cr_size_x * sizeof(int));
12414 }
12415 }
12416
12417 if(img->MbaffFrameFlag)
12418 {
12419 for (j = 0; j<img->mb_cr_size_y; j++)
12420 {
12421
12422 memcpy(rdopt->rec_mbU[j],rec_mbU[j], img->mb_cr_size_x * sizeof(imgpel));
12423 memcpy(rdopt->rec_mbV[j],rec_mbV[j], img->mb_cr_size_x * sizeof(imgpel));
12424 }
12425 }
12426 }
12427
12428 //===== coefficients and cbp =====
12429 i4p=cofAC; cofAC=img->cofAC; img->cofAC=i4p;
12430 i3p=cofDC; cofDC=img->cofDC; img->cofDC=i3p;
12431 currMB->cbp = cbp;
12432 currMB->cbp_blk = cbp_blk;
12433 //==== macroblock type ====
12434 currMB->mb_type = mode;
12435
12436 if(img->MbaffFrameFlag)
12437 {
12438 rdopt->mode = mode;
12439 rdopt->i16offset = img->i16offset;
12440 rdopt->cbp = cbp;
12441 rdopt->cbp_blk = cbp_blk;
12442 rdopt->mb_type = mode;
12443
12444 rdopt->prev_qp = currMB->prev_qp;
12445 rdopt->prev_delta_qp = currMB->prev_delta_qp;
12446 rdopt->delta_qp = currMB->delta_qp;
12447 rdopt->qp = currMB->qp;
12448 rdopt->prev_cbp = currMB->prev_cbp;
12449
12450 for(i = 0;i<4+img->num_blk8x8_uv;i++)
12451 {
12452 for(j = 0;j<4;j++)
12453 for(k = 0;k<2;k++)
12454 memcpy(rdopt->cofAC[i][j][k], img->cofAC[i][j][k], 65 * sizeof(int));
12455 }
12456 for(i = 0;i<3;i++)
12457 for(k = 0;k<2;k++)
12458 memcpy(rdopt->cofDC[i][k], img->cofDC[i][k], 18 * sizeof(int));
12459 }
12460
12461
12462 memcpy(currMB->b8mode,b8mode, BLOCK_MULTIPLE * sizeof(int));
12463 memcpy(currMB->b8pdir,b8pdir, BLOCK_MULTIPLE * sizeof(int));
12464 if(img->MbaffFrameFlag)
12465 {
12466 memcpy(rdopt->b8mode,b8mode, BLOCK_MULTIPLE * sizeof(int));
12467 memcpy(rdopt->b8pdir,b8pdir, BLOCK_MULTIPLE * sizeof(int));
12468 }
12469
12470 currMB->bi_pred_me = currMB->mb_type == 1 ? bi_pred_me : 0;
12471
12472
12473 //if P8x8 mode and transform size 4x4 choosen, restore motion vector data for this transform size
12474 if (mode == P8x8 && !luma_transform_size_8x8_flag && input->Transform8x8Mode)
12475 RestoreMV8x8(1);
12476
12477 //==== transform size flag ====
12478 if (((currMB->cbp & 15) == 0) && !(IS_OLDINTRA(currMB) || currMB->mb_type == I8MB))
12479 currMB->luma_transform_size_8x8_flag = 0;
12480 else
12481 currMB->luma_transform_size_8x8_flag = luma_transform_size_8x8_flag;
12482
12483 rdopt->luma_transform_size_8x8_flag = currMB->luma_transform_size_8x8_flag;
12484
12485 if (input->rdopt==3 && img->type!=B_SLICE)
12486 {
12487 //! save the MB Mode of every macroblock
12488 decs->dec_mb_mode[img->mb_y][img->mb_x] = mode;
12489 }
12490
12491 //==== reference frames =====
12492 for (j = 0; j < 4; j++)
12493 {
12494 block_y = img->block_y + j;
12495 for (i = 0; i < 4; i++)
12496 {
12497 block_x = img->block_x + i;
12498 k = 2*(j >> 1)+(i >> 1);
12499
12500 // backward prediction or intra
12501 if ((currMB->b8pdir[k] == 1) || IS_INTRA(currMB))
12502 {
12503 enc_picture->ref_idx [LIST_0][block_y][block_x] = -1;
12504 enc_picture->ref_pic_id [LIST_0][block_y][block_x] = -1;
12505 enc_picture->mv [LIST_0][block_y][block_x][0] = 0;
12506 enc_picture->mv [LIST_0][block_y][block_x][1] = 0;
12507 if(img->MbaffFrameFlag)
12508 rdopt->refar[LIST_0][j][i] = -1;
12509 }
12510 else
12511 {
12512 if (currMB->bi_pred_me && (currMB->b8pdir[k] == 2) && currMB->mb_type==1)
12513 {
12514 cur_mv = currMB->bi_pred_me == 1
12515 ? img->bipred_mv1[j][i][LIST_0][0][currMB->b8mode[k]]
12516 : img->bipred_mv2[j][i][LIST_0][0][currMB->b8mode[k]];
12517
12518 enc_picture->ref_idx [LIST_0][block_y][block_x] = 0;
12519 enc_picture->ref_pic_id [LIST_0][block_y][block_x] = enc_picture->ref_pic_num[LIST_0 + currMB->list_offset][0];
12520 enc_picture->mv [LIST_0][block_y][block_x][0] = cur_mv[0];
12521 enc_picture->mv [LIST_0][block_y][block_x][1] = cur_mv[1];
12522 if(img->MbaffFrameFlag)
12523 rdopt->refar[LIST_0][j][i] = 0;
12524 }
12525 else
12526 {
12527 cur_mv = img->all_mv[j][i][LIST_0][(short)frefframe[j][i]][currMB->b8mode[k]];
12528
12529 enc_picture->ref_idx [LIST_0][block_y][block_x] = frefframe[j][i];
12530 enc_picture->ref_pic_id [LIST_0][block_y][block_x] = enc_picture->ref_pic_num[LIST_0 + currMB->list_offset][(short)frefframe[j][i]];
12531 enc_picture->mv [LIST_0][block_y][block_x][0] = cur_mv[0];
12532 enc_picture->mv [LIST_0][block_y][block_x][1] = cur_mv[1];
12533 if(img->MbaffFrameFlag)
12534 rdopt->refar[LIST_0][j][i] = frefframe[j][i];
12535 }
12536 }
12537
12538 // forward prediction or intra
12539 if ((currMB->b8pdir[k] == 0) || IS_INTRA(currMB))
12540 {
12541 enc_picture->ref_idx [LIST_1][block_y][block_x] = -1;
12542 enc_picture->ref_pic_id [LIST_1][block_y][block_x] = -1;
12543 enc_picture->mv [LIST_1][block_y][block_x][0] = 0;
12544 enc_picture->mv [LIST_1][block_y][block_x][1] = 0;
12545 if(img->MbaffFrameFlag)
12546 rdopt->refar[LIST_1][j][i] = -1;
12547 }
12548 }
12549 }
12550
12551 if (bframe)
12552 {
12553 for (j=0; j<4; j++)
12554 {
12555 block_y = img->block_y + j;
12556 for (i=0; i<4; i++)
12557 {
12558 block_x = img->block_x + i;
12559 k = 2*(j >> 1)+(i >> 1);
12560
12561 // forward
12562 if (IS_INTRA(currMB)||(currMB->b8pdir[k] == 0))
12563 {
12564 enc_picture->ref_idx [LIST_1][block_y][block_x] = -1;
12565 enc_picture->ref_pic_id [LIST_1][block_y][block_x] = -1;
12566 enc_picture->mv [LIST_1][block_y][block_x][0] = 0;
12567 enc_picture->mv [LIST_1][block_y][block_x][1] = 0;
12568 if(img->MbaffFrameFlag)
12569 rdopt->refar[LIST_1][j][i] = -1;
12570 }
12571 else
12572 {
12573 if (currMB->bi_pred_me && (currMB->b8pdir[k] == 2) && currMB->mb_type==1)
12574 {
12575 cur_mv = currMB->bi_pred_me == 1
12576 ? img->bipred_mv1[j][i][LIST_1][0][currMB->b8mode[k]]
12577 : img->bipred_mv2[j][i][LIST_1][0][currMB->b8mode[k]];
12578
12579 enc_picture->ref_idx [LIST_1][block_y][block_x] = 0;
12580 enc_picture->ref_pic_id [LIST_1][block_y][block_x] = enc_picture->ref_pic_num[LIST_1 + currMB->list_offset][0];
12581 enc_picture->mv [LIST_1][block_y][block_x][0] = cur_mv[0];
12582 enc_picture->mv [LIST_1][block_y][block_x][1] = cur_mv[1];
12583 if(img->MbaffFrameFlag)
12584 rdopt->refar[LIST_1][j][i] = 0;
12585 }
12586 else
12587 {
12588 cur_mv = img->all_mv[j][i][LIST_1][(short)brefframe[j][i]][currMB->b8mode[k]];
12589
12590 enc_picture->ref_idx [LIST_1][block_y][block_x] = brefframe[j][i];
12591 enc_picture->ref_pic_id [LIST_1][block_y][block_x] = enc_picture->ref_pic_num[LIST_1 + currMB->list_offset][(short)brefframe[j][i]];
12592 enc_picture->mv [LIST_1][block_y][block_x][0] = cur_mv[0];
12593 enc_picture->mv [LIST_1][block_y][block_x][1] = cur_mv[1];
12594 if(img->MbaffFrameFlag)
12595 rdopt->refar[LIST_1][j][i] = brefframe[j][i];
12596 }
12597 }
12598 }
12599 }
12600 }
12601
12602 //==== intra prediction modes ====
12603 currMB->c_ipred_mode = best_c_imode;
12604 img->i16offset = best_i16offset;
12605
12606 if(currMB->mb_type == I8MB)
12607 {
12608 memcpy(currMB->intra_pred_modes8x8,b8_intra_pred_modes8x8, MB_BLOCK_PARTITIONS * sizeof(char));
12609 memcpy(currMB->intra_pred_modes,b8_intra_pred_modes8x8, MB_BLOCK_PARTITIONS * sizeof(char));
12610 for(j = 0; j < BLOCK_MULTIPLE; j++)
12611 {
12612 memcpy(&img->ipredmode[img->block_y+j][img->block_x],b8_ipredmode8x8[j], BLOCK_MULTIPLE * sizeof(char));
12613 memcpy(&img->ipredmode8x8[img->block_y+j][img->block_x], b8_ipredmode8x8[j], BLOCK_MULTIPLE * sizeof(char));
12614 }
12615 }
12616 else if (mode!=I4MB && mode!=I8MB)
12617 {
12618 memset(currMB->intra_pred_modes,DC_PRED, MB_BLOCK_PARTITIONS * sizeof(char));
12619 for(j = img->block_y; j < img->block_y + BLOCK_MULTIPLE; j++)
12620 memset(&img->ipredmode[j][img->block_x], DC_PRED, BLOCK_MULTIPLE * sizeof(char));
12621 }
12622 // Residue Color Transform
12623 else if (mode == I4MB)
12624 {
12625 memcpy(currMB->intra_pred_modes,b4_intra_pred_modes, MB_BLOCK_PARTITIONS * sizeof(char));
12626 for(j = 0; j < BLOCK_MULTIPLE; j++)
12627 memcpy(&img->ipredmode[img->block_y + j][img->block_x],&b4_ipredmode[BLOCK_MULTIPLE * j], BLOCK_MULTIPLE * sizeof(char));
12628 }
12629
12630 if(img->MbaffFrameFlag)
12631 {
12632 rdopt->c_ipred_mode = currMB->c_ipred_mode;
12633 rdopt->i16offset = img->i16offset;
12634 memcpy(rdopt->intra_pred_modes,currMB->intra_pred_modes, MB_BLOCK_PARTITIONS * sizeof(char));
12635 memcpy(rdopt->intra_pred_modes8x8,currMB->intra_pred_modes8x8, MB_BLOCK_PARTITIONS * sizeof(char));
12636 for(j = img->block_y; j < img->block_y +BLOCK_MULTIPLE; j++)
12637 memcpy(&rdopt->ipredmode[j][img->block_x],&ipredmodes[j][img->block_x], BLOCK_MULTIPLE * sizeof(char));
12638 }
12639
12640 //==== motion vectors =====
12641 SetMotionVectorsMB (currMB, bframe);
12642}
12643
12644
12645
12646/*!
12647 *************************************************************************************
12648 * \brief
12649 * Set reference frames and motion vectors
12650 *************************************************************************************
12651 */
12652void SetRefAndMotionVectors (int block, int mode, int pdir, int fwref, int bwref)
12653{
12654 int i, j=0;
12655 int bslice = (img->type==B_SLICE);
12656 int pmode = (mode==1||mode==2||mode==3?mode:4);
12657 int j0 = ((block >> 1)<<1);
12658 int i0 = ((block & 0x01)<<1);
12659 int j1 = j0 + (input->part_size[pmode][1]);
12660 int i1 = i0 + (input->part_size[pmode][0]);
12661 int block_x, block_y;
12662 short *cur_mv;
12663 Macroblock *currMB = &img->mb_data[img->current_mb_nr];
12664
12665 if (pdir<0)
12666 {
12667 for (j = img->block_y + j0; j < img->block_y + j1; j++)
12668 {
12669 for (i=img->block_x + i0; i<img->block_x +i1; i++)
12670 {
12671 enc_picture->ref_pic_id[LIST_0][j][i] = -1;
12672 enc_picture->ref_pic_id[LIST_1][j][i] = -1;
12673 }
12674 memset(&enc_picture->ref_idx[LIST_0][j][img->block_x + i0], -1, (input->part_size[pmode][0]) * sizeof(char));
12675 memset(&enc_picture->ref_idx[LIST_1][j][img->block_x + i0], -1, (input->part_size[pmode][0]) * sizeof(char));
12676 memset(enc_picture->mv[LIST_0][j][img->block_x + i0], 0, 2*(input->part_size[pmode][0]) * sizeof(short));
12677 memset(enc_picture->mv[LIST_1][j][img->block_x + i0], 0, 2*(input->part_size[pmode][0]) * sizeof(short));
12678 }
12679 return;
12680 }
12681
12682 if (!bslice)
12683 {
12684 for (j=j0; j<j1; j++)
12685 {
12686 block_y = img->block_y + j;
12687 memset(&enc_picture->ref_idx [LIST_0][block_y][img->block_x + i0], fwref, (input->part_size[pmode][0]) * sizeof(char));
12688 for (i=i0; i<i1; i++)
12689 {
12690 block_x = img->block_x + i;
12691 cur_mv = img->all_mv[j][i][LIST_0][fwref][mode];
12692 enc_picture->mv [LIST_0][block_y][block_x][0] = cur_mv[0];
12693 enc_picture->mv [LIST_0][block_y][block_x][1] = cur_mv[1];
12694 enc_picture->ref_pic_id[LIST_0][block_y][block_x] = enc_picture->ref_pic_num[LIST_0+currMB->list_offset][fwref];
12695 }
12696 }
12697 return;
12698 }
12699 else
12700 {
12701 for (j=j0; j<j1; j++)
12702 {
12703 block_y = img->block_y + j;
12704 for (i=i0; i<i1; i++)
12705 {
12706 block_x = img->block_x + i;
12707 if (mode==0)
12708 {
12709 pdir = direct_pdir[block_y][block_x];
12710 fwref = direct_ref_idx[LIST_0][block_y][block_x];
12711 bwref = direct_ref_idx[LIST_1][block_y][block_x];
12712 }
12713
12714 if ((pdir==0 || pdir==2))
12715 {
12716 if (currMB->bi_pred_me && (pdir == 2) && mode == 1)
12717 {
12718 cur_mv = currMB->bi_pred_me == 1
12719 ? img->bipred_mv1[j][i][LIST_0][0][mode]
12720 : img->bipred_mv2[j][i][LIST_0][0][mode];
12721
12722 enc_picture->mv [LIST_0][block_y][block_x][0] = cur_mv[0];
12723 enc_picture->mv [LIST_0][block_y][block_x][1] = cur_mv[1];
12724 enc_picture->ref_idx [LIST_0][block_y][block_x] = 0;
12725 enc_picture->ref_pic_id[LIST_0][block_y][block_x] = enc_picture->ref_pic_num[LIST_0+currMB->list_offset][0];
12726 }
12727 else
12728 {
12729 cur_mv = img->all_mv[j][i][LIST_0][fwref][mode];
12730
12731 enc_picture->mv [LIST_0][block_y][block_x][0] = cur_mv[0];
12732 enc_picture->mv [LIST_0][block_y][block_x][1] = cur_mv[1];
12733 enc_picture->ref_idx [LIST_0][block_y][block_x] = fwref;
12734 enc_picture->ref_pic_id[LIST_0][block_y][block_x] =
12735 enc_picture->ref_pic_num[LIST_0+currMB->list_offset][(short)enc_picture->ref_idx[LIST_0][block_y][block_x]];
12736 }
12737 }
12738 else
12739 {
12740 enc_picture->mv [LIST_0][block_y][block_x][0] = 0;
12741 enc_picture->mv [LIST_0][block_y][block_x][1] = 0;
12742 enc_picture->ref_idx [LIST_0][block_y][block_x] = -1;
12743 enc_picture->ref_pic_id[LIST_0][block_y][block_x] = -1;
12744 }
12745
12746 if ((pdir==1 || pdir==2))
12747 {
12748 if (currMB->bi_pred_me && (pdir == 2) && mode == 1)
12749 {
12750 cur_mv = currMB->bi_pred_me == 1
12751 ? img->bipred_mv1[j][i][LIST_1][0][mode]
12752 : img->bipred_mv2[j][i][LIST_1][0][mode];
12753
12754 enc_picture->mv [LIST_1][block_y][block_x][0] = cur_mv[0];
12755 enc_picture->mv [LIST_1][block_y][block_x][1] = cur_mv[1];
12756 enc_picture->ref_idx [LIST_1][block_y][block_x] = 0;
12757 enc_picture->ref_pic_id[LIST_1][block_y][block_x] = enc_picture->ref_pic_num[LIST_1+currMB->list_offset][0];
12758 }
12759 else
12760 {
12761 cur_mv = img->all_mv[j][i][LIST_1][bwref][mode];
12762
12763 enc_picture->mv [LIST_1][block_y][block_x][0] = cur_mv[0];
12764 enc_picture->mv [LIST_1][block_y][block_x][1] = cur_mv[1];
12765 enc_picture->ref_idx [LIST_1][block_y][block_x] = bwref;
12766 enc_picture->ref_pic_id[LIST_1][block_y][block_x] =
12767 enc_picture->ref_pic_num[LIST_1+currMB->list_offset][(short)enc_picture->ref_idx[LIST_1][block_y][block_x]];
12768 }
12769 }
12770 else
12771 {
12772 enc_picture->mv [LIST_1][block_y][block_x][0] = 0;
12773 enc_picture->mv [LIST_1][block_y][block_x][1] = 0;
12774 enc_picture->ref_idx [LIST_1][block_y][block_x] = -1;
12775 enc_picture->ref_pic_id[LIST_1][block_y][block_x] = -1;
12776 }
12777 }
12778 }
12779 }
12780}
12781
12782/*!
12783 *************************************************************************************
12784 * \brief
12785 * skip macroblock field inference
12786 * \return
12787 * inferred field flag
12788 *************************************************************************************
12789 */
12790int field_flag_inference()
12791{
12792 int mb_field;
12793 Macroblock *currMB = &img->mb_data[img->current_mb_nr];
12794
12795 if (currMB->mbAvailA)
12796 {
12797 mb_field = img->mb_data[currMB->mbAddrA].mb_field;
12798 }
12799 else
12800 {
12801 // check top macroblock pair
12802 if (currMB->mbAvailB)
12803 mb_field = img->mb_data[currMB->mbAddrB].mb_field;
12804 else
12805 mb_field = 0;
12806 }
12807
12808 return mb_field;
12809}
12810
12811/*!
12812 *************************************************************************************
12813 * \brief
12814 * Store motion vectors for 8x8 partition
12815 *************************************************************************************
12816 */
12817
12818void StoreMVBlock8x8(int dir, int block8x8, int mode, int ref, int bw_ref, int pdir8, int bframe)
12819{
12820 int i, j, i0, j0, ii, jj;
12821 short ******all_mv = img->all_mv;
12822 short ******pred_mv = img->pred_mv;
12823 short (*lc_l0_mv8x8)[4][2] = all_mv8x8[dir][LIST_0];
12824 short (*lc_l1_mv8x8)[4][2] = all_mv8x8[dir][LIST_1];
12825 short (*lc_pr_mv8x8)[4][2] = NULL;
12826
12827 i0 = (block8x8 & 0x01) << 1;
12828 j0 = (block8x8 >> 1) << 1;
12829 ii = i0+2;
12830 jj = j0+2;
12831
12832 if (!bframe)
12833 {
12834 if (pdir8>=0) //(mode8!=IBLOCK)&&(mode8!=I16MB)) // && ref != -1)
12835 {
12836 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_0];
12837 for (j=j0; j<jj; j++)
12838 for (i=i0; i<ii; i++)
12839 {
12840 lc_l0_mv8x8[j][i][0] = all_mv [j][i][LIST_0][ref][4][0];
12841 lc_l0_mv8x8[j][i][1] = all_mv [j][i][LIST_0][ref][4][1];
12842 lc_pr_mv8x8[j][i][0] = pred_mv[j][i][LIST_0][ref][4][0];
12843 lc_pr_mv8x8[j][i][1] = pred_mv[j][i][LIST_0][ref][4][1];
12844 }
12845 }
12846 }
12847 else
12848 {
12849 if (pdir8 == 0) // list0
12850 {
12851 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_0];
12852 for (j=j0; j<jj; j++)
12853 for (i=i0; i<ii; i++)
12854 {
12855 lc_l0_mv8x8[j][i][0] = all_mv [j][i][LIST_0][ref][mode][0];
12856 lc_l0_mv8x8[j][i][1] = all_mv [j][i][LIST_0][ref][mode][1];
12857 lc_pr_mv8x8[j][i][0] = pred_mv[j][i][LIST_0][ref][mode][0];
12858 lc_pr_mv8x8[j][i][1] = pred_mv[j][i][LIST_0][ref][mode][1];
12859 }
12860 }
12861 else if (pdir8 == 1) // list1
12862 {
12863 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_1];
12864 for (j=j0; j<jj; j++)
12865 for (i=i0; i<ii; i++)
12866 {
12867 lc_l1_mv8x8[j][i][0] = all_mv [j][i][LIST_1][bw_ref][mode][0];
12868 lc_l1_mv8x8[j][i][1] = all_mv [j][i][LIST_1][bw_ref][mode][1];
12869 lc_pr_mv8x8[j][i][0] = pred_mv[j][i][LIST_1][bw_ref][mode][0];
12870 lc_pr_mv8x8[j][i][1] = pred_mv[j][i][LIST_1][bw_ref][mode][1];
12871 }
12872 }
12873 else if (pdir8==2) // bipred
12874 {
12875 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_0];
12876 for (j=j0; j<jj; j++)
12877 {
12878 for (i=i0; i<ii; i++)
12879 {
12880 lc_l0_mv8x8[j][i][0] = all_mv [j][i][LIST_0][ref][mode][0];
12881 lc_l0_mv8x8[j][i][1] = all_mv [j][i][LIST_0][ref][mode][1];
12882 lc_pr_mv8x8[j][i][0] = pred_mv[j][i][LIST_0][ref][mode][0];
12883 lc_pr_mv8x8[j][i][1] = pred_mv[j][i][LIST_0][ref][mode][1];
12884 }
12885 }
12886 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_1];
12887 for (j=j0; j<jj; j++)
12888 {
12889 for (i=i0; i<ii; i++)
12890 {
12891 lc_l1_mv8x8[j][i][0] = all_mv [j][i][LIST_1][bw_ref][mode][0];
12892 lc_l1_mv8x8[j][i][1] = all_mv [j][i][LIST_1][bw_ref][mode][1];
12893 lc_pr_mv8x8[j][i][0] = pred_mv[j][i][LIST_1][bw_ref][mode][0];
12894 lc_pr_mv8x8[j][i][1] = pred_mv[j][i][LIST_1][bw_ref][mode][1];
12895 }
12896 }
12897 }
12898 else
12899 {
12900 error("invalid direction mode", 255);
12901 }
12902 }
12903}
12904
12905
12906
12907/*!
12908 *************************************************************************************
12909 * \brief
12910 * Store motion vectors of 8x8 partitions of one macroblock
12911 *************************************************************************************
12912 */
12913void StoreMV8x8(int dir)
12914{
12915 int block8x8;
12916
12917 int bframe = (img->type == B_SLICE);
12918
12919 for (block8x8=0; block8x8<4; block8x8++)
12920 StoreMVBlock8x8(dir, block8x8, tr8x8.part8x8mode[block8x8], tr8x8.part8x8fwref[block8x8],
12921 tr8x8.part8x8bwref[block8x8], tr8x8.part8x8pdir[block8x8], bframe);
12922}
12923
12924/*!
12925*************************************************************************************
12926* \brief
12927* Restore motion vectors for 8x8 partition
12928*************************************************************************************
12929*/
12930void RestoreMVBlock8x8(int dir, int block8x8, RD_8x8DATA tr, int bframe)
12931{
12932 int i, j, i0, j0, ii, jj;
12933 short ******all_mv = img->all_mv;
12934 short ******pred_mv = img->pred_mv;
12935 short (*lc_l0_mv8x8)[4][2] = all_mv8x8[dir][LIST_0];
12936 short (*lc_l1_mv8x8)[4][2] = all_mv8x8[dir][LIST_1];
12937 short (*lc_pr_mv8x8)[4][2] = NULL;
12938
12939 short pdir8 = tr.part8x8pdir [block8x8];
12940 short mode = tr.part8x8mode [block8x8];
12941 short ref = tr.part8x8fwref[block8x8];
12942 short bw_ref = tr.part8x8bwref[block8x8];
12943
12944 i0 = (block8x8 & 0x01) << 1;
12945 j0 = (block8x8 >> 1) << 1;
12946 ii = i0+2;
12947 jj = j0+2;
12948
12949 if (!bframe)
12950 {
12951 if (pdir8>=0) //(mode8!=IBLOCK)&&(mode8!=I16MB)) // && ref != -1)
12952 {
12953 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_0];
12954 for (j=j0; j<jj; j++)
12955 for (i=i0; i<ii; i++)
12956 {
12957 all_mv [j][i][LIST_0][ref][4][0] = lc_l0_mv8x8[j][i][0] ;
12958 all_mv [j][i][LIST_0][ref][4][1] = lc_l0_mv8x8[j][i][1] ;
12959 pred_mv[j][i][LIST_0][ref][4][0] = lc_pr_mv8x8[j][i][0];
12960 pred_mv[j][i][LIST_0][ref][4][1] = lc_pr_mv8x8[j][i][1];
12961 }
12962 }
12963 }
12964 else
12965 {
12966 if (pdir8==0) // forward
12967 {
12968 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_0];
12969 for (j=j0; j<jj; j++)
12970 {
12971 for (i=i0; i<ii; i++)
12972 {
12973 all_mv [j][i][LIST_0][ref][mode][0] = lc_l0_mv8x8[j][i][0] ;
12974 all_mv [j][i][LIST_0][ref][mode][1] = lc_l0_mv8x8[j][i][1] ;
12975 pred_mv[j][i][LIST_0][ref][mode][0] = lc_pr_mv8x8[j][i][0];
12976 pred_mv[j][i][LIST_0][ref][mode][1] = lc_pr_mv8x8[j][i][1];
12977 }
12978 }
12979 }
12980 else if (pdir8==1) // backward
12981 {
12982 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_1];
12983 for (j=j0; j<jj; j++)
12984 {
12985 for (i=i0; i<ii; i++)
12986 {
12987 all_mv [j][i][LIST_1][bw_ref][mode][0] = lc_l1_mv8x8[j][i][0] ;
12988 all_mv [j][i][LIST_1][bw_ref][mode][1] = lc_l1_mv8x8[j][i][1] ;
12989 pred_mv[j][i][LIST_1][bw_ref][mode][0] = lc_pr_mv8x8[j][i][0];
12990 pred_mv[j][i][LIST_1][bw_ref][mode][1] = lc_pr_mv8x8[j][i][1];
12991 }
12992 }
12993 }
12994 else if (pdir8==2) // bidir
12995 {
12996 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_0];
12997 for (j=j0; j<jj; j++)
12998 {
12999 for (i=i0; i<ii; i++)
13000 {
13001 all_mv [j][i][LIST_0][ref][mode][0] = lc_l0_mv8x8[j][i][0] ;
13002 all_mv [j][i][LIST_0][ref][mode][1] = lc_l0_mv8x8[j][i][1] ;
13003 pred_mv[j][i][LIST_0][ref][mode][0] = lc_pr_mv8x8[j][i][0];
13004 pred_mv[j][i][LIST_0][ref][mode][1] = lc_pr_mv8x8[j][i][1];
13005 }
13006 }
13007 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_1];
13008 for (j=j0; j<jj; j++)
13009 {
13010 for (i=i0; i<ii; i++)
13011 {
13012 all_mv [j][i][LIST_1][bw_ref][mode][0] = lc_l1_mv8x8[j][i][0] ;
13013 all_mv [j][i][LIST_1][bw_ref][mode][1] = lc_l1_mv8x8[j][i][1] ;
13014 pred_mv[j][i][LIST_1][bw_ref][mode][0] = lc_pr_mv8x8[j][i][0];
13015 pred_mv[j][i][LIST_1][bw_ref][mode][1] = lc_pr_mv8x8[j][i][1];
13016 }
13017 }
13018 }
13019 else
13020 {
13021 error("invalid direction mode", 255);
13022 }
13023 }
13024}
13025
13026/*!
13027 *************************************************************************************
13028 * \brief
13029 * Restore motion vectors of 8x8 partitions of one macroblock
13030 *************************************************************************************
13031 */
13032void RestoreMV8x8(int dir)
13033{
13034 int block8x8;
13035
13036 int bframe = (img->type == B_SLICE);
13037
13038 for (block8x8=0; block8x8<4; block8x8++)
13039 RestoreMVBlock8x8(dir, block8x8, tr8x8, bframe);
13040}
13041
13042
13043/*!
13044 *************************************************************************************
13045 * \brief
13046 * Store predictors for 8x8 partition
13047 *************************************************************************************
13048 */
13049
13050void StoreNewMotionVectorsBlock8x8(int dir, int block8x8, int mode, int fw_ref, int bw_ref, int pdir8, int bframe)
13051{
13052 int i, j, i0, j0, ii, jj;
13053 short ******all_mv = img->all_mv;
13054 short ******pred_mv = img->pred_mv;
13055 short (*lc_l0_mv8x8)[4][2] = all_mv8x8[dir][LIST_0];
13056 short (*lc_l1_mv8x8)[4][2] = all_mv8x8[dir][LIST_1];
13057 short (*lc_pr_mv8x8)[4][2] = NULL;
13058
13059 i0 = (block8x8 & 0x01) << 1;
13060 j0 = (block8x8 >> 1) << 1;
13061 ii = i0+2;
13062 jj = j0+2;
13063
13064 if (pdir8<0)
13065 {
13066 for (j=j0; j<jj; j++)
13067 {
13068 memset(&lc_l0_mv8x8[j][i0], 0, 4 * sizeof(short));
13069 memset(&lc_l1_mv8x8[j][i0], 0, 4 * sizeof(short));
13070 }
13071 return;
13072 }
13073
13074 if (!bframe)
13075 {
13076
13077 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_0];
13078 for (j=j0; j<jj; j++)
13079 {
13080 for (i=i0; i<ii; i++)
13081 {
13082 lc_l0_mv8x8[j][i][0] = all_mv [j][i][LIST_0][fw_ref][4][0];
13083 lc_l0_mv8x8[j][i][1] = all_mv [j][i][LIST_0][fw_ref][4][1];
13084 lc_pr_mv8x8[j][i][0] = pred_mv[j][i][LIST_0][fw_ref][4][0];
13085 lc_pr_mv8x8[j][i][1] = pred_mv[j][i][LIST_0][fw_ref][4][1];
13086 }
13087 memset(&lc_l1_mv8x8[j][i0], 0, 4 * sizeof(short));
13088 }
13089 return;
13090 }
13091 else
13092 {
13093 if ((pdir8==0 || pdir8==2))
13094 {
13095 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_0];
13096
13097 for (j=j0; j<jj; j++)
13098 for (i=i0; i<ii; i++)
13099 {
13100 lc_l0_mv8x8[j][i][0] = all_mv [j][i][LIST_0][fw_ref][mode][0];
13101 lc_l0_mv8x8[j][i][1] = all_mv [j][i][LIST_0][fw_ref][mode][1];
13102 lc_pr_mv8x8[j][i][0] = pred_mv[j][i][LIST_0][fw_ref][mode][0];
13103 lc_pr_mv8x8[j][i][1] = pred_mv[j][i][LIST_0][fw_ref][mode][1];
13104 }
13105 }
13106 else
13107 {
13108 for (j=j0; j<jj; j++)
13109 memset(&lc_l0_mv8x8[j][i0], 0, 4 * sizeof(short));
13110 }
13111
13112 if ((pdir8==1 || pdir8==2))
13113 {
13114 lc_pr_mv8x8 = pred_mv8x8[dir][LIST_1];
13115
13116 for (j=j0; j<jj; j++)
13117 for (i=i0; i<ii; i++)
13118 {
13119 lc_l1_mv8x8[j][i][0] = all_mv [j][i][LIST_1][bw_ref][mode][0];
13120 lc_l1_mv8x8[j][i][1] = all_mv [j][i][LIST_1][bw_ref][mode][1];
13121 lc_pr_mv8x8[j][i][0] = pred_mv[j][i][LIST_1][bw_ref][mode][0];
13122 lc_pr_mv8x8[j][i][1] = pred_mv[j][i][LIST_1][bw_ref][mode][1];
13123 }
13124 }
13125 else
13126 {
13127 for (j=j0; j<jj; j++)
13128 memset(&lc_l1_mv8x8[j][i0], 0, 4 * sizeof(short));
13129 }
13130 }
13131}
13132
13133/*!
13134 ************************************************************************
13135 * \brief
13136 * Makes the decision if 8x8 tranform will be used (for RD-off)
13137 ************************************************************************
13138 */
13139int GetBestTransformP8x8()
13140{
13141 int block_y, block_x, pic_pix_y, pic_pix_x, i, j, k;
13142 int mb_y, mb_x, block8x8;
13143 int cost8x8=0, cost4x4=0;
13144 int *diff_ptr;
13145
13146 if(input->Transform8x8Mode==2) //always allow 8x8 transform
13147 return 1;
13148
13149 for (block8x8=0; block8x8<4; block8x8++)
13150 {
13151 mb_y = (block8x8 >> 1) << 3;
13152 mb_x = (block8x8 & 0x01) << 3;
13153 //===== loop over 4x4 blocks =====
13154 k=0;
13155 for (block_y=mb_y; block_y<mb_y+8; block_y+=4)
13156 {
13157 pic_pix_y = img->opix_y + block_y;
13158
13159 //get cost for transform size 4x4
13160 for (block_x=mb_x; block_x<mb_x+8; block_x+=4)
13161 {
13162 pic_pix_x = img->opix_x + block_x;
13163
13164 //===== get displaced frame difference ======
13165 diff_ptr=&diff4x4[k];
13166 for (j=0; j<4; j++)
13167 {
13168 for (i=0; i<4; i++, k++)
13169 {
13170 //4x4 transform size
13171 diff4x4[k] = imgY_org[pic_pix_y+j][pic_pix_x+i] - tr4x4.mpr8x8[j+block_y][i+block_x];
13172 //8x8 transform size
13173 diff8x8[k] = imgY_org[pic_pix_y+j][pic_pix_x+i] - tr8x8.mpr8x8[j+block_y][i+block_x];
13174 }
13175 }
13176
13177 cost4x4 += distortion4x4 (diff_ptr);
13178 }
13179 }
13180 cost8x8 += distortion8x8 (diff8x8);
13181 }
13182 return (cost8x8 < cost4x4);
13183}
13184
13185/*!
13186************************************************************************
13187* \brief
13188* Sets MBAFF RD parameters
13189************************************************************************
13190*/
13191void set_mbaff_parameters()
13192{
13193 int i, j, k;
13194 Macroblock *currMB = &img->mb_data[img->current_mb_nr];
13195 int mode = best_mode;
13196 int bframe = (img->type==B_SLICE);
13197 signed char **ipredmodes = img->ipredmode;
13198
13199
13200 //===== reconstruction values =====
13201 for (j=0; j < MB_BLOCK_SIZE; j++)
13202 memcpy(rdopt->rec_mbY[j],&enc_picture->imgY[img->pix_y + j][img->pix_x], MB_BLOCK_SIZE * sizeof(imgpel));
13203
13204 if (img->yuv_format != YUV400)
13205 {
13206 for (j=0; j<img->mb_cr_size_y; j++)
13207 {
13208 memcpy(rdopt->rec_mbU[j],&enc_picture->imgUV[0][img->pix_c_y + j][img->pix_c_x], img->mb_cr_size_x * sizeof(imgpel));
13209 memcpy(rdopt->rec_mbV[j],&enc_picture->imgUV[1][img->pix_c_y + j][img->pix_c_x], img->mb_cr_size_x * sizeof(imgpel));
13210 }
13211 }
13212
13213 //===== coefficients and cbp =====
13214 rdopt->mode = mode;
13215 rdopt->i16offset = img->i16offset;
13216 rdopt->cbp = currMB->cbp;
13217 rdopt->cbp_blk = currMB->cbp_blk;
13218 rdopt->mb_type = currMB->mb_type;
13219
13220 rdopt->luma_transform_size_8x8_flag = currMB->luma_transform_size_8x8_flag;
13221
13222 if(rdopt->mb_type == 0 && mode != 0)
13223 {
13224 mode=0;
13225 rdopt->mode=0;
13226 }
13227
13228 for(i=0;i<4+img->num_blk8x8_uv;i++)
13229 {
13230 for(j=0;j<4;j++)
13231 for(k=0;k<2;k++)
13232 memcpy(rdopt->cofAC[i][j][k], img->cofAC[i][j][k], 65 * sizeof(int));
13233 }
13234
13235 for(i=0;i<3;i++)
13236 {
13237 for(k=0;k<2;k++)
13238 memcpy(rdopt->cofDC[i][k], img->cofDC[i][k], 18 * sizeof(int));
13239 }
13240
13241 memcpy(rdopt->b8mode,currMB->b8mode, BLOCK_MULTIPLE * sizeof(int));
13242 memcpy(rdopt->b8pdir,currMB->b8pdir, BLOCK_MULTIPLE * sizeof(int));
13243
13244 //==== reference frames =====
13245 if (bframe)
13246 {
13247 for (j = 0; j < BLOCK_MULTIPLE; j++)
13248 {
13249 memcpy(rdopt->refar[LIST_0][j],&enc_picture->ref_idx[LIST_0][img->block_y + j][img->block_x] , BLOCK_MULTIPLE * sizeof(char));
13250 memcpy(rdopt->refar[LIST_1][j],&enc_picture->ref_idx[LIST_1][img->block_y + j][img->block_x] , BLOCK_MULTIPLE * sizeof(char));
13251 }
13252 rdopt->bi_pred_me = currMB->bi_pred_me;
13253 }
13254 else
13255 {
13256 for (j = 0; j < BLOCK_MULTIPLE; j++)
13257 memcpy(rdopt->refar[LIST_0][j],&enc_picture->ref_idx[LIST_0][img->block_y + j][img->block_x] , BLOCK_MULTIPLE * sizeof(char));
13258 }
13259
13260 memcpy(rdopt->intra_pred_modes,currMB->intra_pred_modes, MB_BLOCK_PARTITIONS * sizeof(char));
13261 memcpy(rdopt->intra_pred_modes8x8,currMB->intra_pred_modes8x8, MB_BLOCK_PARTITIONS * sizeof(char));
13262 for (j = img->block_y; j < img->block_y + 4; j++)
13263 {
13264 memcpy(&rdopt->ipredmode[j][img->block_x],&ipredmodes[j][img->block_x], BLOCK_MULTIPLE * sizeof(char));
13265 }
13266}
13267
13268/*!
13269************************************************************************
13270* \brief
13271* store coding state (for rd-optimized mode decision), used for 8x8 transformation
13272************************************************************************
13273*/
13274void store_coding_state_cs_cm()
13275{
13276 store_coding_state(cs_cm);
13277}
13278
13279/*!
13280************************************************************************
13281* \brief
13282* restore coding state (for rd-optimized mode decision), used for 8x8 transformation
13283************************************************************************
13284*/
13285void reset_coding_state_cs_cm()
13286{
13287 reset_coding_state(cs_cm);
13288}
13289
13290/*!
13291************************************************************************
13292* \brief
13293* update rounding offsets based on JVT-N011
13294************************************************************************
13295*/
13296void update_offset_params(int mode, int luma_transform_size_8x8_flag)
13297{
13298 int is_inter = (mode != I4MB)&&(mode != I16MB) && (mode != I8MB);
13299 int luma_pos = AdaptRndPos[(is_inter<<1) + luma_transform_size_8x8_flag][img->type];
13300 int i,j;
13301 int temp = 0;
13302 int offsetRange = 1 << (OffsetBits - 1);
13303 int blk_mask = 0x03 + (luma_transform_size_8x8_flag<<2);
13304 int blk_shift = 2 + luma_transform_size_8x8_flag;
13305 short **offsetList = luma_transform_size_8x8_flag ? OffsetList8x8 : OffsetList4x4;
13306
13307 int **fAdjust = is_inter
13308 ? (luma_transform_size_8x8_flag ? bestInterFAdjust8x8 : bestInterFAdjust4x4)
13309 : (luma_transform_size_8x8_flag ? bestIntraFAdjust8x8 : bestIntraFAdjust4x4);
13310
13311 for (j=0; j < MB_BLOCK_SIZE; j++)
13312 {
13313 int j_pos = ((j & blk_mask)<<blk_shift);
13314 for (i=0; i < MB_BLOCK_SIZE; i++)
13315 {
13316 temp = j_pos + (i & blk_mask);
13317 offsetList[luma_pos][temp] += fAdjust[j][i];
13318 offsetList[luma_pos][temp] = iClip3(0,offsetRange,offsetList[luma_pos][temp]);
13319 }
13320 }
13321
13322 if (input->AdaptRndChroma)
13323 {
13324 int u_pos = AdaptRndCrPos[is_inter][img->type];
13325 int v_pos = u_pos + 1;
13326 int jpos;
13327
13328 int ***fAdjustCr = is_inter ? bestInterFAdjust4x4Cr : bestIntraFAdjust4x4Cr;
13329
13330 for (j=0; j < img->mb_cr_size_y; j++)
13331 {
13332 jpos = ((j & 0x03)<<2);
13333 for (i=0; i < img->mb_cr_size_x; i++)
13334 {
13335 temp = jpos + (i & 0x03);
13336 OffsetList4x4[u_pos][temp] += fAdjustCr[0][j][i];
13337 OffsetList4x4[u_pos][temp] = iClip3(0,offsetRange,OffsetList4x4[u_pos][temp]);
13338 OffsetList4x4[v_pos][temp] += fAdjustCr[1][j][i];
13339 OffsetList4x4[v_pos][temp] = iClip3(0,offsetRange,OffsetList4x4[v_pos][temp]);
13340 }
13341 }
13342 }
13343}
13344
13345void assign_enc_picture_params(int mode, signed char best_pdir, int block, int list_offset, int best_fw_ref, int best_bw_ref, int bframe)
13346{
13347 int i,j;
13348 int block_x, block_y;
13349 short *cur_mv;
13350
13351 if (mode==1)
13352 {
13353 if (best_pdir==1)
13354 {
13355 for (j=img->block_y+(block&2); j<img->block_y+(block&2) + BLOCK_MULTIPLE; j++)
13356 {
13357 block_x = img->block_x+(block&1)*2;
13358
13359 memset(&enc_picture->ref_idx[LIST_0][j][block_x], -1 , BLOCK_MULTIPLE * sizeof(char));
13360 memset(enc_picture->mv [LIST_0][j][block_x], 0 , 2 * BLOCK_MULTIPLE * sizeof(short));
13361 for (i=block_x; i<block_x + BLOCK_MULTIPLE; i++)
13362 {
13363 enc_picture->ref_pic_id [LIST_0][j][i] = -1;
13364 }
13365 }
13366 }
13367 else if (img->bi_pred_me[mode])
13368 {
13369 for (j=0; j<BLOCK_MULTIPLE; j++)
13370 {
13371 block_y = img->block_y+(block&2)+j;
13372 block_x = img->block_x+(block&1)*2;
13373 memset(&enc_picture->ref_idx[LIST_0][block_y][block_x], 0, BLOCK_MULTIPLE * sizeof(char));
13374 for (i=0; i<BLOCK_MULTIPLE; i++)
13375 {
13376 cur_mv = img->bi_pred_me[mode] == 1
13377 ? img->bipred_mv1[i][j][LIST_0][0][mode]
13378 : img->bipred_mv2[i][j][LIST_0][0][mode];
13379
13380 enc_picture->ref_pic_id [LIST_0][block_y][block_x + i] = enc_picture->ref_pic_num[LIST_0 + list_offset][0];
13381 enc_picture->mv [LIST_0][block_y][block_x + i][0] = cur_mv[0];
13382 enc_picture->mv [LIST_0][block_y][block_x + i][1] = cur_mv[1];
13383 }
13384 }
13385 }
13386 else
13387 {
13388 for (j=0; j<BLOCK_MULTIPLE; j++)
13389 {
13390 block_y = img->block_y+(block&2)+j;
13391 block_x = img->block_x+(block&1)*2;
13392 memset(&enc_picture->ref_idx[LIST_0][block_y][block_x], best_fw_ref , BLOCK_MULTIPLE * sizeof(char));
13393 for (i=0; i<BLOCK_MULTIPLE; i++)
13394 {
13395 cur_mv = img->all_mv[j][i][LIST_0][best_fw_ref][mode];
13396
13397 enc_picture->ref_pic_id [LIST_0][block_y][block_x + i] = enc_picture->ref_pic_num[LIST_0 + list_offset][best_fw_ref];
13398 enc_picture->mv [LIST_0][block_y][block_x + i][0] = cur_mv[0];
13399 enc_picture->mv [LIST_0][block_y][block_x + i][1] = cur_mv[1];
13400 }
13401 }
13402 }
13403
13404 if (bframe)
13405 {
13406 if (best_pdir==0)
13407 {
13408 for (j=img->block_y+(block&2); j<img->block_y+(block&2) + BLOCK_MULTIPLE; j++)
13409 {
13410 block_x = img->block_x+(block&1)*2;
13411 memset(&enc_picture->ref_idx[LIST_1][j][block_x], -1 , BLOCK_MULTIPLE * sizeof(char));
13412 memset(enc_picture->mv[LIST_1][j][block_x], 0 , 2 * BLOCK_MULTIPLE * sizeof(short));
13413 for (i=block_x; i<block_x + BLOCK_MULTIPLE; i++)
13414 {
13415 enc_picture->ref_pic_id [LIST_1][j][i] = -1;
13416 }
13417 }
13418 }
13419 else
13420 {
13421 if (img->bi_pred_me[mode])
13422 {
13423 for (j=0; j<BLOCK_MULTIPLE; j++)
13424 {
13425 block_y = img->block_y+(block&2)+j;
13426 block_x = img->block_x+(block&1)*2;
13427 memset(&enc_picture->ref_idx[LIST_1][block_y][block_x], 0, BLOCK_MULTIPLE * sizeof(char));
13428 for (i=0; i<BLOCK_MULTIPLE; i++)
13429 {
13430 cur_mv = img->bi_pred_me[mode] == 1
13431 ? img->bipred_mv1[i][j][LIST_1][0][mode]
13432 : img->bipred_mv2[i][j][LIST_1][0][mode];
13433
13434 enc_picture->ref_pic_id [LIST_1][block_y][block_x + i] =
13435 enc_picture->ref_pic_num[LIST_1 + list_offset][0];
13436 enc_picture->mv [LIST_1][block_y][block_x + i][0] = cur_mv[0];
13437 enc_picture->mv [LIST_1][block_y][block_x + i][1] = cur_mv[1];
13438 }
13439 }
13440 }
13441 else
13442 {
13443 for (j=0; j<BLOCK_MULTIPLE; j++)
13444 {
13445 block_y = img->block_y+(block&2)+j;
13446 block_x = img->block_x+(block&1)*2;
13447 memset(&enc_picture->ref_idx[LIST_1][block_y][block_x], best_bw_ref, BLOCK_MULTIPLE * sizeof(char));
13448 for (i=0; i<BLOCK_MULTIPLE; i++)
13449 {
13450
13451 enc_picture->ref_pic_id [LIST_1][block_y][block_x + i] =
13452 enc_picture->ref_pic_num[LIST_1 + list_offset][best_bw_ref];
13453 if(best_bw_ref>=0)
13454 {
13455 cur_mv = img->all_mv[j][i][LIST_1][best_bw_ref][mode];
13456 enc_picture->mv[LIST_1][block_y][block_x + i][0] = cur_mv[0];
13457 enc_picture->mv[LIST_1][block_y][block_x + i][1] = cur_mv[1];
13458 }
13459 }
13460 }
13461 }
13462 }
13463 }
13464 }
13465 else if (mode==2)
13466 {
13467 for (j=0; j<2; j++)
13468 {
13469 block_y = img->block_y + block * 2 + j;
13470 for (i=0; i<BLOCK_MULTIPLE; i++)
13471 {
13472 block_x = img->block_x + i;
13473 if (best_pdir==1)
13474 {
13475 enc_picture->ref_idx [LIST_0][block_y][block_x] = -1;
13476 enc_picture->ref_pic_id [LIST_0][block_y][block_x] = -1;
13477 enc_picture->mv [LIST_0][block_y][block_x][0] = 0;
13478 enc_picture->mv [LIST_0][block_y][block_x][1] = 0;
13479 }
13480 else
13481 {
13482 cur_mv = img->all_mv[j+block*2][i][LIST_0][best_fw_ref][mode];
13483
13484 enc_picture->ref_idx [LIST_0][block_y][block_x] = best_fw_ref;
13485 enc_picture->ref_pic_id [LIST_0][block_y][block_x] =
13486 enc_picture->ref_pic_num[LIST_0 + list_offset][best_fw_ref];
13487 enc_picture->mv [LIST_0][block_y][block_x][0] = cur_mv[0];
13488 enc_picture->mv [LIST_0][block_y][block_x][1] = cur_mv[1];
13489 }
13490
13491 if (bframe)
13492 {
13493 if (best_pdir==0)
13494 {
13495 enc_picture->ref_idx [LIST_1][block_y][block_x] = -1;
13496 enc_picture->ref_pic_id [LIST_1][block_y][block_x] = -1;
13497 enc_picture->mv [LIST_1][block_y][block_x][0] = 0;
13498 enc_picture->mv [LIST_1][block_y][block_x][1] = 0;
13499 }
13500 else
13501 {
13502 enc_picture->ref_idx[LIST_1][block_y][block_x] = best_bw_ref;
13503 if(best_bw_ref>=0)
13504 {
13505 cur_mv = img->all_mv[j+ block*2][i][LIST_1][best_bw_ref][mode];
13506
13507 enc_picture->ref_pic_id [LIST_1][block_y][block_x] =
13508 enc_picture->ref_pic_num[LIST_1 + list_offset][best_bw_ref];
13509 enc_picture->mv[LIST_1][block_y][block_x][0] = cur_mv[0];
13510 enc_picture->mv[LIST_1][block_y][block_x][1] = cur_mv[1];
13511 }
13512 }
13513 }
13514 }
13515 }
13516 }
13517 else
13518 {
13519 for (j=0; j<BLOCK_MULTIPLE; j++)
13520 {
13521 block_y = img->block_y+j;
13522 for (i=0; i<2; i++)
13523 {
13524 block_x = img->block_x + block*2 + i;
13525 if (best_pdir==1)
13526 {
13527 enc_picture->ref_idx [LIST_0][block_y][block_x] = -1;
13528 enc_picture->ref_pic_id [LIST_0][block_y][block_x] = -1;
13529 enc_picture->mv [LIST_0][block_y][block_x][0] = 0;
13530 enc_picture->mv [LIST_0][block_y][block_x][1] = 0;
13531 }
13532 else
13533 {
13534 cur_mv = img->all_mv[j][block*2+i][LIST_0][best_fw_ref][mode];
13535
13536 enc_picture->ref_idx [LIST_0][block_y][block_x] = best_fw_ref;
13537 enc_picture->ref_pic_id [LIST_0][block_y][block_x] =
13538 enc_picture->ref_pic_num[LIST_0 + list_offset][best_fw_ref];
13539 enc_picture->mv[LIST_0][block_y][block_x][0] = cur_mv[0];
13540 enc_picture->mv[LIST_0][block_y][block_x][1] = cur_mv[1];
13541 }
13542
13543 if (bframe)
13544 {
13545 if (best_pdir==0)
13546 {
13547 enc_picture->ref_idx [LIST_1][block_y][block_x] = -1;
13548 enc_picture->ref_pic_id [LIST_1][block_y][block_x] = -1;
13549 enc_picture->mv [LIST_1][block_y][block_x][0] = 0;
13550 enc_picture->mv [LIST_1][block_y][block_x][1] = 0;
13551 }
13552 else
13553 {
13554 enc_picture->ref_idx[LIST_1][block_y][block_x] = best_bw_ref;
13555 if(best_bw_ref>=0)
13556 {
13557 cur_mv = img->all_mv[j][block*2+i][LIST_1][best_bw_ref][mode];
13558 enc_picture->ref_pic_id [LIST_1][block_y][block_x] =
13559 enc_picture->ref_pic_num[LIST_1 + list_offset][best_bw_ref];
13560
13561 enc_picture->mv[LIST_1][block_y][block_x][0] = cur_mv[0];
13562 enc_picture->mv[LIST_1][block_y][block_x][1] = cur_mv[1];
13563 }
13564 }
13565 }
13566 }
13567 }
13568 }
13569}
13570
13571void update_refresh_map(int intra, int intra1, Macroblock *currMB)
13572{
13573 if (input->RestrictRef==1)
13574 {
13575 // Modified for Fast Mode Decision. Inchoon Choi, SungKyunKwan Univ.
13576 if (input->rdopt<2)
13577 {
13578 refresh_map[2*img->mb_y ][2*img->mb_x ] = (intra ? 1 : 0);
13579 refresh_map[2*img->mb_y ][2*img->mb_x+1] = (intra ? 1 : 0);
13580 refresh_map[2*img->mb_y+1][2*img->mb_x ] = (intra ? 1 : 0);
13581 refresh_map[2*img->mb_y+1][2*img->mb_x+1] = (intra ? 1 : 0);
13582 }
13583 else if (input->rdopt==3)
13584 {
13585 refresh_map[2*img->mb_y ][2*img->mb_x ] = (intra1==0 && (currMB->mb_type==I16MB || currMB->mb_type==I4MB) ? 1 : 0);
13586 refresh_map[2*img->mb_y ][2*img->mb_x+1] = (intra1==0 && (currMB->mb_type==I16MB || currMB->mb_type==I4MB) ? 1 : 0);
13587 refresh_map[2*img->mb_y+1][2*img->mb_x ] = (intra1==0 && (currMB->mb_type==I16MB || currMB->mb_type==I4MB) ? 1 : 0);
13588 refresh_map[2*img->mb_y+1][2*img->mb_x+1] = (intra1==0 && (currMB->mb_type==I16MB || currMB->mb_type==I4MB) ? 1 : 0);
13589 }
13590 }
13591 else if (input->RestrictRef==2)
13592 {
13593 refresh_map[2*img->mb_y ][2*img->mb_x ] = (currMB->mb_type==I16MB || currMB->mb_type==I4MB ? 1 : 0);
13594 refresh_map[2*img->mb_y ][2*img->mb_x+1] = (currMB->mb_type==I16MB || currMB->mb_type==I4MB ? 1 : 0);
13595 refresh_map[2*img->mb_y+1][2*img->mb_x ] = (currMB->mb_type==I16MB || currMB->mb_type==I4MB ? 1 : 0);
13596 refresh_map[2*img->mb_y+1][2*img->mb_x+1] = (currMB->mb_type==I16MB || currMB->mb_type==I4MB ? 1 : 0);
13597 }
13598}