hexsha stringlengths 40 40 | size int64 22 2.4M | ext stringclasses 5
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 260 | max_stars_repo_name stringlengths 5 109 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 260 | max_issues_repo_name stringlengths 5 109 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 260 | max_forks_repo_name stringlengths 5 109 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 22 2.4M | avg_line_length float64 5 169k | max_line_length int64 5 786k | alphanum_fraction float64 0.06 0.95 | matches listlengths 1 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9ed89daaa4ad2c8af0900164eb7c0305b6871cb1 | 41,622 | c | C | gst-plugins-base-1.2.4/gst/audiotestsrc/gstaudiotestsrc.c | Malk123/Robby | 1af36a34b40f6a0f2ba80067e0b364d83d5b4630 | [
"MIT"
] | null | null | null | gst-plugins-base-1.2.4/gst/audiotestsrc/gstaudiotestsrc.c | Malk123/Robby | 1af36a34b40f6a0f2ba80067e0b364d83d5b4630 | [
"MIT"
] | null | null | null | gst-plugins-base-1.2.4/gst/audiotestsrc/gstaudiotestsrc.c | Malk123/Robby | 1af36a34b40f6a0f2ba80067e0b364d83d5b4630 | [
"MIT"
] | null | null | null | /* GStreamer
* Copyright (C) 2005 Stefan Kost <ensonic@users.sf.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:element-audiotestsrc
*
* AudioTestSrc can be used to generate basic audio signals. It support several
* different waveforms and allows to set the base frequency and volume.
*
* <refsect2>
* <title>Example launch line</title>
* |[
* gst-launch audiotestsrc ! audioconvert ! alsasink
* ]| This pipeline produces a sine with default frequency, 440 Hz, and the
* default volume, 0.8 (relative to a maximum 1.0).
* |[
* gst-launch audiotestsrc wave=2 freq=200 ! audioconvert ! tee name=t ! queue ! alsasink t. ! queue ! libvisual_lv_scope ! videoconvert ! xvimagesink
* ]| In this example a saw wave is generated. The wave is shown using a
* scope visualizer from libvisual, allowing you to visually verify that
* the saw wave is correct.
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "gstaudiotestsrc.h"
#define M_PI_M2 ( G_PI + G_PI )
GST_DEBUG_CATEGORY_STATIC (audio_test_src_debug);
#define GST_CAT_DEFAULT audio_test_src_debug
#define DEFAULT_SAMPLES_PER_BUFFER 1024
#define DEFAULT_WAVE GST_AUDIO_TEST_SRC_WAVE_SINE
#define DEFAULT_FREQ 440.0
#define DEFAULT_VOLUME 0.8
#define DEFAULT_IS_LIVE FALSE
#define DEFAULT_TIMESTAMP_OFFSET G_GINT64_CONSTANT (0)
#define DEFAULT_CAN_ACTIVATE_PUSH TRUE
#define DEFAULT_CAN_ACTIVATE_PULL FALSE
enum
{
PROP_0,
PROP_SAMPLES_PER_BUFFER,
PROP_WAVE,
PROP_FREQ,
PROP_VOLUME,
PROP_IS_LIVE,
PROP_TIMESTAMP_OFFSET,
PROP_CAN_ACTIVATE_PUSH,
PROP_CAN_ACTIVATE_PULL,
PROP_LAST
};
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define FORMAT_STR "{ S16LE, S32LE, F32LE, F64LE }"
#define DEFAULT_FORMAT_STR "S16LE"
#else
#define FORMAT_STR "{ S16BE, S32BE, F32BE, F64BE }"
#define DEFAULT_FORMAT_STR "S16BE"
#endif
static GstStaticPadTemplate gst_audio_test_src_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " FORMAT_STR ", "
"layout = (string) interleaved, "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2]")
);
#define gst_audio_test_src_parent_class parent_class
G_DEFINE_TYPE (GstAudioTestSrc, gst_audio_test_src, GST_TYPE_BASE_SRC);
#define GST_TYPE_AUDIO_TEST_SRC_WAVE (gst_audiostestsrc_wave_get_type())
static GType
gst_audiostestsrc_wave_get_type (void)
{
static GType audiostestsrc_wave_type = 0;
static const GEnumValue audiostestsrc_waves[] = {
{GST_AUDIO_TEST_SRC_WAVE_SINE, "Sine", "sine"},
{GST_AUDIO_TEST_SRC_WAVE_SQUARE, "Square", "square"},
{GST_AUDIO_TEST_SRC_WAVE_SAW, "Saw", "saw"},
{GST_AUDIO_TEST_SRC_WAVE_TRIANGLE, "Triangle", "triangle"},
{GST_AUDIO_TEST_SRC_WAVE_SILENCE, "Silence", "silence"},
{GST_AUDIO_TEST_SRC_WAVE_WHITE_NOISE, "White uniform noise", "white-noise"},
{GST_AUDIO_TEST_SRC_WAVE_PINK_NOISE, "Pink noise", "pink-noise"},
{GST_AUDIO_TEST_SRC_WAVE_SINE_TAB, "Sine table", "sine-table"},
{GST_AUDIO_TEST_SRC_WAVE_TICKS, "Periodic Ticks", "ticks"},
{GST_AUDIO_TEST_SRC_WAVE_GAUSSIAN_WHITE_NOISE, "White Gaussian noise",
"gaussian-noise"},
{GST_AUDIO_TEST_SRC_WAVE_RED_NOISE, "Red (brownian) noise", "red-noise"},
{GST_AUDIO_TEST_SRC_WAVE_BLUE_NOISE, "Blue noise", "blue-noise"},
{GST_AUDIO_TEST_SRC_WAVE_VIOLET_NOISE, "Violet noise", "violet-noise"},
{0, NULL, NULL},
};
if (G_UNLIKELY (audiostestsrc_wave_type == 0)) {
audiostestsrc_wave_type = g_enum_register_static ("GstAudioTestSrcWave",
audiostestsrc_waves);
}
return audiostestsrc_wave_type;
}
static void gst_audio_test_src_finalize (GObject * object);
static void gst_audio_test_src_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_audio_test_src_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
static gboolean gst_audio_test_src_setcaps (GstBaseSrc * basesrc,
GstCaps * caps);
static GstCaps *gst_audio_test_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
static gboolean gst_audio_test_src_is_seekable (GstBaseSrc * basesrc);
static gboolean gst_audio_test_src_do_seek (GstBaseSrc * basesrc,
GstSegment * segment);
static gboolean gst_audio_test_src_query (GstBaseSrc * basesrc,
GstQuery * query);
static void gst_audio_test_src_change_wave (GstAudioTestSrc * src);
static void gst_audio_test_src_get_times (GstBaseSrc * basesrc,
GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
static gboolean gst_audio_test_src_start (GstBaseSrc * basesrc);
static gboolean gst_audio_test_src_stop (GstBaseSrc * basesrc);
static GstFlowReturn gst_audio_test_src_fill (GstBaseSrc * basesrc,
guint64 offset, guint length, GstBuffer * buffer);
static void
gst_audio_test_src_class_init (GstAudioTestSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSrcClass *gstbasesrc_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesrc_class = (GstBaseSrcClass *) klass;
gobject_class->set_property = gst_audio_test_src_set_property;
gobject_class->get_property = gst_audio_test_src_get_property;
gobject_class->finalize = gst_audio_test_src_finalize;
g_object_class_install_property (gobject_class, PROP_SAMPLES_PER_BUFFER,
g_param_spec_int ("samplesperbuffer", "Samples per buffer",
"Number of samples in each outgoing buffer",
1, G_MAXINT, DEFAULT_SAMPLES_PER_BUFFER,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_WAVE,
g_param_spec_enum ("wave", "Waveform", "Oscillator waveform",
GST_TYPE_AUDIO_TEST_SRC_WAVE, GST_AUDIO_TEST_SRC_WAVE_SINE,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_FREQ,
g_param_spec_double ("freq", "Frequency", "Frequency of test signal",
0.0, 20000.0, DEFAULT_FREQ,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_VOLUME,
g_param_spec_double ("volume", "Volume", "Volume of test signal", 0.0,
1.0, DEFAULT_VOLUME,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_IS_LIVE,
g_param_spec_boolean ("is-live", "Is Live",
"Whether to act as a live source", DEFAULT_IS_LIVE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass),
PROP_TIMESTAMP_OFFSET, g_param_spec_int64 ("timestamp-offset",
"Timestamp offset",
"An offset added to timestamps set on buffers (in ns)", G_MININT64,
G_MAXINT64, DEFAULT_TIMESTAMP_OFFSET,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_CAN_ACTIVATE_PUSH,
g_param_spec_boolean ("can-activate-push", "Can activate push",
"Can activate in push mode", DEFAULT_CAN_ACTIVATE_PUSH,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_CAN_ACTIVATE_PULL,
g_param_spec_boolean ("can-activate-pull", "Can activate pull",
"Can activate in pull mode", DEFAULT_CAN_ACTIVATE_PULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_audio_test_src_src_template));
gst_element_class_set_static_metadata (gstelement_class,
"Audio test source", "Source/Audio",
"Creates audio test signals of given frequency and volume",
"Stefan Kost <ensonic@users.sf.net>");
gstbasesrc_class->set_caps = GST_DEBUG_FUNCPTR (gst_audio_test_src_setcaps);
gstbasesrc_class->fixate = GST_DEBUG_FUNCPTR (gst_audio_test_src_fixate);
gstbasesrc_class->is_seekable =
GST_DEBUG_FUNCPTR (gst_audio_test_src_is_seekable);
gstbasesrc_class->do_seek = GST_DEBUG_FUNCPTR (gst_audio_test_src_do_seek);
gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_audio_test_src_query);
gstbasesrc_class->get_times =
GST_DEBUG_FUNCPTR (gst_audio_test_src_get_times);
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_audio_test_src_start);
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_audio_test_src_stop);
gstbasesrc_class->fill = GST_DEBUG_FUNCPTR (gst_audio_test_src_fill);
}
static void
gst_audio_test_src_init (GstAudioTestSrc * src)
{
src->volume = DEFAULT_VOLUME;
src->freq = DEFAULT_FREQ;
/* we operate in time */
gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
gst_base_src_set_live (GST_BASE_SRC (src), DEFAULT_IS_LIVE);
src->samples_per_buffer = DEFAULT_SAMPLES_PER_BUFFER;
src->generate_samples_per_buffer = src->samples_per_buffer;
src->timestamp_offset = DEFAULT_TIMESTAMP_OFFSET;
src->can_activate_pull = DEFAULT_CAN_ACTIVATE_PULL;
src->gen = NULL;
src->wave = DEFAULT_WAVE;
gst_base_src_set_blocksize (GST_BASE_SRC (src), -1);
}
static void
gst_audio_test_src_finalize (GObject * object)
{
GstAudioTestSrc *src = GST_AUDIO_TEST_SRC (object);
if (src->gen)
g_rand_free (src->gen);
src->gen = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static GstCaps *
gst_audio_test_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
{
GstAudioTestSrc *src = GST_AUDIO_TEST_SRC (bsrc);
GstStructure *structure;
caps = gst_caps_make_writable (caps);
structure = gst_caps_get_structure (caps, 0);
GST_DEBUG_OBJECT (src, "fixating samplerate to %d", GST_AUDIO_DEF_RATE);
gst_structure_fixate_field_nearest_int (structure, "rate",
GST_AUDIO_DEF_RATE);
gst_structure_fixate_field_string (structure, "format", DEFAULT_FORMAT_STR);
/* fixate to mono unless downstream requires stereo, for backwards compat */
gst_structure_fixate_field_nearest_int (structure, "channels", 1);
caps = GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps);
return caps;
}
static gboolean
gst_audio_test_src_setcaps (GstBaseSrc * basesrc, GstCaps * caps)
{
GstAudioTestSrc *src = GST_AUDIO_TEST_SRC (basesrc);
GstAudioInfo info;
if (!gst_audio_info_from_caps (&info, caps))
goto invalid_caps;
GST_DEBUG_OBJECT (src, "negotiated to caps %" GST_PTR_FORMAT, caps);
src->info = info;
gst_base_src_set_blocksize (basesrc,
GST_AUDIO_INFO_BPF (&info) * src->samples_per_buffer);
gst_audio_test_src_change_wave (src);
return TRUE;
/* ERROR */
invalid_caps:
{
GST_ERROR_OBJECT (basesrc, "received invalid caps");
return FALSE;
}
}
static gboolean
gst_audio_test_src_query (GstBaseSrc * basesrc, GstQuery * query)
{
GstAudioTestSrc *src = GST_AUDIO_TEST_SRC (basesrc);
gboolean res = FALSE;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONVERT:
{
GstFormat src_fmt, dest_fmt;
gint64 src_val, dest_val;
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
if (!gst_audio_info_convert (&src->info, src_fmt, src_val, dest_fmt,
&dest_val))
goto error;
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
res = TRUE;
break;
}
case GST_QUERY_SCHEDULING:
{
/* if we can operate in pull mode */
gst_query_set_scheduling (query, GST_SCHEDULING_FLAG_SEEKABLE, 1, -1, 0);
gst_query_add_scheduling_mode (query, GST_PAD_MODE_PUSH);
if (src->can_activate_pull)
gst_query_add_scheduling_mode (query, GST_PAD_MODE_PULL);
res = TRUE;
break;
}
default:
res = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);
break;
}
return res;
/* ERROR */
error:
{
GST_DEBUG_OBJECT (src, "query failed");
return FALSE;
}
}
#define DEFINE_SINE(type,scale) \
static void \
gst_audio_test_src_create_sine_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c, channels; \
gdouble step, amp; \
\
channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
step = M_PI_M2 * src->freq / GST_AUDIO_INFO_RATE (&src->info); \
amp = src->volume * scale; \
\
i = 0; \
while (i < (src->generate_samples_per_buffer * channels)) { \
src->accumulator += step; \
if (src->accumulator >= M_PI_M2) \
src->accumulator -= M_PI_M2; \
\
for (c = 0; c < channels; ++c) { \
samples[i++] = (g##type) (sin (src->accumulator) * amp); \
} \
} \
}
DEFINE_SINE (int16, 32767.0);
DEFINE_SINE (int32, 2147483647.0);
DEFINE_SINE (float, 1.0);
DEFINE_SINE (double, 1.0);
static const ProcessFunc sine_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_sine_int16,
(ProcessFunc) gst_audio_test_src_create_sine_int32,
(ProcessFunc) gst_audio_test_src_create_sine_float,
(ProcessFunc) gst_audio_test_src_create_sine_double
};
#define DEFINE_SQUARE(type,scale) \
static void \
gst_audio_test_src_create_square_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c, channels; \
gdouble step, amp; \
\
channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
step = M_PI_M2 * src->freq / GST_AUDIO_INFO_RATE (&src->info); \
amp = src->volume * scale; \
\
i = 0; \
while (i < (src->generate_samples_per_buffer * channels)) { \
src->accumulator += step; \
if (src->accumulator >= M_PI_M2) \
src->accumulator -= M_PI_M2; \
\
for (c = 0; c < channels; ++c) { \
samples[i++] = (g##type) ((src->accumulator < G_PI) ? amp : -amp); \
} \
} \
}
DEFINE_SQUARE (int16, 32767.0);
DEFINE_SQUARE (int32, 2147483647.0);
DEFINE_SQUARE (float, 1.0);
DEFINE_SQUARE (double, 1.0);
static const ProcessFunc square_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_square_int16,
(ProcessFunc) gst_audio_test_src_create_square_int32,
(ProcessFunc) gst_audio_test_src_create_square_float,
(ProcessFunc) gst_audio_test_src_create_square_double
};
#define DEFINE_SAW(type,scale) \
static void \
gst_audio_test_src_create_saw_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c, channels; \
gdouble step, amp; \
\
channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
step = M_PI_M2 * src->freq / GST_AUDIO_INFO_RATE (&src->info); \
amp = (src->volume * scale) / G_PI; \
\
i = 0; \
while (i < (src->generate_samples_per_buffer * channels)) { \
src->accumulator += step; \
if (src->accumulator >= M_PI_M2) \
src->accumulator -= M_PI_M2; \
\
if (src->accumulator < G_PI) { \
for (c = 0; c < channels; ++c) \
samples[i++] = (g##type) (src->accumulator * amp); \
} else { \
for (c = 0; c < channels; ++c) \
samples[i++] = (g##type) ((M_PI_M2 - src->accumulator) * -amp); \
} \
} \
}
DEFINE_SAW (int16, 32767.0);
DEFINE_SAW (int32, 2147483647.0);
DEFINE_SAW (float, 1.0);
DEFINE_SAW (double, 1.0);
static const ProcessFunc saw_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_saw_int16,
(ProcessFunc) gst_audio_test_src_create_saw_int32,
(ProcessFunc) gst_audio_test_src_create_saw_float,
(ProcessFunc) gst_audio_test_src_create_saw_double
};
#define DEFINE_TRIANGLE(type,scale) \
static void \
gst_audio_test_src_create_triangle_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c, channels; \
gdouble step, amp; \
\
channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
step = M_PI_M2 * src->freq / GST_AUDIO_INFO_RATE (&src->info); \
amp = (src->volume * scale) / G_PI_2; \
\
i = 0; \
while (i < (src->generate_samples_per_buffer * channels)) { \
src->accumulator += step; \
if (src->accumulator >= M_PI_M2) \
src->accumulator -= M_PI_M2; \
\
if (src->accumulator < (G_PI_2)) { \
for (c = 0; c < channels; ++c) \
samples[i++] = (g##type) (src->accumulator * amp); \
} else if (src->accumulator < (G_PI * 1.5)) { \
for (c = 0; c < channels; ++c) \
samples[i++] = (g##type) ((src->accumulator - G_PI) * -amp); \
} else { \
for (c = 0; c < channels; ++c) \
samples[i++] = (g##type) ((M_PI_M2 - src->accumulator) * -amp); \
} \
} \
}
DEFINE_TRIANGLE (int16, 32767.0);
DEFINE_TRIANGLE (int32, 2147483647.0);
DEFINE_TRIANGLE (float, 1.0);
DEFINE_TRIANGLE (double, 1.0);
static const ProcessFunc triangle_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_triangle_int16,
(ProcessFunc) gst_audio_test_src_create_triangle_int32,
(ProcessFunc) gst_audio_test_src_create_triangle_float,
(ProcessFunc) gst_audio_test_src_create_triangle_double
};
#define DEFINE_SILENCE(type) \
static void \
gst_audio_test_src_create_silence_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
memset (samples, 0, src->generate_samples_per_buffer * sizeof (g##type) * src->info.channels); \
}
DEFINE_SILENCE (int16);
DEFINE_SILENCE (int32);
DEFINE_SILENCE (float);
DEFINE_SILENCE (double);
static const ProcessFunc silence_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_silence_int16,
(ProcessFunc) gst_audio_test_src_create_silence_int32,
(ProcessFunc) gst_audio_test_src_create_silence_float,
(ProcessFunc) gst_audio_test_src_create_silence_double
};
#define DEFINE_WHITE_NOISE(type,scale) \
static void \
gst_audio_test_src_create_white_noise_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c; \
gdouble amp = (src->volume * scale); \
gint channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
\
i = 0; \
while (i < (src->generate_samples_per_buffer * channels)) { \
for (c = 0; c < channels; ++c) \
samples[i++] = (g##type) (amp * g_rand_double_range (src->gen, -1.0, 1.0)); \
} \
}
DEFINE_WHITE_NOISE (int16, 32767.0);
DEFINE_WHITE_NOISE (int32, 2147483647.0);
DEFINE_WHITE_NOISE (float, 1.0);
DEFINE_WHITE_NOISE (double, 1.0);
static const ProcessFunc white_noise_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_white_noise_int16,
(ProcessFunc) gst_audio_test_src_create_white_noise_int32,
(ProcessFunc) gst_audio_test_src_create_white_noise_float,
(ProcessFunc) gst_audio_test_src_create_white_noise_double
};
/* pink noise calculation is based on
* http://www.firstpr.com.au/dsp/pink-noise/phil_burk_19990905_patest_pink.c
* which has been released under public domain
* Many thanks Phil!
*/
static void
gst_audio_test_src_init_pink_noise (GstAudioTestSrc * src)
{
gint i;
gint num_rows = 12; /* arbitrary: 1 .. PINK_MAX_RANDOM_ROWS */
glong pmax;
src->pink.index = 0;
src->pink.index_mask = (1 << num_rows) - 1;
/* calculate maximum possible signed random value.
* Extra 1 for white noise always added. */
pmax = (num_rows + 1) * (1 << (PINK_RANDOM_BITS - 1));
src->pink.scalar = 1.0f / pmax;
/* Initialize rows. */
for (i = 0; i < num_rows; i++)
src->pink.rows[i] = 0;
src->pink.running_sum = 0;
}
/* Generate Pink noise values between -1.0 and +1.0 */
static gdouble
gst_audio_test_src_generate_pink_noise_value (GstAudioTestSrc * src)
{
GstPinkNoise *pink = &src->pink;
glong new_random;
glong sum;
/* Increment and mask index. */
pink->index = (pink->index + 1) & pink->index_mask;
/* If index is zero, don't update any random values. */
if (pink->index != 0) {
/* Determine how many trailing zeros in PinkIndex. */
/* This algorithm will hang if n==0 so test first. */
gint num_zeros = 0;
gint n = pink->index;
while ((n & 1) == 0) {
n = n >> 1;
num_zeros++;
}
/* Replace the indexed ROWS random value.
* Subtract and add back to RunningSum instead of adding all the random
* values together. Only one changes each time.
*/
pink->running_sum -= pink->rows[num_zeros];
new_random = 32768.0 - (65536.0 * (gulong) g_rand_int (src->gen)
/ (G_MAXUINT32 + 1.0));
pink->running_sum += new_random;
pink->rows[num_zeros] = new_random;
}
/* Add extra white noise value. */
new_random = 32768.0 - (65536.0 * (gulong) g_rand_int (src->gen)
/ (G_MAXUINT32 + 1.0));
sum = pink->running_sum + new_random;
/* Scale to range of -1.0 to 0.9999. */
return (pink->scalar * sum);
}
#define DEFINE_PINK(type, scale) \
static void \
gst_audio_test_src_create_pink_noise_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c, channels; \
gdouble amp; \
\
amp = src->volume * scale; \
channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
\
i = 0; \
while (i < (src->generate_samples_per_buffer * channels)) { \
for (c = 0; c < channels; ++c) { \
samples[i++] = \
(g##type) (gst_audio_test_src_generate_pink_noise_value (src) * \
amp); \
} \
} \
}
DEFINE_PINK (int16, 32767.0);
DEFINE_PINK (int32, 2147483647.0);
DEFINE_PINK (float, 1.0);
DEFINE_PINK (double, 1.0);
static const ProcessFunc pink_noise_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_pink_noise_int16,
(ProcessFunc) gst_audio_test_src_create_pink_noise_int32,
(ProcessFunc) gst_audio_test_src_create_pink_noise_float,
(ProcessFunc) gst_audio_test_src_create_pink_noise_double
};
static void
gst_audio_test_src_init_sine_table (GstAudioTestSrc * src)
{
gint i;
gdouble ang = 0.0;
gdouble step = M_PI_M2 / 1024.0;
gdouble amp = src->volume;
for (i = 0; i < 1024; i++) {
src->wave_table[i] = sin (ang) * amp;
ang += step;
}
}
#define DEFINE_SINE_TABLE(type,scale) \
static void \
gst_audio_test_src_create_sine_table_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c, channels; \
gdouble step, scl; \
\
channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
step = M_PI_M2 * src->freq / GST_AUDIO_INFO_RATE (&src->info); \
scl = 1024.0 / M_PI_M2; \
\
i = 0; \
while (i < (src->generate_samples_per_buffer * channels)) { \
src->accumulator += step; \
if (src->accumulator >= M_PI_M2) \
src->accumulator -= M_PI_M2; \
\
for (c = 0; c < channels; ++c) \
samples[i++] = (g##type) scale * src->wave_table[(gint) (src->accumulator * scl)]; \
} \
}
DEFINE_SINE_TABLE (int16, 32767.0);
DEFINE_SINE_TABLE (int32, 2147483647.0);
DEFINE_SINE_TABLE (float, 1.0);
DEFINE_SINE_TABLE (double, 1.0);
static const ProcessFunc sine_table_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_sine_table_int16,
(ProcessFunc) gst_audio_test_src_create_sine_table_int32,
(ProcessFunc) gst_audio_test_src_create_sine_table_float,
(ProcessFunc) gst_audio_test_src_create_sine_table_double
};
#define DEFINE_TICKS(type,scale) \
static void \
gst_audio_test_src_create_tick_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c, channels, samplerate; \
gdouble step, scl; \
\
channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
samplerate = GST_AUDIO_INFO_RATE (&src->info); \
step = M_PI_M2 * src->freq / samplerate; \
scl = 1024.0 / M_PI_M2; \
\
for (i = 0; i < src->generate_samples_per_buffer; i++) { \
src->accumulator += step; \
if (src->accumulator >= M_PI_M2) \
src->accumulator -= M_PI_M2; \
\
if ((src->next_sample + i)%samplerate < 1600) { \
for (c = 0; c < channels; ++c) \
samples[(i * channels) + c] = (g##type) scale * src->wave_table[(gint) (src->accumulator * scl)]; \
} else { \
for (c = 0; c < channels; ++c) \
samples[(i * channels) + c] = 0; \
} \
} \
}
DEFINE_TICKS (int16, 32767.0);
DEFINE_TICKS (int32, 2147483647.0);
DEFINE_TICKS (float, 1.0);
DEFINE_TICKS (double, 1.0);
static const ProcessFunc tick_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_tick_int16,
(ProcessFunc) gst_audio_test_src_create_tick_int32,
(ProcessFunc) gst_audio_test_src_create_tick_float,
(ProcessFunc) gst_audio_test_src_create_tick_double
};
/* Gaussian white noise using Box-Muller algorithm. unit variance
* normally-distributed random numbers are generated in pairs as the real
* and imaginary parts of a compex random variable with
* uniformly-distributed argument and \chi^{2}-distributed modulus.
*/
#define DEFINE_GAUSSIAN_WHITE_NOISE(type,scale) \
static void \
gst_audio_test_src_create_gaussian_white_noise_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c; \
gdouble amp = (src->volume * scale); \
gint channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
\
for (i = 0; i < src->generate_samples_per_buffer * channels; ) { \
for (c = 0; c < channels; ++c) { \
gdouble mag = sqrt (-2 * log (1.0 - g_rand_double (src->gen))); \
gdouble phs = g_rand_double_range (src->gen, 0.0, M_PI_M2); \
\
samples[i++] = (g##type) (amp * mag * cos (phs)); \
if (++c >= channels) \
break; \
samples[i++] = (g##type) (amp * mag * sin (phs)); \
} \
} \
}
DEFINE_GAUSSIAN_WHITE_NOISE (int16, 32767.0);
DEFINE_GAUSSIAN_WHITE_NOISE (int32, 2147483647.0);
DEFINE_GAUSSIAN_WHITE_NOISE (float, 1.0);
DEFINE_GAUSSIAN_WHITE_NOISE (double, 1.0);
static const ProcessFunc gaussian_white_noise_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_gaussian_white_noise_int16,
(ProcessFunc) gst_audio_test_src_create_gaussian_white_noise_int32,
(ProcessFunc) gst_audio_test_src_create_gaussian_white_noise_float,
(ProcessFunc) gst_audio_test_src_create_gaussian_white_noise_double
};
/* Brownian (Red) Noise: noise where the power density decreases by 6 dB per
* octave with increasing frequency
*
* taken from http://vellocet.com/dsp/noise/VRand.html
* by Andrew Simper of Vellocet (andy@vellocet.com)
*/
#define DEFINE_RED_NOISE(type,scale) \
static void \
gst_audio_test_src_create_red_noise_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c; \
gdouble amp = (src->volume * scale); \
gdouble state = src->red.state; \
gint channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
\
for (i = 0; i < src->generate_samples_per_buffer * channels; ) { \
for (c = 0; c < channels; ++c) { \
while (TRUE) { \
gdouble r = g_rand_double_range (src->gen, -1.0, 1.0); \
state += r; \
if (state < -8.0f || state > 8.0f) state -= r; \
else break; \
} \
samples[i++] = (g##type) (amp * state * 0.0625f); /* /16.0 */ \
} \
} \
src->red.state = state; \
}
DEFINE_RED_NOISE (int16, 32767.0);
DEFINE_RED_NOISE (int32, 2147483647.0);
DEFINE_RED_NOISE (float, 1.0);
DEFINE_RED_NOISE (double, 1.0);
static const ProcessFunc red_noise_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_red_noise_int16,
(ProcessFunc) gst_audio_test_src_create_red_noise_int32,
(ProcessFunc) gst_audio_test_src_create_red_noise_float,
(ProcessFunc) gst_audio_test_src_create_red_noise_double
};
/* Blue Noise: apply spectral inversion to pink noise */
#define DEFINE_BLUE_NOISE(type) \
static void \
gst_audio_test_src_create_blue_noise_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c; \
static gdouble flip=1.0; \
gint channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
\
gst_audio_test_src_create_pink_noise_##type (src, samples); \
for (i = 0; i < src->generate_samples_per_buffer * channels; ) { \
for (c = 0; c < channels; ++c) { \
samples[i++] *= flip; \
} \
flip *= -1.0; \
} \
}
DEFINE_BLUE_NOISE (int16);
DEFINE_BLUE_NOISE (int32);
DEFINE_BLUE_NOISE (float);
DEFINE_BLUE_NOISE (double);
static const ProcessFunc blue_noise_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_blue_noise_int16,
(ProcessFunc) gst_audio_test_src_create_blue_noise_int32,
(ProcessFunc) gst_audio_test_src_create_blue_noise_float,
(ProcessFunc) gst_audio_test_src_create_blue_noise_double
};
/* Violet Noise: apply spectral inversion to red noise */
#define DEFINE_VIOLET_NOISE(type) \
static void \
gst_audio_test_src_create_violet_noise_##type (GstAudioTestSrc * src, g##type * samples) \
{ \
gint i, c; \
static gdouble flip=1.0; \
gint channels = GST_AUDIO_INFO_CHANNELS (&src->info); \
\
gst_audio_test_src_create_red_noise_##type (src, samples); \
for (i = 0; i < src->generate_samples_per_buffer * channels; ) { \
for (c = 0; c < channels; ++c) { \
samples[i++] *= flip; \
} \
flip *= -1.0; \
} \
}
DEFINE_VIOLET_NOISE (int16);
DEFINE_VIOLET_NOISE (int32);
DEFINE_VIOLET_NOISE (float);
DEFINE_VIOLET_NOISE (double);
static const ProcessFunc violet_noise_funcs[] = {
(ProcessFunc) gst_audio_test_src_create_violet_noise_int16,
(ProcessFunc) gst_audio_test_src_create_violet_noise_int32,
(ProcessFunc) gst_audio_test_src_create_violet_noise_float,
(ProcessFunc) gst_audio_test_src_create_violet_noise_double
};
/*
* gst_audio_test_src_change_wave:
* Assign function pointer of wave generator.
*/
static void
gst_audio_test_src_change_wave (GstAudioTestSrc * src)
{
gint idx;
/* not negotiated yet? */
if (src->info.finfo == NULL) {
src->process = NULL;
return;
}
switch (GST_AUDIO_FORMAT_INFO_FORMAT (src->info.finfo)) {
case GST_AUDIO_FORMAT_S16:
idx = 0;
break;
case GST_AUDIO_FORMAT_S32:
idx = 1;
break;
case GST_AUDIO_FORMAT_F32:
idx = 2;
break;
case GST_AUDIO_FORMAT_F64:
idx = 3;
break;
default:
src->process = NULL;
return;
}
switch (src->wave) {
case GST_AUDIO_TEST_SRC_WAVE_SINE:
src->process = sine_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_SQUARE:
src->process = square_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_SAW:
src->process = saw_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_TRIANGLE:
src->process = triangle_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_SILENCE:
src->process = silence_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_WHITE_NOISE:
if (!(src->gen))
src->gen = g_rand_new ();
src->process = white_noise_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_PINK_NOISE:
if (!(src->gen))
src->gen = g_rand_new ();
gst_audio_test_src_init_pink_noise (src);
src->process = pink_noise_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_SINE_TAB:
gst_audio_test_src_init_sine_table (src);
src->process = sine_table_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_TICKS:
gst_audio_test_src_init_sine_table (src);
src->process = tick_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_GAUSSIAN_WHITE_NOISE:
if (!(src->gen))
src->gen = g_rand_new ();
src->process = gaussian_white_noise_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_RED_NOISE:
if (!(src->gen))
src->gen = g_rand_new ();
src->red.state = 0.0;
src->process = red_noise_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_BLUE_NOISE:
if (!(src->gen))
src->gen = g_rand_new ();
gst_audio_test_src_init_pink_noise (src);
src->process = blue_noise_funcs[idx];
break;
case GST_AUDIO_TEST_SRC_WAVE_VIOLET_NOISE:
if (!(src->gen))
src->gen = g_rand_new ();
src->red.state = 0.0;
src->process = violet_noise_funcs[idx];
break;
default:
GST_ERROR ("invalid wave-form");
break;
}
}
/*
* gst_audio_test_src_change_volume:
* Recalc wave tables for precalculated waves.
*/
static void
gst_audio_test_src_change_volume (GstAudioTestSrc * src)
{
switch (src->wave) {
case GST_AUDIO_TEST_SRC_WAVE_SINE_TAB:
gst_audio_test_src_init_sine_table (src);
break;
default:
break;
}
}
static void
gst_audio_test_src_get_times (GstBaseSrc * basesrc, GstBuffer * buffer,
GstClockTime * start, GstClockTime * end)
{
/* for live sources, sync on the timestamp of the buffer */
if (gst_base_src_is_live (basesrc)) {
GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buffer);
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
/* get duration to calculate end time */
GstClockTime duration = GST_BUFFER_DURATION (buffer);
if (GST_CLOCK_TIME_IS_VALID (duration)) {
*end = timestamp + duration;
}
*start = timestamp;
}
} else {
*start = -1;
*end = -1;
}
}
static gboolean
gst_audio_test_src_start (GstBaseSrc * basesrc)
{
GstAudioTestSrc *src = GST_AUDIO_TEST_SRC (basesrc);
src->next_sample = 0;
src->next_byte = 0;
src->next_time = 0;
src->check_seek_stop = FALSE;
src->eos_reached = FALSE;
src->tags_pushed = FALSE;
src->accumulator = 0;
return TRUE;
}
static gboolean
gst_audio_test_src_stop (GstBaseSrc * basesrc)
{
return TRUE;
}
/* seek to time, will be called when we operate in push mode. In pull mode we
* get the requested byte offset. */
static gboolean
gst_audio_test_src_do_seek (GstBaseSrc * basesrc, GstSegment * segment)
{
GstAudioTestSrc *src = GST_AUDIO_TEST_SRC (basesrc);
GstClockTime time;
gint samplerate, bpf;
gint64 next_sample;
GST_DEBUG_OBJECT (src, "seeking %" GST_SEGMENT_FORMAT, segment);
time = segment->position;
src->reverse = (segment->rate < 0.0);
samplerate = GST_AUDIO_INFO_RATE (&src->info);
bpf = GST_AUDIO_INFO_BPF (&src->info);
/* now move to the time indicated, don't seek to the sample *after* the time */
next_sample = gst_util_uint64_scale_int (time, samplerate, GST_SECOND);
src->next_byte = next_sample * bpf;
if (samplerate == 0)
src->next_time = 0;
else
src->next_time =
gst_util_uint64_scale_round (next_sample, GST_SECOND, samplerate);
GST_DEBUG_OBJECT (src, "seeking next_sample=%" G_GINT64_FORMAT
" next_time=%" GST_TIME_FORMAT, next_sample,
GST_TIME_ARGS (src->next_time));
g_assert (src->next_time <= time);
src->next_sample = next_sample;
if (!src->reverse) {
if (GST_CLOCK_TIME_IS_VALID (segment->start)) {
segment->time = segment->start;
}
} else {
if (GST_CLOCK_TIME_IS_VALID (segment->stop)) {
segment->time = segment->stop;
}
}
if (GST_CLOCK_TIME_IS_VALID (segment->stop)) {
time = segment->stop;
src->sample_stop =
gst_util_uint64_scale_round (time, samplerate, GST_SECOND);
src->check_seek_stop = TRUE;
} else {
src->check_seek_stop = FALSE;
}
src->eos_reached = FALSE;
return TRUE;
}
static gboolean
gst_audio_test_src_is_seekable (GstBaseSrc * basesrc)
{
/* we're seekable... */
return TRUE;
}
static GstFlowReturn
gst_audio_test_src_fill (GstBaseSrc * basesrc, guint64 offset,
guint length, GstBuffer * buffer)
{
GstAudioTestSrc *src;
GstClockTime next_time;
gint64 next_sample, next_byte;
gint bytes, samples;
GstElementClass *eclass;
GstMapInfo map;
gint samplerate, bpf;
src = GST_AUDIO_TEST_SRC (basesrc);
/* example for tagging generated data */
if (!src->tags_pushed) {
GstTagList *taglist;
taglist = gst_tag_list_new (GST_TAG_DESCRIPTION, "audiotest wave", NULL);
eclass = GST_ELEMENT_CLASS (parent_class);
if (eclass->send_event)
eclass->send_event (GST_ELEMENT_CAST (basesrc),
gst_event_new_tag (taglist));
else
gst_tag_list_unref (taglist);
src->tags_pushed = TRUE;
}
if (src->eos_reached) {
GST_INFO_OBJECT (src, "eos");
return GST_FLOW_EOS;
}
samplerate = GST_AUDIO_INFO_RATE (&src->info);
bpf = GST_AUDIO_INFO_BPF (&src->info);
/* if no length was given, use our default length in samples otherwise convert
* the length in bytes to samples. */
if (length == -1)
samples = src->samples_per_buffer;
else
samples = length / bpf;
/* if no offset was given, use our next logical byte */
if (offset == -1)
offset = src->next_byte;
/* now see if we are at the byteoffset we think we are */
if (offset != src->next_byte) {
GST_DEBUG_OBJECT (src, "seek to new offset %" G_GUINT64_FORMAT, offset);
/* we have a discont in the expected sample offset, do a 'seek' */
src->next_sample = offset / bpf;
src->next_time =
gst_util_uint64_scale_int (src->next_sample, GST_SECOND, samplerate);
src->next_byte = offset;
}
/* check for eos */
if (src->check_seek_stop &&
(src->sample_stop > src->next_sample) &&
(src->sample_stop < src->next_sample + samples)
) {
/* calculate only partial buffer */
src->generate_samples_per_buffer = src->sample_stop - src->next_sample;
next_sample = src->sample_stop;
src->eos_reached = TRUE;
} else {
/* calculate full buffer */
src->generate_samples_per_buffer = samples;
next_sample = src->next_sample + (src->reverse ? (-samples) : samples);
}
bytes = src->generate_samples_per_buffer * bpf;
next_byte = src->next_byte + (src->reverse ? (-bytes) : bytes);
next_time = gst_util_uint64_scale_int (next_sample, GST_SECOND, samplerate);
GST_LOG_OBJECT (src, "samplerate %d", samplerate);
GST_LOG_OBJECT (src, "next_sample %" G_GINT64_FORMAT ", ts %" GST_TIME_FORMAT,
next_sample, GST_TIME_ARGS (next_time));
gst_buffer_set_size (buffer, bytes);
GST_BUFFER_OFFSET (buffer) = src->next_sample;
GST_BUFFER_OFFSET_END (buffer) = next_sample;
if (!src->reverse) {
GST_BUFFER_TIMESTAMP (buffer) = src->timestamp_offset + src->next_time;
GST_BUFFER_DURATION (buffer) = next_time - src->next_time;
} else {
GST_BUFFER_TIMESTAMP (buffer) = src->timestamp_offset + next_time;
GST_BUFFER_DURATION (buffer) = src->next_time - next_time;
}
gst_object_sync_values (GST_OBJECT (src), GST_BUFFER_TIMESTAMP (buffer));
src->next_time = next_time;
src->next_sample = next_sample;
src->next_byte = next_byte;
GST_LOG_OBJECT (src, "generating %u samples at ts %" GST_TIME_FORMAT,
src->generate_samples_per_buffer,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
src->process (src, map.data);
gst_buffer_unmap (buffer, &map);
if (G_UNLIKELY ((src->wave == GST_AUDIO_TEST_SRC_WAVE_SILENCE)
|| (src->volume == 0.0))) {
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_GAP);
}
return GST_FLOW_OK;
}
static void
gst_audio_test_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstAudioTestSrc *src = GST_AUDIO_TEST_SRC (object);
switch (prop_id) {
case PROP_SAMPLES_PER_BUFFER:
src->samples_per_buffer = g_value_get_int (value);
gst_base_src_set_blocksize (GST_BASE_SRC_CAST (src),
GST_AUDIO_INFO_BPF (&src->info) * src->samples_per_buffer);
break;
case PROP_WAVE:
src->wave = g_value_get_enum (value);
gst_audio_test_src_change_wave (src);
break;
case PROP_FREQ:
src->freq = g_value_get_double (value);
break;
case PROP_VOLUME:
src->volume = g_value_get_double (value);
gst_audio_test_src_change_volume (src);
break;
case PROP_IS_LIVE:
gst_base_src_set_live (GST_BASE_SRC (src), g_value_get_boolean (value));
break;
case PROP_TIMESTAMP_OFFSET:
src->timestamp_offset = g_value_get_int64 (value);
break;
case PROP_CAN_ACTIVATE_PUSH:
GST_BASE_SRC (src)->can_activate_push = g_value_get_boolean (value);
break;
case PROP_CAN_ACTIVATE_PULL:
src->can_activate_pull = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_audio_test_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstAudioTestSrc *src = GST_AUDIO_TEST_SRC (object);
switch (prop_id) {
case PROP_SAMPLES_PER_BUFFER:
g_value_set_int (value, src->samples_per_buffer);
break;
case PROP_WAVE:
g_value_set_enum (value, src->wave);
break;
case PROP_FREQ:
g_value_set_double (value, src->freq);
break;
case PROP_VOLUME:
g_value_set_double (value, src->volume);
break;
case PROP_IS_LIVE:
g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src)));
break;
case PROP_TIMESTAMP_OFFSET:
g_value_set_int64 (value, src->timestamp_offset);
break;
case PROP_CAN_ACTIVATE_PUSH:
g_value_set_boolean (value, GST_BASE_SRC (src)->can_activate_push);
break;
case PROP_CAN_ACTIVATE_PULL:
g_value_set_boolean (value, src->can_activate_pull);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (audio_test_src_debug, "audiotestsrc", 0,
"Audio Test Source");
return gst_element_register (plugin, "audiotestsrc",
GST_RANK_NONE, GST_TYPE_AUDIO_TEST_SRC);
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
audiotestsrc,
"Creates audio test signals of given frequency and volume",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
| 31.579666 | 150 | 0.699678 | [
"object"
] |
9edac6210081fa470224fd24d64ed5e3a50fd86e | 82,202 | c | C | magick/transform.c | AlokKumar47/test | 77e41f9edd23fed552a0eeae7b2813b0da825fb0 | [
"ImageMagick"
] | null | null | null | magick/transform.c | AlokKumar47/test | 77e41f9edd23fed552a0eeae7b2813b0da825fb0 | [
"ImageMagick"
] | null | null | null | magick/transform.c | AlokKumar47/test | 77e41f9edd23fed552a0eeae7b2813b0da825fb0 | [
"ImageMagick"
] | null | null | null | /*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% TTTTT RRRR AAA N N SSSSS FFFFF OOO RRRR M M %
% T R R A A NN N SS F O O R R MM MM %
% T RRRR AAAAA N N N SSS FFF O O RRRR M M M %
% T R R A A N NN SS F O O R R M M %
% T R R A A N N SSSSS F OOO R R M M %
% %
% %
% MagickCore Image Transform Methods %
% %
% Software Design %
% Cristy %
% July 1992 %
% %
% %
% Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
% obtain a copy of the License at %
% %
% https://imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
% See the License for the specific language governing permissions and %
% limitations under the License. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
*/
/*
Include declarations.
*/
#include "magick/studio.h"
#include "magick/attribute.h"
#include "magick/cache.h"
#include "magick/cache-view.h"
#include "magick/color.h"
#include "magick/color-private.h"
#include "magick/colorspace-private.h"
#include "magick/composite.h"
#include "magick/distort.h"
#include "magick/draw.h"
#include "magick/effect.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/geometry.h"
#include "magick/image.h"
#include "magick/memory_.h"
#include "magick/layer.h"
#include "magick/list.h"
#include "magick/monitor.h"
#include "magick/monitor-private.h"
#include "magick/pixel-private.h"
#include "magick/resource_.h"
#include "magick/resize.h"
#include "magick/statistic.h"
#include "magick/string_.h"
#include "magick/thread-private.h"
#include "magick/transform.h"
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% A u t o O r i e n t I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% AutoOrientImage() adjusts an image so that its orientation is suitable for
% viewing (i.e. top-left orientation).
%
% The format of the AutoOrientImage method is:
%
% Image *AutoOrientImage(const Image *image,
% const OrientationType orientation,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: The image.
%
% o orientation: Current image orientation.
%
% o exception: Return any errors or warnings in this structure.
%
*/
MagickExport Image *AutoOrientImage(const Image *image,
const OrientationType orientation,ExceptionInfo *exception)
{
Image
*orient_image;
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
orient_image=(Image *) NULL;
switch(orientation)
{
case UndefinedOrientation:
case TopLeftOrientation:
default:
{
orient_image=CloneImage(image,0,0,MagickTrue,exception);
break;
}
case TopRightOrientation:
{
orient_image=FlopImage(image,exception);
break;
}
case BottomRightOrientation:
{
orient_image=RotateImage(image,180.0,exception);
break;
}
case BottomLeftOrientation:
{
orient_image=FlipImage(image,exception);
break;
}
case LeftTopOrientation:
{
orient_image=TransposeImage(image,exception);
break;
}
case RightTopOrientation:
{
orient_image=RotateImage(image,90.0,exception);
break;
}
case RightBottomOrientation:
{
orient_image=TransverseImage(image,exception);
break;
}
case LeftBottomOrientation:
{
orient_image=RotateImage(image,270.0,exception);
break;
}
}
if (orient_image != (Image *) NULL)
orient_image->orientation=TopLeftOrientation;
return(orient_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% C h o p I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ChopImage() removes a region of an image and collapses the image to occupy
% the removed portion.
%
% The format of the ChopImage method is:
%
% Image *ChopImage(const Image *image,const RectangleInfo *chop_info)
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o chop_info: Define the region of the image to chop.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
ExceptionInfo *exception)
{
#define ChopImageTag "Chop/Image"
CacheView
*chop_view,
*image_view;
Image
*chop_image;
MagickBooleanType
status;
MagickOffsetType
progress;
RectangleInfo
extent;
ssize_t
y;
/*
Check chop geometry.
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
assert(chop_info != (RectangleInfo *) NULL);
if (((chop_info->x+(ssize_t) chop_info->width) < 0) ||
((chop_info->y+(ssize_t) chop_info->height) < 0) ||
(chop_info->x > (ssize_t) image->columns) ||
(chop_info->y > (ssize_t) image->rows))
ThrowImageException(OptionWarning,"GeometryDoesNotContainImage");
extent=(*chop_info);
if ((extent.x+(ssize_t) extent.width) > (ssize_t) image->columns)
extent.width=(size_t) ((ssize_t) image->columns-extent.x);
if ((extent.y+(ssize_t) extent.height) > (ssize_t) image->rows)
extent.height=(size_t) ((ssize_t) image->rows-extent.y);
if (extent.x < 0)
{
extent.width-=(size_t) (-extent.x);
extent.x=0;
}
if (extent.y < 0)
{
extent.height-=(size_t) (-extent.y);
extent.y=0;
}
chop_image=CloneImage(image,image->columns-extent.width,image->rows-
extent.height,MagickTrue,exception);
if (chop_image == (Image *) NULL)
return((Image *) NULL);
/*
Extract chop image.
*/
status=MagickTrue;
progress=0;
image_view=AcquireVirtualCacheView(image,exception);
chop_view=AcquireAuthenticCacheView(chop_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(status) \
magick_number_threads(image,chop_image,extent.y,1)
#endif
for (y=0; y < (ssize_t) extent.y; y++)
{
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict chop_indexes,
*magick_restrict indexes;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
q=QueueCacheViewAuthenticPixels(chop_view,0,y,chop_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
indexes=GetCacheViewAuthenticIndexQueue(image_view);
chop_indexes=GetCacheViewAuthenticIndexQueue(chop_view);
for (x=0; x < (ssize_t) image->columns; x++)
{
if ((x < extent.x) || (x >= (ssize_t) (extent.x+extent.width)))
{
*q=(*p);
if (indexes != (IndexPacket *) NULL)
{
if (chop_indexes != (IndexPacket *) NULL)
*chop_indexes++=GetPixelIndex(indexes+x);
}
q++;
}
p++;
}
if (SyncCacheViewAuthenticPixels(chop_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,ChopImageTag,progress,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
/*
Extract chop image.
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(status) \
magick_number_threads(image,image,image->rows,1)
#endif
for (y=0; y < (ssize_t) (image->rows-(extent.y+extent.height)); y++)
{
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict chop_indexes,
*magick_restrict indexes;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,extent.y+extent.height+y,
image->columns,1,exception);
q=QueueCacheViewAuthenticPixels(chop_view,0,extent.y+y,chop_image->columns,
1,exception);
if ((p == (PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
indexes=GetCacheViewAuthenticIndexQueue(image_view);
chop_indexes=GetCacheViewAuthenticIndexQueue(chop_view);
for (x=0; x < (ssize_t) image->columns; x++)
{
if ((x < extent.x) || (x >= (ssize_t) (extent.x+extent.width)))
{
*q=(*p);
if (indexes != (IndexPacket *) NULL)
{
if (chop_indexes != (IndexPacket *) NULL)
*chop_indexes++=GetPixelIndex(indexes+x);
}
q++;
}
p++;
}
if (SyncCacheViewAuthenticPixels(chop_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,ChopImageTag,progress,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
chop_view=DestroyCacheView(chop_view);
image_view=DestroyCacheView(image_view);
chop_image->type=image->type;
if (status == MagickFalse)
chop_image=DestroyImage(chop_image);
return(chop_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
+ C o n s o l i d a t e C M Y K I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ConsolidateCMYKImage() consolidates separate C, M, Y, and K planes into a
% single image.
%
% The format of the ConsolidateCMYKImage method is:
%
% Image *ConsolidateCMYKImage(const Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image sequence.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *ConsolidateCMYKImages(const Image *images,
ExceptionInfo *exception)
{
CacheView
*cmyk_view,
*image_view;
Image
*cmyk_image,
*cmyk_images;
register ssize_t
i;
ssize_t
y;
/*
Consolidate separate C, M, Y, and K planes into a single image.
*/
assert(images != (Image *) NULL);
assert(images->signature == MagickCoreSignature);
if (images->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
cmyk_images=NewImageList();
for (i=0; i < (ssize_t) GetImageListLength(images); i+=4)
{
cmyk_image=CloneImage(images,0,0,MagickTrue,exception);
if (cmyk_image == (Image *) NULL)
break;
if (SetImageStorageClass(cmyk_image,DirectClass) == MagickFalse)
break;
(void) SetImageColorspace(cmyk_image,CMYKColorspace);
image_view=AcquireVirtualCacheView(images,exception);
cmyk_view=AcquireAuthenticCacheView(cmyk_image,exception);
for (y=0; y < (ssize_t) images->rows; y++)
{
register const PixelPacket
*magick_restrict p;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
p=GetCacheViewVirtualPixels(image_view,0,y,images->columns,1,exception);
q=QueueCacheViewAuthenticPixels(cmyk_view,0,y,cmyk_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
break;
for (x=0; x < (ssize_t) images->columns; x++)
{
SetPixelRed(q,ClampToQuantum(QuantumRange-GetPixelIntensity(images,p)));
p++;
q++;
}
if (SyncCacheViewAuthenticPixels(cmyk_view,exception) == MagickFalse)
break;
}
cmyk_view=DestroyCacheView(cmyk_view);
image_view=DestroyCacheView(image_view);
images=GetNextImageInList(images);
if (images == (Image *) NULL)
break;
image_view=AcquireVirtualCacheView(images,exception);
cmyk_view=AcquireAuthenticCacheView(cmyk_image,exception);
for (y=0; y < (ssize_t) images->rows; y++)
{
register const PixelPacket
*magick_restrict p;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
p=GetCacheViewVirtualPixels(image_view,0,y,images->columns,1,exception);
q=GetCacheViewAuthenticPixels(cmyk_view,0,y,cmyk_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
break;
for (x=0; x < (ssize_t) images->columns; x++)
{
q->green=ClampToQuantum(QuantumRange-GetPixelIntensity(images,p));
p++;
q++;
}
if (SyncCacheViewAuthenticPixels(cmyk_view,exception) == MagickFalse)
break;
}
cmyk_view=DestroyCacheView(cmyk_view);
image_view=DestroyCacheView(image_view);
images=GetNextImageInList(images);
if (images == (Image *) NULL)
break;
image_view=AcquireVirtualCacheView(images,exception);
cmyk_view=AcquireAuthenticCacheView(cmyk_image,exception);
for (y=0; y < (ssize_t) images->rows; y++)
{
register const PixelPacket
*magick_restrict p;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
p=GetCacheViewVirtualPixels(image_view,0,y,images->columns,1,exception);
q=GetCacheViewAuthenticPixels(cmyk_view,0,y,cmyk_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
break;
for (x=0; x < (ssize_t) images->columns; x++)
{
q->blue=ClampToQuantum(QuantumRange-GetPixelIntensity(images,p));
p++;
q++;
}
if (SyncCacheViewAuthenticPixels(cmyk_view,exception) == MagickFalse)
break;
}
cmyk_view=DestroyCacheView(cmyk_view);
image_view=DestroyCacheView(image_view);
images=GetNextImageInList(images);
if (images == (Image *) NULL)
break;
image_view=AcquireVirtualCacheView(images,exception);
cmyk_view=AcquireAuthenticCacheView(cmyk_image,exception);
for (y=0; y < (ssize_t) images->rows; y++)
{
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict indexes;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
p=GetCacheViewVirtualPixels(image_view,0,y,images->columns,1,exception);
q=GetCacheViewAuthenticPixels(cmyk_view,0,y,cmyk_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
break;
indexes=GetCacheViewAuthenticIndexQueue(cmyk_view);
for (x=0; x < (ssize_t) images->columns; x++)
{
SetPixelIndex(indexes+x,ClampToQuantum(QuantumRange-
GetPixelIntensity(images,p)));
p++;
}
if (SyncCacheViewAuthenticPixels(cmyk_view,exception) == MagickFalse)
break;
}
cmyk_view=DestroyCacheView(cmyk_view);
image_view=DestroyCacheView(image_view);
AppendImageToList(&cmyk_images,cmyk_image);
images=GetNextImageInList(images);
if (images == (Image *) NULL)
break;
}
return(cmyk_images);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% C r o p I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% CropImage() extracts a region of the image starting at the offset defined
% by geometry. Region must be fully defined, and no special handling of
% geometry flags is performed.
%
% The format of the CropImage method is:
%
% Image *CropImage(const Image *image,const RectangleInfo *geometry,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o geometry: Define the region of the image to crop with members
% x, y, width, and height.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
ExceptionInfo *exception)
{
#define CropImageTag "Crop/Image"
CacheView
*crop_view,
*image_view;
Image
*crop_image;
MagickBooleanType
status;
MagickOffsetType
progress;
RectangleInfo
bounding_box,
page;
ssize_t
y;
/*
Check crop geometry.
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(geometry != (const RectangleInfo *) NULL);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
bounding_box=image->page;
if ((bounding_box.width == 0) || (bounding_box.height == 0))
{
bounding_box.width=image->columns;
bounding_box.height=image->rows;
}
page=(*geometry);
if (page.width == 0)
page.width=bounding_box.width;
if (page.height == 0)
page.height=bounding_box.height;
if (((bounding_box.x-page.x) >= (ssize_t) page.width) ||
((bounding_box.y-page.y) >= (ssize_t) page.height) ||
((page.x-bounding_box.x) > (ssize_t) image->columns) ||
((page.y-bounding_box.y) > (ssize_t) image->rows))
{
/*
Crop is not within virtual canvas, return 1 pixel transparent image.
*/
(void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
"GeometryDoesNotContainImage","`%s'",image->filename);
crop_image=CloneImage(image,1,1,MagickTrue,exception);
if (crop_image == (Image *) NULL)
return((Image *) NULL);
crop_image->background_color.opacity=(Quantum) TransparentOpacity;
(void) SetImageBackgroundColor(crop_image);
crop_image->page=bounding_box;
crop_image->page.x=(-1);
crop_image->page.y=(-1);
if (crop_image->dispose == BackgroundDispose)
crop_image->dispose=NoneDispose;
return(crop_image);
}
if ((page.x < 0) && (bounding_box.x >= 0))
{
page.width+=page.x-bounding_box.x;
page.x=0;
}
else
{
page.width-=bounding_box.x-page.x;
page.x-=bounding_box.x;
if (page.x < 0)
page.x=0;
}
if ((page.y < 0) && (bounding_box.y >= 0))
{
page.height+=page.y-bounding_box.y;
page.y=0;
}
else
{
page.height-=bounding_box.y-page.y;
page.y-=bounding_box.y;
if (page.y < 0)
page.y=0;
}
if ((page.x+(ssize_t) page.width) > (ssize_t) image->columns)
page.width=image->columns-page.x;
if ((geometry->width != 0) && (page.width > geometry->width))
page.width=geometry->width;
if ((page.y+(ssize_t) page.height) > (ssize_t) image->rows)
page.height=image->rows-page.y;
if ((geometry->height != 0) && (page.height > geometry->height))
page.height=geometry->height;
bounding_box.x+=page.x;
bounding_box.y+=page.y;
if ((page.width == 0) || (page.height == 0))
{
(void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
"GeometryDoesNotContainImage","`%s'",image->filename);
return((Image *) NULL);
}
/*
Initialize crop image attributes.
*/
crop_image=CloneImage(image,page.width,page.height,MagickTrue,exception);
if (crop_image == (Image *) NULL)
return((Image *) NULL);
crop_image->page.width=image->page.width;
crop_image->page.height=image->page.height;
if (((ssize_t) (bounding_box.x+bounding_box.width) > (ssize_t) image->page.width) ||
((ssize_t) (bounding_box.y+bounding_box.height) > (ssize_t) image->page.height))
{
crop_image->page.width=bounding_box.width;
crop_image->page.height=bounding_box.height;
}
crop_image->page.x=bounding_box.x;
crop_image->page.y=bounding_box.y;
/*
Crop image.
*/
status=MagickTrue;
progress=0;
image_view=AcquireVirtualCacheView(image,exception);
crop_view=AcquireAuthenticCacheView(crop_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(status) \
magick_number_threads(image,crop_image,crop_image->rows,1)
#endif
for (y=0; y < (ssize_t) crop_image->rows; y++)
{
register const IndexPacket
*magick_restrict indexes;
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict crop_indexes;
register PixelPacket
*magick_restrict q;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,page.x,page.y+y,crop_image->columns,
1,exception);
q=QueueCacheViewAuthenticPixels(crop_view,0,y,crop_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
indexes=GetCacheViewVirtualIndexQueue(image_view);
crop_indexes=GetCacheViewAuthenticIndexQueue(crop_view);
(void) memcpy(q,p,(size_t) crop_image->columns*sizeof(*p));
if ((indexes != (IndexPacket *) NULL) &&
(crop_indexes != (IndexPacket *) NULL))
(void) memcpy(crop_indexes,indexes,(size_t) crop_image->columns*
sizeof(*crop_indexes));
if (SyncCacheViewAuthenticPixels(crop_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,CropImageTag,progress,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
crop_view=DestroyCacheView(crop_view);
image_view=DestroyCacheView(image_view);
crop_image->type=image->type;
if (status == MagickFalse)
crop_image=DestroyImage(crop_image);
return(crop_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% C r o p I m a g e T o T i l e s %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% CropImageToTiles() crops a single image, into a possible list of tiles.
% This may include a single sub-region of the image. This basically applies
% all the normal geometry flags for Crop.
%
% Image *CropImageToTiles(const Image *image,
% const RectangleInfo *crop_geometry, ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image The transformed image is returned as this parameter.
%
% o crop_geometry: A crop geometry string.
%
% o exception: return any errors or warnings in this structure.
%
*/
static inline double MagickRound(double x)
{
/*
Round the fraction to nearest integer.
*/
if ((x-floor(x)) < (ceil(x)-x))
return(floor(x));
return(ceil(x));
}
MagickExport Image *CropImageToTiles(const Image *image,
const char *crop_geometry,ExceptionInfo *exception)
{
Image
*next,
*crop_image;
MagickStatusType
flags;
RectangleInfo
geometry;
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
crop_image=NewImageList();
next=NewImageList();
flags=ParseGravityGeometry(image,crop_geometry,&geometry,exception);
if ((flags & AreaValue) != 0)
{
PointInfo
delta,
offset;
RectangleInfo
crop;
size_t
height,
width;
/*
Crop into NxM tiles (@ flag).
*/
width=image->columns;
height=image->rows;
if (geometry.width == 0)
geometry.width=1;
if (geometry.height == 0)
geometry.height=1;
if ((flags & AspectValue) == 0)
{
width-=(geometry.x < 0 ? -1 : 1)*geometry.x;
height-=(geometry.y < 0 ? -1 : 1)*geometry.y;
}
else
{
width+=(geometry.x < 0 ? -1 : 1)*geometry.x;
height+=(geometry.y < 0 ? -1 : 1)*geometry.y;
}
delta.x=(double) width/geometry.width;
delta.y=(double) height/geometry.height;
if (delta.x < 1.0)
delta.x=1.0;
if (delta.y < 1.0)
delta.y=1.0;
for (offset.y=0; offset.y < (double) height; )
{
if ((flags & AspectValue) == 0)
{
crop.y=(ssize_t) MagickRound((MagickRealType) (offset.y-
(geometry.y > 0 ? 0 : geometry.y)));
offset.y+=delta.y; /* increment now to find width */
crop.height=(size_t) MagickRound((MagickRealType) (offset.y+
(geometry.y < 0 ? 0 : geometry.y)));
}
else
{
crop.y=(ssize_t) MagickRound((MagickRealType) (offset.y-
(geometry.y > 0 ? geometry.y : 0)));
offset.y+=delta.y; /* increment now to find width */
crop.height=(size_t) MagickRound((MagickRealType) (offset.y+
(geometry.y < 0 ? geometry.y : 0)));
}
crop.height-=crop.y;
crop.y+=image->page.y;
for (offset.x=0; offset.x < (double) width; )
{
if ((flags & AspectValue) == 0)
{
crop.x=(ssize_t) MagickRound((MagickRealType) (offset.x-
(geometry.x > 0 ? 0 : geometry.x)));
offset.x+=delta.x; /* increment now to find height */
crop.width=(size_t) MagickRound((MagickRealType) (offset.x+
(geometry.x < 0 ? 0 : geometry.x)));
}
else
{
crop.x=(ssize_t) MagickRound((MagickRealType) (offset.x-
(geometry.x > 0 ? geometry.x : 0)));
offset.x+=delta.x; /* increment now to find height */
crop.width=(size_t) MagickRound((MagickRealType) (offset.x+
(geometry.x < 0 ? geometry.x : 0)));
}
crop.width-=crop.x;
crop.x+=image->page.x;
next=CropImage(image,&crop,exception);
if (next != (Image *) NULL)
AppendImageToList(&crop_image,next);
}
}
ClearMagickException(exception);
return(crop_image);
}
if (((geometry.width == 0) && (geometry.height == 0)) ||
((flags & XValue) != 0) || ((flags & YValue) != 0))
{
/*
Crop a single region at +X+Y.
*/
crop_image=CropImage(image,&geometry,exception);
if ((crop_image != (Image *) NULL) && ((flags & AspectValue) != 0))
{
crop_image->page.width=geometry.width;
crop_image->page.height=geometry.height;
crop_image->page.x-=geometry.x;
crop_image->page.y-=geometry.y;
}
return(crop_image);
}
if ((image->columns > geometry.width) || (image->rows > geometry.height))
{
RectangleInfo
page;
size_t
height,
width;
ssize_t
x,
y;
/*
Crop into tiles of fixed size WxH.
*/
page=image->page;
if (page.width == 0)
page.width=image->columns;
if (page.height == 0)
page.height=image->rows;
width=geometry.width;
if (width == 0)
width=page.width;
height=geometry.height;
if (height == 0)
height=page.height;
next=NewImageList();
for (y=0; y < (ssize_t) page.height; y+=(ssize_t) height)
{
for (x=0; x < (ssize_t) page.width; x+=(ssize_t) width)
{
geometry.width=width;
geometry.height=height;
geometry.x=x;
geometry.y=y;
next=CropImage(image,&geometry,exception);
if (next == (Image *) NULL)
break;
AppendImageToList(&crop_image,next);
}
if (next == (Image *) NULL)
break;
}
return(crop_image);
}
return(CloneImage(image,0,0,MagickTrue,exception));
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% E x c e r p t I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ExcerptImage() returns a excerpt of the image as defined by the geometry.
%
% The format of the ExcerptImage method is:
%
% Image *ExcerptImage(const Image *image,const RectangleInfo *geometry,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o geometry: Define the region of the image to extend with members
% x, y, width, and height.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *ExcerptImage(const Image *image,
const RectangleInfo *geometry,ExceptionInfo *exception)
{
#define ExcerptImageTag "Excerpt/Image"
CacheView
*excerpt_view,
*image_view;
Image
*excerpt_image;
MagickBooleanType
status;
MagickOffsetType
progress;
ssize_t
y;
/*
Allocate excerpt image.
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(geometry != (const RectangleInfo *) NULL);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
excerpt_image=CloneImage(image,geometry->width,geometry->height,MagickTrue,
exception);
if (excerpt_image == (Image *) NULL)
return((Image *) NULL);
/*
Excerpt each row.
*/
status=MagickTrue;
progress=0;
image_view=AcquireVirtualCacheView(image,exception);
excerpt_view=AcquireAuthenticCacheView(excerpt_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(progress,status) \
magick_number_threads(image,excerpt_image,excerpt_image->rows,1)
#endif
for (y=0; y < (ssize_t) excerpt_image->rows; y++)
{
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict excerpt_indexes,
*magick_restrict indexes;
register PixelPacket
*magick_restrict q;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,geometry->x,geometry->y+y,
geometry->width,1,exception);
q=GetCacheViewAuthenticPixels(excerpt_view,0,y,excerpt_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
(void) memcpy(q,p,(size_t) excerpt_image->columns*sizeof(*q));
indexes=GetCacheViewAuthenticIndexQueue(image_view);
if (indexes != (IndexPacket *) NULL)
{
excerpt_indexes=GetCacheViewAuthenticIndexQueue(excerpt_view);
if (excerpt_indexes != (IndexPacket *) NULL)
(void) memcpy(excerpt_indexes,indexes,(size_t)
excerpt_image->columns*sizeof(*excerpt_indexes));
}
if (SyncCacheViewAuthenticPixels(excerpt_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,ExcerptImageTag,progress,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
excerpt_view=DestroyCacheView(excerpt_view);
image_view=DestroyCacheView(image_view);
excerpt_image->type=image->type;
if (status == MagickFalse)
excerpt_image=DestroyImage(excerpt_image);
return(excerpt_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% E x t e n t I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ExtentImage() extends the image as defined by the geometry, gravity, and
% image background color. Set the (x,y) offset of the geometry to move the
% original image relative to the extended image.
%
% The format of the ExtentImage method is:
%
% Image *ExtentImage(const Image *image,const RectangleInfo *geometry,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o geometry: Define the region of the image to extend with members
% x, y, width, and height.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *ExtentImage(const Image *image,
const RectangleInfo *geometry,ExceptionInfo *exception)
{
Image
*extent_image;
MagickBooleanType
status;
/*
Allocate extent image.
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(geometry != (const RectangleInfo *) NULL);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
extent_image=CloneImage(image,geometry->width,geometry->height,MagickTrue,
exception);
if (extent_image == (Image *) NULL)
return((Image *) NULL);
status=SetImageBackgroundColor(extent_image);
if (status == MagickFalse)
{
InheritException(exception,&extent_image->exception);
extent_image=DestroyImage(extent_image);
return((Image *) NULL);
}
status=CompositeImage(extent_image,image->compose,image,-geometry->x,
-geometry->y);
if (status == MagickFalse)
{
InheritException(exception,&extent_image->exception);
extent_image=DestroyImage(extent_image);
return((Image *) NULL);
}
return(extent_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% F l i p I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FlipImage() creates a vertical mirror image by reflecting the pixels
% around the central x-axis.
%
% The format of the FlipImage method is:
%
% Image *FlipImage(const Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *FlipImage(const Image *image,ExceptionInfo *exception)
{
#define FlipImageTag "Flip/Image"
CacheView
*flip_view,
*image_view;
Image
*flip_image;
MagickBooleanType
status;
MagickOffsetType
progress;
RectangleInfo
page;
ssize_t
y;
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
flip_image=CloneImage(image,0,0,MagickTrue,exception);
if (flip_image == (Image *) NULL)
return((Image *) NULL);
/*
Flip image.
*/
status=MagickTrue;
progress=0;
page=image->page;
image_view=AcquireVirtualCacheView(image,exception);
flip_view=AcquireAuthenticCacheView(flip_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(status) \
magick_number_threads(image,flip_image,flip_image->rows,1)
#endif
for (y=0; y < (ssize_t) flip_image->rows; y++)
{
register const IndexPacket
*magick_restrict indexes;
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict flip_indexes;
register PixelPacket
*magick_restrict q;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
q=QueueCacheViewAuthenticPixels(flip_view,0,(ssize_t) (flip_image->rows-y-
1),flip_image->columns,1,exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
(void) memcpy(q,p,(size_t) image->columns*sizeof(*q));
indexes=GetCacheViewVirtualIndexQueue(image_view);
if (indexes != (const IndexPacket *) NULL)
{
flip_indexes=GetCacheViewAuthenticIndexQueue(flip_view);
if (flip_indexes != (IndexPacket *) NULL)
(void) memcpy(flip_indexes,indexes,(size_t) image->columns*
sizeof(*flip_indexes));
}
if (SyncCacheViewAuthenticPixels(flip_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,FlipImageTag,progress,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
flip_view=DestroyCacheView(flip_view);
image_view=DestroyCacheView(image_view);
flip_image->type=image->type;
if (page.height != 0)
page.y=(ssize_t) (page.height-flip_image->rows-page.y);
flip_image->page=page;
if (status == MagickFalse)
flip_image=DestroyImage(flip_image);
return(flip_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% F l o p I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FlopImage() creates a horizontal mirror image by reflecting the pixels
% around the central y-axis.
%
% The format of the FlopImage method is:
%
% Image *FlopImage(const Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception)
{
#define FlopImageTag "Flop/Image"
CacheView
*flop_view,
*image_view;
Image
*flop_image;
MagickBooleanType
status;
MagickOffsetType
progress;
RectangleInfo
page;
ssize_t
y;
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
flop_image=CloneImage(image,0,0,MagickTrue,exception);
if (flop_image == (Image *) NULL)
return((Image *) NULL);
/*
Flop each row.
*/
status=MagickTrue;
progress=0;
page=image->page;
image_view=AcquireVirtualCacheView(image,exception);
flop_view=AcquireAuthenticCacheView(flop_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(status) \
magick_number_threads(image,flop_image,flop_image->rows,1)
#endif
for (y=0; y < (ssize_t) flop_image->rows; y++)
{
register const IndexPacket
*magick_restrict indexes;
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict flop_indexes;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
q=QueueCacheViewAuthenticPixels(flop_view,0,y,flop_image->columns,1,
exception);
if ((p == (PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
q+=flop_image->columns;
indexes=GetCacheViewVirtualIndexQueue(image_view);
flop_indexes=GetCacheViewAuthenticIndexQueue(flop_view);
for (x=0; x < (ssize_t) flop_image->columns; x++)
{
(*--q)=(*p++);
if ((indexes != (const IndexPacket *) NULL) &&
(flop_indexes != (IndexPacket *) NULL))
SetPixelIndex(flop_indexes+flop_image->columns-x-1,
GetPixelIndex(indexes+x));
}
if (SyncCacheViewAuthenticPixels(flop_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,FlopImageTag,progress,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
flop_view=DestroyCacheView(flop_view);
image_view=DestroyCacheView(image_view);
flop_image->type=image->type;
if (page.width != 0)
page.x=(ssize_t) (page.width-flop_image->columns-page.x);
flop_image->page=page;
if (status == MagickFalse)
flop_image=DestroyImage(flop_image);
return(flop_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R o l l I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% RollImage() offsets an image as defined by x_offset and y_offset.
%
% The format of the RollImage method is:
%
% Image *RollImage(const Image *image,const ssize_t x_offset,
% const ssize_t y_offset,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o x_offset: the number of columns to roll in the horizontal direction.
%
% o y_offset: the number of rows to roll in the vertical direction.
%
% o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType CopyImageRegion(Image *destination,const Image *source, const size_t columns,const size_t rows,const ssize_t sx,const ssize_t sy,
const ssize_t dx,const ssize_t dy,ExceptionInfo *exception)
{
CacheView
*source_view,
*destination_view;
MagickBooleanType
status;
ssize_t
y;
if (columns == 0)
return(MagickTrue);
status=MagickTrue;
source_view=AcquireVirtualCacheView(source,exception);
destination_view=AcquireAuthenticCacheView(destination,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(status) \
magick_number_threads(source,destination,rows,1)
#endif
for (y=0; y < (ssize_t) rows; y++)
{
MagickBooleanType
sync;
register const IndexPacket
*magick_restrict indexes;
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict destination_indexes;
register PixelPacket
*magick_restrict q;
/*
Transfer scanline.
*/
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(source_view,sx,sy+y,columns,1,exception);
q=GetCacheViewAuthenticPixels(destination_view,dx,dy+y,columns,1,exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
indexes=GetCacheViewVirtualIndexQueue(source_view);
(void) memcpy(q,p,(size_t) columns*sizeof(*p));
if (indexes != (IndexPacket *) NULL)
{
destination_indexes=GetCacheViewAuthenticIndexQueue(destination_view);
if (destination_indexes != (IndexPacket *) NULL)
(void) memcpy(destination_indexes,indexes,(size_t)
columns*sizeof(*indexes));
}
sync=SyncCacheViewAuthenticPixels(destination_view,exception);
if (sync == MagickFalse)
status=MagickFalse;
}
destination_view=DestroyCacheView(destination_view);
source_view=DestroyCacheView(source_view);
return(status);
}
MagickExport Image *RollImage(const Image *image,const ssize_t x_offset,
const ssize_t y_offset,ExceptionInfo *exception)
{
#define RollImageTag "Roll/Image"
Image
*roll_image;
MagickStatusType
status;
RectangleInfo
offset;
/*
Initialize roll image attributes.
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
roll_image=CloneImage(image,0,0,MagickTrue,exception);
if (roll_image == (Image *) NULL)
return((Image *) NULL);
offset.x=x_offset;
offset.y=y_offset;
while (offset.x < 0)
offset.x+=(ssize_t) image->columns;
while (offset.x >= (ssize_t) image->columns)
offset.x-=(ssize_t) image->columns;
while (offset.y < 0)
offset.y+=(ssize_t) image->rows;
while (offset.y >= (ssize_t) image->rows)
offset.y-=(ssize_t) image->rows;
/*
Roll image.
*/
status=CopyImageRegion(roll_image,image,(size_t) offset.x,
(size_t) offset.y,(ssize_t) image->columns-offset.x,(ssize_t) image->rows-
offset.y,0,0,exception);
(void) SetImageProgress(image,RollImageTag,0,3);
status&=CopyImageRegion(roll_image,image,image->columns-offset.x,
(size_t) offset.y,0,(ssize_t) image->rows-offset.y,offset.x,0,
exception);
(void) SetImageProgress(image,RollImageTag,1,3);
status&=CopyImageRegion(roll_image,image,(size_t) offset.x,image->rows-
offset.y,(ssize_t) image->columns-offset.x,0,0,offset.y,exception);
(void) SetImageProgress(image,RollImageTag,2,3);
status&=CopyImageRegion(roll_image,image,image->columns-offset.x,image->rows-
offset.y,0,0,offset.x,offset.y,exception);
(void) SetImageProgress(image,RollImageTag,3,3);
roll_image->type=image->type;
if (status == MagickFalse)
roll_image=DestroyImage(roll_image);
return(roll_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% S h a v e I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ShaveImage() shaves pixels from the image edges. It allocates the memory
% necessary for the new Image structure and returns a pointer to the new
% image.
%
% The format of the ShaveImage method is:
%
% Image *ShaveImage(const Image *image,const RectangleInfo *shave_info,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o shave_image: Method ShaveImage returns a pointer to the shaved
% image. A null image is returned if there is a memory shortage or
% if the image width or height is zero.
%
% o image: the image.
%
% o shave_info: Specifies a pointer to a RectangleInfo which defines the
% region of the image to crop.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *ShaveImage(const Image *image,
const RectangleInfo *shave_info,ExceptionInfo *exception)
{
Image
*shave_image;
RectangleInfo
geometry;
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if (((2*shave_info->width) >= image->columns) ||
((2*shave_info->height) >= image->rows))
ThrowImageException(OptionWarning,"GeometryDoesNotContainImage");
SetGeometry(image,&geometry);
geometry.width-=2*shave_info->width;
geometry.height-=2*shave_info->height;
geometry.x=(ssize_t) shave_info->width+image->page.x;
geometry.y=(ssize_t) shave_info->height+image->page.y;
shave_image=CropImage(image,&geometry,exception);
if (shave_image == (Image *) NULL)
return((Image *) NULL);
shave_image->page.width-=2*shave_info->width;
shave_image->page.height-=2*shave_info->height;
shave_image->page.x-=(ssize_t) shave_info->width;
shave_image->page.y-=(ssize_t) shave_info->height;
return(shave_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% S p l i c e I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% SpliceImage() splices a solid color into the image as defined by the
% geometry.
%
% The format of the SpliceImage method is:
%
% Image *SpliceImage(const Image *image,const RectangleInfo *geometry,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o geometry: Define the region of the image to splice with members
% x, y, width, and height.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *SpliceImage(const Image *image,
const RectangleInfo *geometry,ExceptionInfo *exception)
{
#define SpliceImageTag "Splice/Image"
CacheView
*image_view,
*splice_view;
Image
*splice_image;
MagickBooleanType
status;
MagickOffsetType
progress;
RectangleInfo
splice_geometry;
ssize_t
columns,
y;
/*
Allocate splice image.
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(geometry != (const RectangleInfo *) NULL);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
splice_geometry=(*geometry);
splice_image=CloneImage(image,image->columns+splice_geometry.width,
image->rows+splice_geometry.height,MagickTrue,exception);
if (splice_image == (Image *) NULL)
return((Image *) NULL);
if (SetImageStorageClass(splice_image,DirectClass) == MagickFalse)
{
InheritException(exception,&splice_image->exception);
splice_image=DestroyImage(splice_image);
return((Image *) NULL);
}
(void) SetImageBackgroundColor(splice_image);
/*
Respect image geometry.
*/
switch (image->gravity)
{
default:
case UndefinedGravity:
case NorthWestGravity:
break;
case NorthGravity:
{
splice_geometry.x+=(ssize_t) splice_geometry.width/2;
break;
}
case NorthEastGravity:
{
splice_geometry.x+=(ssize_t) splice_geometry.width;
break;
}
case WestGravity:
{
splice_geometry.y+=(ssize_t) splice_geometry.width/2;
break;
}
case StaticGravity:
case CenterGravity:
{
splice_geometry.x+=(ssize_t) splice_geometry.width/2;
splice_geometry.y+=(ssize_t) splice_geometry.height/2;
break;
}
case EastGravity:
{
splice_geometry.x+=(ssize_t) splice_geometry.width;
splice_geometry.y+=(ssize_t) splice_geometry.height/2;
break;
}
case SouthWestGravity:
{
splice_geometry.y+=(ssize_t) splice_geometry.height;
break;
}
case SouthGravity:
{
splice_geometry.x+=(ssize_t) splice_geometry.width/2;
splice_geometry.y+=(ssize_t) splice_geometry.height;
break;
}
case SouthEastGravity:
{
splice_geometry.x+=(ssize_t) splice_geometry.width;
splice_geometry.y+=(ssize_t) splice_geometry.height;
break;
}
}
/*
Splice image.
*/
status=MagickTrue;
progress=0;
columns=MagickMin(splice_geometry.x,(ssize_t) splice_image->columns);
image_view=AcquireVirtualCacheView(image,exception);
splice_view=AcquireAuthenticCacheView(splice_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(progress,status) \
magick_number_threads(image,splice_image,splice_geometry.y,1)
#endif
for (y=0; y < (ssize_t) splice_geometry.y; y++)
{
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict indexes,
*magick_restrict splice_indexes;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,y,splice_image->columns,1,
exception);
q=QueueCacheViewAuthenticPixels(splice_view,0,y,splice_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
indexes=GetCacheViewAuthenticIndexQueue(image_view);
splice_indexes=GetCacheViewAuthenticIndexQueue(splice_view);
for (x=0; x < columns; x++)
{
SetPixelRed(q,GetPixelRed(p));
SetPixelGreen(q,GetPixelGreen(p));
SetPixelBlue(q,GetPixelBlue(p));
SetPixelOpacity(q,OpaqueOpacity);
if (image->matte != MagickFalse)
SetPixelOpacity(q,GetPixelOpacity(p));
if (image->colorspace == CMYKColorspace)
SetPixelIndex(splice_indexes+x,GetPixelIndex(indexes));
indexes++;
p++;
q++;
}
for ( ; x < (ssize_t) (splice_geometry.x+splice_geometry.width); x++)
q++;
for ( ; x < (ssize_t) splice_image->columns; x++)
{
SetPixelRed(q,GetPixelRed(p));
SetPixelGreen(q,GetPixelGreen(p));
SetPixelBlue(q,GetPixelBlue(p));
SetPixelOpacity(q,OpaqueOpacity);
if (image->matte != MagickFalse)
SetPixelOpacity(q,GetPixelOpacity(p));
if (image->colorspace == CMYKColorspace)
SetPixelIndex(splice_indexes+x,GetPixelIndex(indexes));
indexes++;
p++;
q++;
}
if (SyncCacheViewAuthenticPixels(splice_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,SpliceImageTag,progress,
splice_image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(progress,status) \
magick_number_threads(image,splice_image,splice_image->rows,1)
#endif
for (y=(ssize_t) (splice_geometry.y+splice_geometry.height);
y < (ssize_t) splice_image->rows; y++)
{
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict indexes,
*magick_restrict splice_indexes;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
if (status == MagickFalse)
continue;
if ((y < 0) || (y >= (ssize_t)splice_image->rows))
continue;
p=GetCacheViewVirtualPixels(image_view,0,y-(ssize_t) splice_geometry.height,
splice_image->columns,1,exception);
q=QueueCacheViewAuthenticPixels(splice_view,0,y,splice_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
indexes=GetCacheViewAuthenticIndexQueue(image_view);
splice_indexes=GetCacheViewAuthenticIndexQueue(splice_view);
for (x=0; x < columns; x++)
{
SetPixelRed(q,GetPixelRed(p));
SetPixelGreen(q,GetPixelGreen(p));
SetPixelBlue(q,GetPixelBlue(p));
SetPixelOpacity(q,OpaqueOpacity);
if (image->matte != MagickFalse)
SetPixelOpacity(q,GetPixelOpacity(p));
if (image->colorspace == CMYKColorspace)
SetPixelIndex(splice_indexes+x,GetPixelIndex(indexes));
indexes++;
p++;
q++;
}
for ( ; x < (ssize_t) (splice_geometry.x+splice_geometry.width); x++)
q++;
for ( ; x < (ssize_t) splice_image->columns; x++)
{
SetPixelRed(q,GetPixelRed(p));
SetPixelGreen(q,GetPixelGreen(p));
SetPixelBlue(q,GetPixelBlue(p));
SetPixelOpacity(q,OpaqueOpacity);
if (image->matte != MagickFalse)
SetPixelOpacity(q,GetPixelOpacity(p));
if (image->colorspace == CMYKColorspace)
SetPixelIndex(splice_indexes+x,GetPixelIndex(indexes));
indexes++;
p++;
q++;
}
if (SyncCacheViewAuthenticPixels(splice_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,SpliceImageTag,progress,
splice_image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
splice_view=DestroyCacheView(splice_view);
image_view=DestroyCacheView(image_view);
if (status == MagickFalse)
splice_image=DestroyImage(splice_image);
return(splice_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% T r a n s f o r m I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% TransformImage() is a convenience method that behaves like ResizeImage() or
% CropImage() but accepts scaling and/or cropping information as a region
% geometry specification. If the operation fails, the original image handle
% is left as is.
%
% This should only be used for single images.
%
% The format of the TransformImage method is:
%
% MagickBooleanType TransformImage(Image **image,const char *crop_geometry,
% const char *image_geometry)
%
% A description of each parameter follows:
%
% o image: the image The transformed image is returned as this parameter.
%
% o crop_geometry: A crop geometry string. This geometry defines a
% subregion of the image to crop.
%
% o image_geometry: An image geometry string. This geometry defines the
% final size of the image.
%
*/
/*
DANGER: This function destroys what it assumes to be a single image list.
If the input image is part of a larger list, all other images in that list
will be simply 'lost', not destroyed.
Also if the crop generates a list of images only the first image is resized.
And finally if the crop succeeds and the resize failed, you will get a
cropped image, as well as a 'false' or 'failed' report.
This function and should probably be deprecated in favor of direct calls
to CropImageToTiles() or ResizeImage(), as appropriate.
*/
MagickExport MagickBooleanType TransformImage(Image **image,
const char *crop_geometry,const char *image_geometry)
{
Image
*resize_image,
*transform_image;
MagickStatusType
flags;
RectangleInfo
geometry;
assert(image != (Image **) NULL);
assert((*image)->signature == MagickCoreSignature);
if ((*image)->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
transform_image=(*image);
if (crop_geometry != (const char *) NULL)
{
Image
*crop_image;
/*
Crop image to a user specified size.
*/
crop_image=CropImageToTiles(*image,crop_geometry,&(*image)->exception);
if (crop_image == (Image *) NULL)
transform_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception);
else
{
transform_image=DestroyImage(transform_image);
transform_image=GetFirstImageInList(crop_image);
}
*image=transform_image;
}
if (image_geometry == (const char *) NULL)
return(MagickTrue);
/*
Scale image to a user specified size.
*/
flags=ParseRegionGeometry(transform_image,image_geometry,&geometry,
&(*image)->exception);
(void) flags;
if ((transform_image->columns == geometry.width) &&
(transform_image->rows == geometry.height))
return(MagickTrue);
resize_image=ResizeImage(transform_image,geometry.width,geometry.height,
transform_image->filter,transform_image->blur,&(*image)->exception);
if (resize_image == (Image *) NULL)
return(MagickFalse);
transform_image=DestroyImage(transform_image);
transform_image=resize_image;
*image=transform_image;
return(MagickTrue);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% T r a n s f o r m I m a g e s %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% TransformImages() calls TransformImage() on each image of a sequence.
%
% The format of the TransformImage method is:
%
% MagickBooleanType TransformImages(Image **image,
% const char *crop_geometry,const char *image_geometry)
%
% A description of each parameter follows:
%
% o image: the image The transformed image is returned as this parameter.
%
% o crop_geometry: A crop geometry string. This geometry defines a
% subregion of the image to crop.
%
% o image_geometry: An image geometry string. This geometry defines the
% final size of the image.
%
*/
MagickExport MagickBooleanType TransformImages(Image **images,
const char *crop_geometry,const char *image_geometry)
{
Image
*image,
**image_list,
*transform_images;
MagickStatusType
status;
register ssize_t
i;
assert(images != (Image **) NULL);
assert((*images)->signature == MagickCoreSignature);
if ((*images)->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
(*images)->filename);
image_list=ImageListToArray(*images,&(*images)->exception);
if (image_list == (Image **) NULL)
return(MagickFalse);
status=MagickTrue;
transform_images=NewImageList();
for (i=0; image_list[i] != (Image *) NULL; i++)
{
image=image_list[i];
status&=TransformImage(&image,crop_geometry,image_geometry);
AppendImageToList(&transform_images,image);
}
*images=transform_images;
image_list=(Image **) RelinquishMagickMemory(image_list);
return(status != 0 ? MagickTrue : MagickFalse);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% T r a n s p o s e I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% TransposeImage() creates a horizontal mirror image by reflecting the pixels
% around the central y-axis while rotating them by 90 degrees.
%
% The format of the TransposeImage method is:
%
% Image *TransposeImage(const Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *TransposeImage(const Image *image,ExceptionInfo *exception)
{
#define TransposeImageTag "Transpose/Image"
CacheView
*image_view,
*transpose_view;
Image
*transpose_image;
MagickBooleanType
status;
MagickOffsetType
progress;
RectangleInfo
page;
ssize_t
y;
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
transpose_image=CloneImage(image,image->rows,image->columns,MagickTrue,
exception);
if (transpose_image == (Image *) NULL)
return((Image *) NULL);
/*
Transpose image.
*/
status=MagickTrue;
progress=0;
image_view=AcquireVirtualCacheView(image,exception);
transpose_view=AcquireAuthenticCacheView(transpose_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(progress,status) \
magick_number_threads(image,transpose_image,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict transpose_indexes,
*magick_restrict indexes;
register PixelPacket
*magick_restrict q;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,(ssize_t) image->rows-y-1,
image->columns,1,exception);
q=QueueCacheViewAuthenticPixels(transpose_view,(ssize_t) (image->rows-y-1),
0,1,transpose_image->rows,exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
(void) memcpy(q,p,(size_t) image->columns*sizeof(*q));
indexes=GetCacheViewAuthenticIndexQueue(image_view);
if (indexes != (IndexPacket *) NULL)
{
transpose_indexes=GetCacheViewAuthenticIndexQueue(transpose_view);
if (transpose_indexes != (IndexPacket *) NULL)
(void) memcpy(transpose_indexes,indexes,(size_t)
image->columns*sizeof(*transpose_indexes));
}
if (SyncCacheViewAuthenticPixels(transpose_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,TransposeImageTag,progress,
image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
transpose_view=DestroyCacheView(transpose_view);
image_view=DestroyCacheView(image_view);
transpose_image->type=image->type;
page=transpose_image->page;
Swap(page.width,page.height);
Swap(page.x,page.y);
transpose_image->page=page;
if (status == MagickFalse)
transpose_image=DestroyImage(transpose_image);
return(transpose_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% T r a n s v e r s e I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% TransverseImage() creates a vertical mirror image by reflecting the pixels
% around the central x-axis while rotating them by 270 degrees.
%
% The format of the TransverseImage method is:
%
% Image *TransverseImage(const Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *TransverseImage(const Image *image,ExceptionInfo *exception)
{
#define TransverseImageTag "Transverse/Image"
CacheView
*image_view,
*transverse_view;
Image
*transverse_image;
MagickBooleanType
status;
MagickOffsetType
progress;
RectangleInfo
page;
ssize_t
y;
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
transverse_image=CloneImage(image,image->rows,image->columns,MagickTrue,
exception);
if (transverse_image == (Image *) NULL)
return((Image *) NULL);
/*
Transverse image.
*/
status=MagickTrue;
progress=0;
image_view=AcquireVirtualCacheView(image,exception);
transverse_view=AcquireAuthenticCacheView(transverse_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(progress,status) \
magick_number_threads(image,transverse_image,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
MagickBooleanType
sync;
register const PixelPacket
*magick_restrict p;
register IndexPacket
*magick_restrict transverse_indexes,
*magick_restrict indexes;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
q=QueueCacheViewAuthenticPixels(transverse_view,(ssize_t) (image->rows-y-
1),0,1,transverse_image->rows,exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
q+=image->columns;
for (x=0; x < (ssize_t) image->columns; x++)
*--q=(*p++);
indexes=GetCacheViewAuthenticIndexQueue(image_view);
if (indexes != (IndexPacket *) NULL)
{
transverse_indexes=GetCacheViewAuthenticIndexQueue(transverse_view);
if (transverse_indexes != (IndexPacket *) NULL)
for (x=0; x < (ssize_t) image->columns; x++)
SetPixelIndex(transverse_indexes+image->columns-x-1,
GetPixelIndex(indexes+x));
}
sync=SyncCacheViewAuthenticPixels(transverse_view,exception);
if (sync == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,TransverseImageTag,progress,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
transverse_view=DestroyCacheView(transverse_view);
image_view=DestroyCacheView(image_view);
transverse_image->type=image->type;
page=transverse_image->page;
Swap(page.width,page.height);
Swap(page.x,page.y);
if (page.width != 0)
page.x=(ssize_t) (page.width-transverse_image->columns-page.x);
if (page.height != 0)
page.y=(ssize_t) (page.height-transverse_image->rows-page.y);
transverse_image->page=page;
if (status == MagickFalse)
transverse_image=DestroyImage(transverse_image);
return(transverse_image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% T r i m I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% TrimImage() trims pixels from the image edges. It allocates the memory
% necessary for the new Image structure and returns a pointer to the new
% image.
%
% The format of the TrimImage method is:
%
% Image *TrimImage(const Image *image,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *TrimImage(const Image *image,ExceptionInfo *exception)
{
RectangleInfo
geometry;
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
geometry=GetImageBoundingBox(image,exception);
if ((geometry.width == 0) || (geometry.height == 0))
{
Image
*crop_image;
crop_image=CloneImage(image,1,1,MagickTrue,exception);
if (crop_image == (Image *) NULL)
return((Image *) NULL);
crop_image->background_color.opacity=(Quantum) TransparentOpacity;
(void) SetImageBackgroundColor(crop_image);
crop_image->page=image->page;
crop_image->page.x=(-1);
crop_image->page.y=(-1);
return(crop_image);
}
geometry.x+=image->page.x;
geometry.y+=image->page.y;
return(CropImage(image,&geometry,exception));
}
| 32.84139 | 155 | 0.556933 | [
"geometry",
"transform",
"solid"
] |
9edc85f775ae1f81833e4a3129ddd13017964712 | 9,510 | h | C | include/flecs/private/vector.h | rziehl/flecs | b147cbc00b3447f936e9827977eb0f71fc119b11 | [
"MIT"
] | null | null | null | include/flecs/private/vector.h | rziehl/flecs | b147cbc00b3447f936e9827977eb0f71fc119b11 | [
"MIT"
] | null | null | null | include/flecs/private/vector.h | rziehl/flecs | b147cbc00b3447f936e9827977eb0f71fc119b11 | [
"MIT"
] | null | null | null | #ifndef FLECS_VECTOR_H
#define FLECS_VECTOR_H
#include "api_defines.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Public, so we can do compile-time offset calculation */
struct ecs_vector_t {
int32_t count;
int32_t size;
#ifndef NDEBUG
int64_t elem_size;
#endif
};
#define ECS_VECTOR_U(size, alignment) size, ECS_MAX(ECS_SIZEOF(ecs_vector_t), alignment)
#define ECS_VECTOR_T(T) ECS_VECTOR_U(ECS_SIZEOF(T), ECS_ALIGNOF(T))
/* Macro's for creating vector on stack */
#ifndef NDEBUG
#define ECS_VECTOR_VALUE(T, elem_count)\
{\
.elem_size = (int32_t)(ECS_SIZEOF(T)),\
.count = elem_count,\
.size = elem_count\
}
#else
#define ECS_VECTOR_VALUE(T, elem_count)\
{\
.count = elem_count,\
.size = elem_count\
}
#endif
#define ECS_VECTOR_DECL(name, T, elem_count)\
struct {\
union {\
ecs_vector_t vector;\
uint64_t align;\
} header;\
T array[elem_count];\
} __##name##_value = {\
.header.vector = ECS_VECTOR_VALUE(T, elem_count),\
};\
const ecs_vector_t *name = (ecs_vector_t*)&__##name##_value
#define ECS_VECTOR_IMPL(name, T, elems, elem_count)\
ecs_os_memcpy(__##name##_value.array, elems, sizeof(T) * elem_count)
#define ECS_VECTOR_STACK(name, T, elems, elem_count)\
ECS_VECTOR_DECL(name, T, elem_count);\
ECS_VECTOR_IMPL(name, T, elems, elem_count)
typedef struct ecs_vector_t ecs_vector_t;
typedef int (*ecs_comparator_t)(
const void* p1,
const void *p2);
FLECS_EXPORT
ecs_vector_t* _ecs_vector_new(
ecs_size_t elem_size,
int16_t offset,
int32_t elem_count);
#define ecs_vector_new(T, elem_count) \
_ecs_vector_new(ECS_VECTOR_T(T), elem_count)
#define ecs_vector_new_t(size, alignment, elem_count) \
_ecs_vector_new(ECS_VECTOR_U(size, alignment), elem_count)
FLECS_EXPORT
ecs_vector_t* _ecs_vector_from_array(
ecs_size_t elem_size,
int16_t offset,
int32_t elem_count,
void *array);
#define ecs_vector_from_array(T, elem_count, array)\
_ecs_vector_from_array(ECS_VECTOR_T(T), elem_count, array)
FLECS_EXPORT
void ecs_vector_free(
ecs_vector_t *vector);
FLECS_EXPORT
void ecs_vector_clear(
ecs_vector_t *vector);
FLECS_EXPORT
void* _ecs_vector_add(
ecs_vector_t **array_inout,
ecs_size_t elem_size,
int16_t offset);
#define ecs_vector_add(vector, T) \
(T*)_ecs_vector_add(vector, ECS_VECTOR_T(T))
#define ecs_vector_add_t(vector, size, alignment) \
_ecs_vector_add(vector, ECS_VECTOR_U(size, alignment))
FLECS_EXPORT
void* _ecs_vector_addn(
ecs_vector_t **array_inout,
ecs_size_t elem_size,
int16_t offset,
int32_t elem_count);
#define ecs_vector_addn(vector, T, elem_count) \
(T*)_ecs_vector_addn(vector, ECS_VECTOR_T(T), elem_count)
#define ecs_vector_addn_t(vector, size, alignment, elem_count) \
_ecs_vector_addn(vector, ECS_VECTOR_U(size, alignment), elem_count)
FLECS_EXPORT
void* _ecs_vector_get(
const ecs_vector_t *vector,
ecs_size_t elem_size,
int16_t offset,
int32_t index);
#define ecs_vector_get(vector, T, index) \
(T*)_ecs_vector_get(vector, ECS_VECTOR_T(T), index)
#define ecs_vector_get_t(vector, size, alignment, index) \
_ecs_vector_get(vector, ECS_VECTOR_U(size, alignment), index)
FLECS_EXPORT
void* _ecs_vector_last(
const ecs_vector_t *vector,
ecs_size_t elem_size,
int16_t offset);
#define ecs_vector_last(vector, T) \
_ecs_vector_last(vector, ECS_VECTOR_T(T))
FLECS_EXPORT
int32_t _ecs_vector_remove(
ecs_vector_t *vector,
ecs_size_t elem_size,
int16_t offset,
void *elem);
#define ecs_vector_remove(vector, T, index) \
_ecs_vector_remove(vector, ECS_VECTOR_T(T), index)
FLECS_EXPORT
void ecs_vector_remove_last(
ecs_vector_t *vector);
FLECS_EXPORT
bool _ecs_vector_pop(
ecs_vector_t *vector,
ecs_size_t elem_size,
int16_t offset,
void *value);
#define ecs_vector_pop(vector, T, value) \
_ecs_vector_pop(vector, ECS_VECTOR_T(T), value)
FLECS_EXPORT
int32_t _ecs_vector_move_index(
ecs_vector_t **dst,
ecs_vector_t *src,
ecs_size_t elem_size,
int16_t offset,
int32_t index);
#define ecs_vector_move_index(dst, src, T, index) \
_ecs_vector_move_index(dst, src, ECS_VECTOR_T(T), index)
FLECS_EXPORT
int32_t _ecs_vector_remove_index(
ecs_vector_t *vector,
ecs_size_t elem_size,
int16_t offset,
int32_t index);
#define ecs_vector_remove_index(vector, T, index) \
_ecs_vector_remove_index(vector, ECS_VECTOR_T(T), index)
#define ecs_vector_remove_index_t(vector, size, alignment, index) \
_ecs_vector_remove_index(vector, ECS_VECTOR_U(size, alignment), index)
FLECS_EXPORT
void _ecs_vector_reclaim(
ecs_vector_t **vector,
ecs_size_t elem_size,
int16_t offset);
#define ecs_vector_reclaim(vector, T)\
_ecs_vector_reclaim(vector, ECS_VECTOR_T(T))
FLECS_EXPORT
int32_t _ecs_vector_grow(
ecs_vector_t **vector,
ecs_size_t elem_size,
int16_t offset,
int32_t elem_count);
#define ecs_vector_grow(vector, T, size) \
_ecs_vector_grow(vector, ECS_VECTOR_T(T), size)
FLECS_EXPORT
int32_t _ecs_vector_set_size(
ecs_vector_t **vector,
ecs_size_t elem_size,
int16_t offset,
int32_t elem_count);
#define ecs_vector_set_size(vector, T, elem_count) \
_ecs_vector_set_size(vector, ECS_VECTOR_T(T), elem_count)
#define ecs_vector_set_size_t(vector, size, alignment, elem_count) \
_ecs_vector_set_size(vector, ECS_VECTOR_U(size, alignment), elem_count)
FLECS_EXPORT
int32_t _ecs_vector_set_count(
ecs_vector_t **vector,
ecs_size_t elem_size,
int16_t offset,
int32_t elem_count);
#define ecs_vector_set_count(vector, T, elem_count) \
_ecs_vector_set_count(vector, ECS_VECTOR_T(T), elem_count)
#define ecs_vector_set_count_t(vector, size, alignment, elem_count) \
_ecs_vector_set_count(vector, ECS_VECTOR_U(size, alignment), elem_count)
FLECS_EXPORT
int32_t _ecs_vector_set_min_size(
ecs_vector_t **array_inout,
ecs_size_t elem_size,
int16_t offset,
int32_t elem_count);
#define ecs_vector_set_min_size(vector, T, size) \
_ecs_vector_set_min_size(vector, ECS_VECTOR_T(T), size)
FLECS_EXPORT
int32_t _ecs_vector_set_min_count(
ecs_vector_t **vector_inout,
ecs_size_t elem_size,
int16_t offset,
int32_t elem_count);
#define ecs_vector_set_min_count(vector, T, size) \
_ecs_vector_set_min_count(vector, ECS_VECTOR_T(T), size)
FLECS_EXPORT
int32_t ecs_vector_count(
const ecs_vector_t *vector);
FLECS_EXPORT
int32_t ecs_vector_size(
const ecs_vector_t *vector);
FLECS_EXPORT
void* _ecs_vector_first(
const ecs_vector_t *vector,
ecs_size_t elem_size,
int16_t offset);
#define ecs_vector_first(vector, T) \
(T*)_ecs_vector_first(vector, ECS_VECTOR_T(T))
#define ecs_vector_first_t(vector, size, alignment) \
_ecs_vector_first(vector, ECS_VECTOR_U(size, alignment))
FLECS_EXPORT
void _ecs_vector_sort(
ecs_vector_t *vector,
ecs_size_t elem_size,
int16_t offset,
ecs_comparator_t compare_action);
#define ecs_vector_sort(vector, T, compare_action) \
_ecs_vector_sort(vector, ECS_VECTOR_T(T), compare_action)
FLECS_EXPORT
void _ecs_vector_memory(
const ecs_vector_t *vector,
ecs_size_t elem_size,
int16_t offset,
int32_t *allocd,
int32_t *used);
#define ecs_vector_memory(vector, T, allocd, used) \
_ecs_vector_memory(vector, ECS_VECTOR_T(T), allocd, used)
#define ecs_vector_memory_t(vector, size, alignment, allocd, used) \
_ecs_vector_memory(vector, ECS_VECTOR_U(size, alignment), allocd, used)
ecs_vector_t* _ecs_vector_copy(
const ecs_vector_t *src,
ecs_size_t elem_size,
int16_t offset);
#define ecs_vector_copy(src, T) \
_ecs_vector_copy(src, ECS_VECTOR_T(T))
#define ecs_vector_copy_t(src, size, alignment) \
_ecs_vector_copy(src, ECS_VECTOR_U(size, alignment))
#ifndef FLECS_LEGACY
#define ecs_vector_each(vector, T, var, ...)\
{\
int var##_i, var##_count = ecs_vector_count(vector);\
T* var##_array = ecs_vector_first(vector, T);\
for (var##_i = 0; var##_i < var##_count; var##_i ++) {\
T* var = &var##_array[var##_i];\
__VA_ARGS__\
}\
}
#endif
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
#ifndef FLECS_NO_CPP
#include <iostream>
namespace flecs {
template <typename T>
class vector {
public:
vector(int32_t count = 0) : m_vector( nullptr ) {
if (count) {
init(count);
}
}
vector(std::initializer_list<T> elems) : m_vector( nullptr) {
init(elems.size());
*this = elems;
}
void operator=(std::initializer_list<T> elems) {
for (auto elem : elems) {
this->add(elem);
}
}
void clear() {
ecs_vector_clear(m_vector);
}
void add(T& value) {
T* elem = ecs_vector_add(&m_vector, T);
*elem = value;
}
void add(T&& value) {
T* elem = ecs_vector_add(&m_vector, T);
*elem = value;
}
T& get(int32_t index) {
return ecs_vector_get(m_vector, T, index);
}
T& first() {
return ecs_vector_first(m_vector, T);
}
T& last() {
return ecs_vector_last(m_vector, T);
}
int32_t count() {
return ecs_vector_count(m_vector);
}
int32_t size() {
return ecs_vector_size(m_vector);
}
private:
void init(int32_t count) {
m_vector = ecs_vector_new(T, count);
}
ecs_vector_t *m_vector;
};
}
#endif
#endif
#endif
| 23.834586 | 88 | 0.713249 | [
"vector"
] |
9ee31bd618d880153b95e7b5fc8bb890105c0aa8 | 4,777 | h | C | src/dawn/native/metal/UtilsMetal.h | encounter/dawn-cmake | 64a23ce0ede5f232cc209b69d64164ede6810b65 | [
"Apache-2.0"
] | null | null | null | src/dawn/native/metal/UtilsMetal.h | encounter/dawn-cmake | 64a23ce0ede5f232cc209b69d64164ede6810b65 | [
"Apache-2.0"
] | null | null | null | src/dawn/native/metal/UtilsMetal.h | encounter/dawn-cmake | 64a23ce0ede5f232cc209b69d64164ede6810b65 | [
"Apache-2.0"
] | null | null | null | // Copyright 2019 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_DAWN_NATIVE_METAL_UTILSMETAL_H_
#define SRC_DAWN_NATIVE_METAL_UTILSMETAL_H_
#include "dawn/native/dawn_platform.h"
#include "dawn/native/metal/DeviceMTL.h"
#include "dawn/native/metal/ShaderModuleMTL.h"
#include "dawn/native/metal/TextureMTL.h"
#import <Metal/Metal.h>
namespace dawn::native {
struct ProgrammableStage;
struct EntryPointMetadata;
enum class SingleShaderStage;
} // namespace dawn::native
namespace dawn::native::metal {
MTLCompareFunction ToMetalCompareFunction(wgpu::CompareFunction compareFunction);
struct TextureBufferCopySplit {
static constexpr uint32_t kMaxTextureBufferCopyRegions = 3;
struct CopyInfo {
NSUInteger bufferOffset;
NSUInteger bytesPerRow;
NSUInteger bytesPerImage;
Origin3D textureOrigin;
Extent3D copyExtent;
};
uint32_t count = 0;
std::array<CopyInfo, kMaxTextureBufferCopyRegions> copies;
auto begin() const { return copies.begin(); }
auto end() const { return copies.begin() + count; }
};
TextureBufferCopySplit ComputeTextureBufferCopySplit(const Texture* texture,
uint32_t mipLevel,
Origin3D origin,
Extent3D copyExtent,
uint64_t bufferSize,
uint64_t bufferOffset,
uint32_t bytesPerRow,
uint32_t rowsPerImage,
Aspect aspect);
void EnsureDestinationTextureInitialized(CommandRecordingContext* commandContext,
Texture* texture,
const TextureCopy& dst,
const Extent3D& size);
MTLBlitOption ComputeMTLBlitOption(const Format& format, Aspect aspect);
// Helper function to create function with constant values wrapped in
// if available branch
MaybeError CreateMTLFunction(const ProgrammableStage& programmableStage,
SingleShaderStage singleShaderStage,
PipelineLayout* pipelineLayout,
ShaderModule::MetalFunctionData* functionData,
uint32_t sampleMask = 0xFFFFFFFF,
const RenderPipeline* renderPipeline = nullptr);
// Allow use MTLStoreActionStoreAndMultismapleResolve because the logic in the backend is
// first to compute what the "best" Metal render pass descriptor is, then fix it up if we
// are not on macOS 10.12 (i.e. the EmulateStoreAndMSAAResolve toggle is on).
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
constexpr MTLStoreAction kMTLStoreActionStoreAndMultisampleResolve =
MTLStoreActionStoreAndMultisampleResolve;
#pragma clang diagnostic pop
// Helper functions to encode Metal render passes that take care of multiple workarounds that
// happen at the render pass start and end. Because workarounds wrap the encoding of the render
// pass, the encoding must be entirely done by the `encodeInside` callback.
// At the end of this function, `commandContext` will have no encoder open.
using EncodeInsideRenderPass = std::function<MaybeError(id<MTLRenderCommandEncoder>)>;
MaybeError EncodeMetalRenderPass(Device* device,
CommandRecordingContext* commandContext,
MTLRenderPassDescriptor* mtlRenderPass,
uint32_t width,
uint32_t height,
EncodeInsideRenderPass encodeInside);
MaybeError EncodeEmptyMetalRenderPass(Device* device,
CommandRecordingContext* commandContext,
MTLRenderPassDescriptor* mtlRenderPass,
Extent3D size);
} // namespace dawn::native::metal
#endif // SRC_DAWN_NATIVE_METAL_UTILSMETAL_H_
| 43.825688 | 95 | 0.636173 | [
"render"
] |
9ee73bfcd9c1e40c2f72d95739b28a7e12fed1b0 | 300 | h | C | netpricing/utilities/follower_light_solver.h | minhcly95/netpricing | d2c88714b420ff21e99ebfa93ef6ae79adb438a0 | [
"MIT"
] | null | null | null | netpricing/utilities/follower_light_solver.h | minhcly95/netpricing | d2c88714b420ff21e99ebfa93ef6ae79adb438a0 | [
"MIT"
] | null | null | null | netpricing/utilities/follower_light_solver.h | minhcly95/netpricing | d2c88714b420ff21e99ebfa93ef6ae79adb438a0 | [
"MIT"
] | null | null | null | #pragma once
#include "follower_solver_base.h"
#include "../graph/light_graph.h"
struct follower_light_solver : public follower_solver_base
{
light_graph lgraph;
follower_light_solver(const problem& prob);
virtual std::vector<path> solve_impl(const std::vector<cost_type>& tolls) override;
};
| 21.428571 | 84 | 0.783333 | [
"vector"
] |
9ee75c9a9aa1bc12ba9a4cbfe6b3e741513a873d | 298,125 | c | C | linux-5.0.1/drivers/scsi/aic7xxx/aic79xx_core.c | Ponny035/LFS | 7ae2280072d71f43e395149d0ad0692483a24b70 | [
"Unlicense"
] | 1 | 2020-09-20T03:48:15.000Z | 2020-09-20T03:48:15.000Z | drivers/scsi/aic7xxx/aic79xx_core.c | YFShiftFinance/Unix | b82f0634af26793369af6df5fa9d374d0e09a54c | [
"MIT"
] | null | null | null | drivers/scsi/aic7xxx/aic79xx_core.c | YFShiftFinance/Unix | b82f0634af26793369af6df5fa9d374d0e09a54c | [
"MIT"
] | null | null | null | /*
* Core routines and tables shareable across OS platforms.
*
* Copyright (c) 1994-2002 Justin T. Gibbs.
* Copyright (c) 2000-2003 Adaptec Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#250 $
*/
#include "aic79xx_osm.h"
#include "aic79xx_inline.h"
#include "aicasm/aicasm_insformat.h"
/***************************** Lookup Tables **********************************/
static const char *const ahd_chip_names[] =
{
"NONE",
"aic7901",
"aic7902",
"aic7901A"
};
/*
* Hardware error codes.
*/
struct ahd_hard_error_entry {
uint8_t errno;
const char *errmesg;
};
static const struct ahd_hard_error_entry ahd_hard_errors[] = {
{ DSCTMOUT, "Discard Timer has timed out" },
{ ILLOPCODE, "Illegal Opcode in sequencer program" },
{ SQPARERR, "Sequencer Parity Error" },
{ DPARERR, "Data-path Parity Error" },
{ MPARERR, "Scratch or SCB Memory Parity Error" },
{ CIOPARERR, "CIOBUS Parity Error" },
};
static const u_int num_errors = ARRAY_SIZE(ahd_hard_errors);
static const struct ahd_phase_table_entry ahd_phase_table[] =
{
{ P_DATAOUT, MSG_NOOP, "in Data-out phase" },
{ P_DATAIN, MSG_INITIATOR_DET_ERR, "in Data-in phase" },
{ P_DATAOUT_DT, MSG_NOOP, "in DT Data-out phase" },
{ P_DATAIN_DT, MSG_INITIATOR_DET_ERR, "in DT Data-in phase" },
{ P_COMMAND, MSG_NOOP, "in Command phase" },
{ P_MESGOUT, MSG_NOOP, "in Message-out phase" },
{ P_STATUS, MSG_INITIATOR_DET_ERR, "in Status phase" },
{ P_MESGIN, MSG_PARITY_ERROR, "in Message-in phase" },
{ P_BUSFREE, MSG_NOOP, "while idle" },
{ 0, MSG_NOOP, "in unknown phase" }
};
/*
* In most cases we only wish to itterate over real phases, so
* exclude the last element from the count.
*/
static const u_int num_phases = ARRAY_SIZE(ahd_phase_table) - 1;
/* Our Sequencer Program */
#include "aic79xx_seq.h"
/**************************** Function Declarations ***************************/
static void ahd_handle_transmission_error(struct ahd_softc *ahd);
static void ahd_handle_lqiphase_error(struct ahd_softc *ahd,
u_int lqistat1);
static int ahd_handle_pkt_busfree(struct ahd_softc *ahd,
u_int busfreetime);
static int ahd_handle_nonpkt_busfree(struct ahd_softc *ahd);
static void ahd_handle_proto_violation(struct ahd_softc *ahd);
static void ahd_force_renegotiation(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static struct ahd_tmode_tstate*
ahd_alloc_tstate(struct ahd_softc *ahd,
u_int scsi_id, char channel);
#ifdef AHD_TARGET_MODE
static void ahd_free_tstate(struct ahd_softc *ahd,
u_int scsi_id, char channel, int force);
#endif
static void ahd_devlimited_syncrate(struct ahd_softc *ahd,
struct ahd_initiator_tinfo *,
u_int *period,
u_int *ppr_options,
role_t role);
static void ahd_update_neg_table(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
struct ahd_transinfo *tinfo);
static void ahd_update_pending_scbs(struct ahd_softc *ahd);
static void ahd_fetch_devinfo(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static void ahd_scb_devinfo(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
struct scb *scb);
static void ahd_setup_initiator_msgout(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
struct scb *scb);
static void ahd_build_transfer_msg(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static void ahd_construct_sdtr(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
u_int period, u_int offset);
static void ahd_construct_wdtr(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
u_int bus_width);
static void ahd_construct_ppr(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
u_int period, u_int offset,
u_int bus_width, u_int ppr_options);
static void ahd_clear_msg_state(struct ahd_softc *ahd);
static void ahd_handle_message_phase(struct ahd_softc *ahd);
typedef enum {
AHDMSG_1B,
AHDMSG_2B,
AHDMSG_EXT
} ahd_msgtype;
static int ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type,
u_int msgval, int full);
static int ahd_parse_msg(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static int ahd_handle_msg_reject(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static void ahd_handle_ign_wide_residue(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static void ahd_reinitialize_dataptrs(struct ahd_softc *ahd);
static void ahd_handle_devreset(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
u_int lun, cam_status status,
char *message, int verbose_level);
#ifdef AHD_TARGET_MODE
static void ahd_setup_target_msgin(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
struct scb *scb);
#endif
static u_int ahd_sglist_size(struct ahd_softc *ahd);
static u_int ahd_sglist_allocsize(struct ahd_softc *ahd);
static bus_dmamap_callback_t
ahd_dmamap_cb;
static void ahd_initialize_hscbs(struct ahd_softc *ahd);
static int ahd_init_scbdata(struct ahd_softc *ahd);
static void ahd_fini_scbdata(struct ahd_softc *ahd);
static void ahd_setup_iocell_workaround(struct ahd_softc *ahd);
static void ahd_iocell_first_selection(struct ahd_softc *ahd);
static void ahd_add_col_list(struct ahd_softc *ahd,
struct scb *scb, u_int col_idx);
static void ahd_rem_col_list(struct ahd_softc *ahd,
struct scb *scb);
static void ahd_chip_init(struct ahd_softc *ahd);
static void ahd_qinfifo_requeue(struct ahd_softc *ahd,
struct scb *prev_scb,
struct scb *scb);
static int ahd_qinfifo_count(struct ahd_softc *ahd);
static int ahd_search_scb_list(struct ahd_softc *ahd, int target,
char channel, int lun, u_int tag,
role_t role, uint32_t status,
ahd_search_action action,
u_int *list_head, u_int *list_tail,
u_int tid);
static void ahd_stitch_tid_list(struct ahd_softc *ahd,
u_int tid_prev, u_int tid_cur,
u_int tid_next);
static void ahd_add_scb_to_free_list(struct ahd_softc *ahd,
u_int scbid);
static u_int ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
u_int prev, u_int next, u_int tid);
static void ahd_reset_current_bus(struct ahd_softc *ahd);
static void ahd_stat_timer(struct timer_list *t);
#ifdef AHD_DUMP_SEQ
static void ahd_dumpseq(struct ahd_softc *ahd);
#endif
static void ahd_loadseq(struct ahd_softc *ahd);
static int ahd_check_patch(struct ahd_softc *ahd,
const struct patch **start_patch,
u_int start_instr, u_int *skip_addr);
static u_int ahd_resolve_seqaddr(struct ahd_softc *ahd,
u_int address);
static void ahd_download_instr(struct ahd_softc *ahd,
u_int instrptr, uint8_t *dconsts);
static int ahd_probe_stack_size(struct ahd_softc *ahd);
static int ahd_scb_active_in_fifo(struct ahd_softc *ahd,
struct scb *scb);
static void ahd_run_data_fifo(struct ahd_softc *ahd,
struct scb *scb);
#ifdef AHD_TARGET_MODE
static void ahd_queue_lstate_event(struct ahd_softc *ahd,
struct ahd_tmode_lstate *lstate,
u_int initiator_id,
u_int event_type,
u_int event_arg);
static void ahd_update_scsiid(struct ahd_softc *ahd,
u_int targid_mask);
static int ahd_handle_target_cmd(struct ahd_softc *ahd,
struct target_cmd *cmd);
#endif
static int ahd_abort_scbs(struct ahd_softc *ahd, int target,
char channel, int lun, u_int tag,
role_t role, uint32_t status);
static void ahd_alloc_scbs(struct ahd_softc *ahd);
static void ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl,
u_int scbid);
static void ahd_calc_residual(struct ahd_softc *ahd,
struct scb *scb);
static void ahd_clear_critical_section(struct ahd_softc *ahd);
static void ahd_clear_intstat(struct ahd_softc *ahd);
static void ahd_enable_coalescing(struct ahd_softc *ahd,
int enable);
static u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
static void ahd_freeze_devq(struct ahd_softc *ahd,
struct scb *scb);
static void ahd_handle_scb_status(struct ahd_softc *ahd,
struct scb *scb);
static const struct ahd_phase_table_entry* ahd_lookup_phase_entry(int phase);
static void ahd_shutdown(void *arg);
static void ahd_update_coalescing_values(struct ahd_softc *ahd,
u_int timer,
u_int maxcmds,
u_int mincmds);
static int ahd_verify_vpd_cksum(struct vpd_config *vpd);
static int ahd_wait_seeprom(struct ahd_softc *ahd);
static int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
int target, char channel, int lun,
u_int tag, role_t role);
static void ahd_reset_cmds_pending(struct ahd_softc *ahd);
/*************************** Interrupt Services *******************************/
static void ahd_run_qoutfifo(struct ahd_softc *ahd);
#ifdef AHD_TARGET_MODE
static void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
#endif
static void ahd_handle_hwerrint(struct ahd_softc *ahd);
static void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
static void ahd_handle_scsiint(struct ahd_softc *ahd,
u_int intstat);
/************************ Sequencer Execution Control *************************/
void
ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
{
if (ahd->src_mode == src && ahd->dst_mode == dst)
return;
#ifdef AHD_DEBUG
if (ahd->src_mode == AHD_MODE_UNKNOWN
|| ahd->dst_mode == AHD_MODE_UNKNOWN)
panic("Setting mode prior to saving it.\n");
if ((ahd_debug & AHD_SHOW_MODEPTR) != 0)
printk("%s: Setting mode 0x%x\n", ahd_name(ahd),
ahd_build_mode_state(ahd, src, dst));
#endif
ahd_outb(ahd, MODE_PTR, ahd_build_mode_state(ahd, src, dst));
ahd->src_mode = src;
ahd->dst_mode = dst;
}
static void
ahd_update_modes(struct ahd_softc *ahd)
{
ahd_mode_state mode_ptr;
ahd_mode src;
ahd_mode dst;
mode_ptr = ahd_inb(ahd, MODE_PTR);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MODEPTR) != 0)
printk("Reading mode 0x%x\n", mode_ptr);
#endif
ahd_extract_mode_state(ahd, mode_ptr, &src, &dst);
ahd_known_modes(ahd, src, dst);
}
static void
ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode,
ahd_mode dstmode, const char *file, int line)
{
#ifdef AHD_DEBUG
if ((srcmode & AHD_MK_MSK(ahd->src_mode)) == 0
|| (dstmode & AHD_MK_MSK(ahd->dst_mode)) == 0) {
panic("%s:%s:%d: Mode assertion failed.\n",
ahd_name(ahd), file, line);
}
#endif
}
#define AHD_ASSERT_MODES(ahd, source, dest) \
ahd_assert_modes(ahd, source, dest, __FILE__, __LINE__);
ahd_mode_state
ahd_save_modes(struct ahd_softc *ahd)
{
if (ahd->src_mode == AHD_MODE_UNKNOWN
|| ahd->dst_mode == AHD_MODE_UNKNOWN)
ahd_update_modes(ahd);
return (ahd_build_mode_state(ahd, ahd->src_mode, ahd->dst_mode));
}
void
ahd_restore_modes(struct ahd_softc *ahd, ahd_mode_state state)
{
ahd_mode src;
ahd_mode dst;
ahd_extract_mode_state(ahd, state, &src, &dst);
ahd_set_modes(ahd, src, dst);
}
/*
* Determine whether the sequencer has halted code execution.
* Returns non-zero status if the sequencer is stopped.
*/
int
ahd_is_paused(struct ahd_softc *ahd)
{
return ((ahd_inb(ahd, HCNTRL) & PAUSE) != 0);
}
/*
* Request that the sequencer stop and wait, indefinitely, for it
* to stop. The sequencer will only acknowledge that it is paused
* once it has reached an instruction boundary and PAUSEDIS is
* cleared in the SEQCTL register. The sequencer may use PAUSEDIS
* for critical sections.
*/
void
ahd_pause(struct ahd_softc *ahd)
{
ahd_outb(ahd, HCNTRL, ahd->pause);
/*
* Since the sequencer can disable pausing in a critical section, we
* must loop until it actually stops.
*/
while (ahd_is_paused(ahd) == 0)
;
}
/*
* Allow the sequencer to continue program execution.
* We check here to ensure that no additional interrupt
* sources that would cause the sequencer to halt have been
* asserted. If, for example, a SCSI bus reset is detected
* while we are fielding a different, pausing, interrupt type,
* we don't want to release the sequencer before going back
* into our interrupt handler and dealing with this new
* condition.
*/
void
ahd_unpause(struct ahd_softc *ahd)
{
/*
* Automatically restore our modes to those saved
* prior to the first change of the mode.
*/
if (ahd->saved_src_mode != AHD_MODE_UNKNOWN
&& ahd->saved_dst_mode != AHD_MODE_UNKNOWN) {
if ((ahd->flags & AHD_UPDATE_PEND_CMDS) != 0)
ahd_reset_cmds_pending(ahd);
ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
}
if ((ahd_inb(ahd, INTSTAT) & ~CMDCMPLT) == 0)
ahd_outb(ahd, HCNTRL, ahd->unpause);
ahd_known_modes(ahd, AHD_MODE_UNKNOWN, AHD_MODE_UNKNOWN);
}
/*********************** Scatter Gather List Handling *************************/
void *
ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
void *sgptr, dma_addr_t addr, bus_size_t len, int last)
{
scb->sg_count++;
if (sizeof(dma_addr_t) > 4
&& (ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg;
sg = (struct ahd_dma64_seg *)sgptr;
sg->addr = ahd_htole64(addr);
sg->len = ahd_htole32(len | (last ? AHD_DMA_LAST_SEG : 0));
return (sg + 1);
} else {
struct ahd_dma_seg *sg;
sg = (struct ahd_dma_seg *)sgptr;
sg->addr = ahd_htole32(addr & 0xFFFFFFFF);
sg->len = ahd_htole32(len | ((addr >> 8) & 0x7F000000)
| (last ? AHD_DMA_LAST_SEG : 0));
return (sg + 1);
}
}
static void
ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb)
{
/* XXX Handle target mode SCBs. */
scb->crc_retry_count = 0;
if ((scb->flags & SCB_PACKETIZED) != 0) {
/* XXX what about ACA?? It is type 4, but TAG_TYPE == 0x3. */
scb->hscb->task_attribute = scb->hscb->control & SCB_TAG_TYPE;
} else {
if (ahd_get_transfer_length(scb) & 0x01)
scb->hscb->task_attribute = SCB_XFERLEN_ODD;
else
scb->hscb->task_attribute = 0;
}
if (scb->hscb->cdb_len <= MAX_CDB_LEN_WITH_SENSE_ADDR
|| (scb->hscb->cdb_len & SCB_CDB_LEN_PTR) != 0)
scb->hscb->shared_data.idata.cdb_plus_saddr.sense_addr =
ahd_htole32(scb->sense_busaddr);
}
static void
ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb)
{
/*
* Copy the first SG into the "current" data ponter area.
*/
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg;
sg = (struct ahd_dma64_seg *)scb->sg_list;
scb->hscb->dataptr = sg->addr;
scb->hscb->datacnt = sg->len;
} else {
struct ahd_dma_seg *sg;
uint32_t *dataptr_words;
sg = (struct ahd_dma_seg *)scb->sg_list;
dataptr_words = (uint32_t*)&scb->hscb->dataptr;
dataptr_words[0] = sg->addr;
dataptr_words[1] = 0;
if ((ahd->flags & AHD_39BIT_ADDRESSING) != 0) {
uint64_t high_addr;
high_addr = ahd_le32toh(sg->len) & 0x7F000000;
scb->hscb->dataptr |= ahd_htole64(high_addr << 8);
}
scb->hscb->datacnt = sg->len;
}
/*
* Note where to find the SG entries in bus space.
* We also set the full residual flag which the
* sequencer will clear as soon as a data transfer
* occurs.
*/
scb->hscb->sgptr = ahd_htole32(scb->sg_list_busaddr|SG_FULL_RESID);
}
static void
ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb)
{
scb->hscb->sgptr = ahd_htole32(SG_LIST_NULL);
scb->hscb->dataptr = 0;
scb->hscb->datacnt = 0;
}
/************************** Memory mapping routines ***************************/
static void *
ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
{
dma_addr_t sg_offset;
/* sg_list_phys points to entry 1, not 0 */
sg_offset = sg_busaddr - (scb->sg_list_busaddr - ahd_sg_size(ahd));
return ((uint8_t *)scb->sg_list + sg_offset);
}
static uint32_t
ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
{
dma_addr_t sg_offset;
/* sg_list_phys points to entry 1, not 0 */
sg_offset = ((uint8_t *)sg - (uint8_t *)scb->sg_list)
- ahd_sg_size(ahd);
return (scb->sg_list_busaddr + sg_offset);
}
static void
ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op)
{
ahd_dmamap_sync(ahd, ahd->scb_data.hscb_dmat,
scb->hscb_map->dmamap,
/*offset*/(uint8_t*)scb->hscb - scb->hscb_map->vaddr,
/*len*/sizeof(*scb->hscb), op);
}
void
ahd_sync_sglist(struct ahd_softc *ahd, struct scb *scb, int op)
{
if (scb->sg_count == 0)
return;
ahd_dmamap_sync(ahd, ahd->scb_data.sg_dmat,
scb->sg_map->dmamap,
/*offset*/scb->sg_list_busaddr - ahd_sg_size(ahd),
/*len*/ahd_sg_size(ahd) * scb->sg_count, op);
}
static void
ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op)
{
ahd_dmamap_sync(ahd, ahd->scb_data.sense_dmat,
scb->sense_map->dmamap,
/*offset*/scb->sense_busaddr,
/*len*/AHD_SENSE_BUFSIZE, op);
}
#ifdef AHD_TARGET_MODE
static uint32_t
ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index)
{
return (((uint8_t *)&ahd->targetcmds[index])
- (uint8_t *)ahd->qoutfifo);
}
#endif
/*********************** Miscellaneous Support Functions ***********************/
/*
* Return pointers to the transfer negotiation information
* for the specified our_id/remote_id pair.
*/
struct ahd_initiator_tinfo *
ahd_fetch_transinfo(struct ahd_softc *ahd, char channel, u_int our_id,
u_int remote_id, struct ahd_tmode_tstate **tstate)
{
/*
* Transfer data structures are stored from the perspective
* of the target role. Since the parameters for a connection
* in the initiator role to a given target are the same as
* when the roles are reversed, we pretend we are the target.
*/
if (channel == 'B')
our_id += 8;
*tstate = ahd->enabled_targets[our_id];
return (&(*tstate)->transinfo[remote_id]);
}
uint16_t
ahd_inw(struct ahd_softc *ahd, u_int port)
{
/*
* Read high byte first as some registers increment
* or have other side effects when the low byte is
* read.
*/
uint16_t r = ahd_inb(ahd, port+1) << 8;
return r | ahd_inb(ahd, port);
}
void
ahd_outw(struct ahd_softc *ahd, u_int port, u_int value)
{
/*
* Write low byte first to accommodate registers
* such as PRGMCNT where the order maters.
*/
ahd_outb(ahd, port, value & 0xFF);
ahd_outb(ahd, port+1, (value >> 8) & 0xFF);
}
uint32_t
ahd_inl(struct ahd_softc *ahd, u_int port)
{
return ((ahd_inb(ahd, port))
| (ahd_inb(ahd, port+1) << 8)
| (ahd_inb(ahd, port+2) << 16)
| (ahd_inb(ahd, port+3) << 24));
}
void
ahd_outl(struct ahd_softc *ahd, u_int port, uint32_t value)
{
ahd_outb(ahd, port, (value) & 0xFF);
ahd_outb(ahd, port+1, ((value) >> 8) & 0xFF);
ahd_outb(ahd, port+2, ((value) >> 16) & 0xFF);
ahd_outb(ahd, port+3, ((value) >> 24) & 0xFF);
}
uint64_t
ahd_inq(struct ahd_softc *ahd, u_int port)
{
return ((ahd_inb(ahd, port))
| (ahd_inb(ahd, port+1) << 8)
| (ahd_inb(ahd, port+2) << 16)
| (ahd_inb(ahd, port+3) << 24)
| (((uint64_t)ahd_inb(ahd, port+4)) << 32)
| (((uint64_t)ahd_inb(ahd, port+5)) << 40)
| (((uint64_t)ahd_inb(ahd, port+6)) << 48)
| (((uint64_t)ahd_inb(ahd, port+7)) << 56));
}
void
ahd_outq(struct ahd_softc *ahd, u_int port, uint64_t value)
{
ahd_outb(ahd, port, value & 0xFF);
ahd_outb(ahd, port+1, (value >> 8) & 0xFF);
ahd_outb(ahd, port+2, (value >> 16) & 0xFF);
ahd_outb(ahd, port+3, (value >> 24) & 0xFF);
ahd_outb(ahd, port+4, (value >> 32) & 0xFF);
ahd_outb(ahd, port+5, (value >> 40) & 0xFF);
ahd_outb(ahd, port+6, (value >> 48) & 0xFF);
ahd_outb(ahd, port+7, (value >> 56) & 0xFF);
}
u_int
ahd_get_scbptr(struct ahd_softc *ahd)
{
AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
return (ahd_inb(ahd, SCBPTR) | (ahd_inb(ahd, SCBPTR + 1) << 8));
}
void
ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr)
{
AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
ahd_outb(ahd, SCBPTR, scbptr & 0xFF);
ahd_outb(ahd, SCBPTR+1, (scbptr >> 8) & 0xFF);
}
#if 0 /* unused */
static u_int
ahd_get_hnscb_qoff(struct ahd_softc *ahd)
{
return (ahd_inw_atomic(ahd, HNSCB_QOFF));
}
#endif
static void
ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value)
{
ahd_outw_atomic(ahd, HNSCB_QOFF, value);
}
#if 0 /* unused */
static u_int
ahd_get_hescb_qoff(struct ahd_softc *ahd)
{
return (ahd_inb(ahd, HESCB_QOFF));
}
#endif
static void
ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value)
{
ahd_outb(ahd, HESCB_QOFF, value);
}
static u_int
ahd_get_snscb_qoff(struct ahd_softc *ahd)
{
u_int oldvalue;
AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
oldvalue = ahd_inw(ahd, SNSCB_QOFF);
ahd_outw(ahd, SNSCB_QOFF, oldvalue);
return (oldvalue);
}
static void
ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value)
{
AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
ahd_outw(ahd, SNSCB_QOFF, value);
}
#if 0 /* unused */
static u_int
ahd_get_sescb_qoff(struct ahd_softc *ahd)
{
AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
return (ahd_inb(ahd, SESCB_QOFF));
}
#endif
static void
ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value)
{
AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
ahd_outb(ahd, SESCB_QOFF, value);
}
#if 0 /* unused */
static u_int
ahd_get_sdscb_qoff(struct ahd_softc *ahd)
{
AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
return (ahd_inb(ahd, SDSCB_QOFF) | (ahd_inb(ahd, SDSCB_QOFF + 1) << 8));
}
#endif
static void
ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value)
{
AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
ahd_outb(ahd, SDSCB_QOFF, value & 0xFF);
ahd_outb(ahd, SDSCB_QOFF+1, (value >> 8) & 0xFF);
}
u_int
ahd_inb_scbram(struct ahd_softc *ahd, u_int offset)
{
u_int value;
/*
* Workaround PCI-X Rev A. hardware bug.
* After a host read of SCB memory, the chip
* may become confused into thinking prefetch
* was required. This starts the discard timer
* running and can cause an unexpected discard
* timer interrupt. The work around is to read
* a normal register prior to the exhaustion of
* the discard timer. The mode pointer register
* has no side effects and so serves well for
* this purpose.
*
* Razor #528
*/
value = ahd_inb(ahd, offset);
if ((ahd->bugs & AHD_PCIX_SCBRAM_RD_BUG) != 0)
ahd_inb(ahd, MODE_PTR);
return (value);
}
u_int
ahd_inw_scbram(struct ahd_softc *ahd, u_int offset)
{
return (ahd_inb_scbram(ahd, offset)
| (ahd_inb_scbram(ahd, offset+1) << 8));
}
static uint32_t
ahd_inl_scbram(struct ahd_softc *ahd, u_int offset)
{
return (ahd_inw_scbram(ahd, offset)
| (ahd_inw_scbram(ahd, offset+2) << 16));
}
static uint64_t
ahd_inq_scbram(struct ahd_softc *ahd, u_int offset)
{
return (ahd_inl_scbram(ahd, offset)
| ((uint64_t)ahd_inl_scbram(ahd, offset+4)) << 32);
}
struct scb *
ahd_lookup_scb(struct ahd_softc *ahd, u_int tag)
{
struct scb* scb;
if (tag >= AHD_SCB_MAX)
return (NULL);
scb = ahd->scb_data.scbindex[tag];
if (scb != NULL)
ahd_sync_scb(ahd, scb,
BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
return (scb);
}
static void
ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb)
{
struct hardware_scb *q_hscb;
struct map_node *q_hscb_map;
uint32_t saved_hscb_busaddr;
/*
* Our queuing method is a bit tricky. The card
* knows in advance which HSCB (by address) to download,
* and we can't disappoint it. To achieve this, the next
* HSCB to download is saved off in ahd->next_queued_hscb.
* When we are called to queue "an arbitrary scb",
* we copy the contents of the incoming HSCB to the one
* the sequencer knows about, swap HSCB pointers and
* finally assign the SCB to the tag indexed location
* in the scb_array. This makes sure that we can still
* locate the correct SCB by SCB_TAG.
*/
q_hscb = ahd->next_queued_hscb;
q_hscb_map = ahd->next_queued_hscb_map;
saved_hscb_busaddr = q_hscb->hscb_busaddr;
memcpy(q_hscb, scb->hscb, sizeof(*scb->hscb));
q_hscb->hscb_busaddr = saved_hscb_busaddr;
q_hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
/* Now swap HSCB pointers. */
ahd->next_queued_hscb = scb->hscb;
ahd->next_queued_hscb_map = scb->hscb_map;
scb->hscb = q_hscb;
scb->hscb_map = q_hscb_map;
/* Now define the mapping from tag to SCB in the scbindex */
ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb;
}
/*
* Tell the sequencer about a new transaction to execute.
*/
void
ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb)
{
ahd_swap_with_next_hscb(ahd, scb);
if (SCBID_IS_NULL(SCB_GET_TAG(scb)))
panic("Attempt to queue invalid SCB tag %x\n",
SCB_GET_TAG(scb));
/*
* Keep a history of SCBs we've downloaded in the qinfifo.
*/
ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);
ahd->qinfifonext++;
if (scb->sg_count != 0)
ahd_setup_data_scb(ahd, scb);
else
ahd_setup_noxfer_scb(ahd, scb);
ahd_setup_scb_common(ahd, scb);
/*
* Make sure our data is consistent from the
* perspective of the adapter.
*/
ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_QUEUE) != 0) {
uint64_t host_dataptr;
host_dataptr = ahd_le64toh(scb->hscb->dataptr);
printk("%s: Queueing SCB %d:0x%x bus addr 0x%x - 0x%x%x/0x%x\n",
ahd_name(ahd),
SCB_GET_TAG(scb), scb->hscb->scsiid,
ahd_le32toh(scb->hscb->hscb_busaddr),
(u_int)((host_dataptr >> 32) & 0xFFFFFFFF),
(u_int)(host_dataptr & 0xFFFFFFFF),
ahd_le32toh(scb->hscb->datacnt));
}
#endif
/* Tell the adapter about the newly queued SCB */
ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
}
/************************** Interrupt Processing ******************************/
static void
ahd_sync_qoutfifo(struct ahd_softc *ahd, int op)
{
ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap,
/*offset*/0,
/*len*/AHD_SCB_MAX * sizeof(struct ahd_completion), op);
}
static void
ahd_sync_tqinfifo(struct ahd_softc *ahd, int op)
{
#ifdef AHD_TARGET_MODE
if ((ahd->flags & AHD_TARGETROLE) != 0) {
ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
ahd->shared_data_map.dmamap,
ahd_targetcmd_offset(ahd, 0),
sizeof(struct target_cmd) * AHD_TMODE_CMDS,
op);
}
#endif
}
/*
* See if the firmware has posted any completed commands
* into our in-core command complete fifos.
*/
#define AHD_RUN_QOUTFIFO 0x1
#define AHD_RUN_TQINFIFO 0x2
static u_int
ahd_check_cmdcmpltqueues(struct ahd_softc *ahd)
{
u_int retval;
retval = 0;
ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap,
/*offset*/ahd->qoutfifonext * sizeof(*ahd->qoutfifo),
/*len*/sizeof(*ahd->qoutfifo), BUS_DMASYNC_POSTREAD);
if (ahd->qoutfifo[ahd->qoutfifonext].valid_tag
== ahd->qoutfifonext_valid_tag)
retval |= AHD_RUN_QOUTFIFO;
#ifdef AHD_TARGET_MODE
if ((ahd->flags & AHD_TARGETROLE) != 0
&& (ahd->flags & AHD_TQINFIFO_BLOCKED) == 0) {
ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
ahd->shared_data_map.dmamap,
ahd_targetcmd_offset(ahd, ahd->tqinfifofnext),
/*len*/sizeof(struct target_cmd),
BUS_DMASYNC_POSTREAD);
if (ahd->targetcmds[ahd->tqinfifonext].cmd_valid != 0)
retval |= AHD_RUN_TQINFIFO;
}
#endif
return (retval);
}
/*
* Catch an interrupt from the adapter
*/
int
ahd_intr(struct ahd_softc *ahd)
{
u_int intstat;
if ((ahd->pause & INTEN) == 0) {
/*
* Our interrupt is not enabled on the chip
* and may be disabled for re-entrancy reasons,
* so just return. This is likely just a shared
* interrupt.
*/
return (0);
}
/*
* Instead of directly reading the interrupt status register,
* infer the cause of the interrupt by checking our in-core
* completion queues. This avoids a costly PCI bus read in
* most cases.
*/
if ((ahd->flags & AHD_ALL_INTERRUPTS) == 0
&& (ahd_check_cmdcmpltqueues(ahd) != 0))
intstat = CMDCMPLT;
else
intstat = ahd_inb(ahd, INTSTAT);
if ((intstat & INT_PEND) == 0)
return (0);
if (intstat & CMDCMPLT) {
ahd_outb(ahd, CLRINT, CLRCMDINT);
/*
* Ensure that the chip sees that we've cleared
* this interrupt before we walk the output fifo.
* Otherwise, we may, due to posted bus writes,
* clear the interrupt after we finish the scan,
* and after the sequencer has added new entries
* and asserted the interrupt again.
*/
if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
if (ahd_is_paused(ahd)) {
/*
* Potentially lost SEQINT.
* If SEQINTCODE is non-zero,
* simulate the SEQINT.
*/
if (ahd_inb(ahd, SEQINTCODE) != NO_SEQINT)
intstat |= SEQINT;
}
} else {
ahd_flush_device_writes(ahd);
}
ahd_run_qoutfifo(ahd);
ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket]++;
ahd->cmdcmplt_total++;
#ifdef AHD_TARGET_MODE
if ((ahd->flags & AHD_TARGETROLE) != 0)
ahd_run_tqinfifo(ahd, /*paused*/FALSE);
#endif
}
/*
* Handle statuses that may invalidate our cached
* copy of INTSTAT separately.
*/
if (intstat == 0xFF && (ahd->features & AHD_REMOVABLE) != 0) {
/* Hot eject. Do nothing */
} else if (intstat & HWERRINT) {
ahd_handle_hwerrint(ahd);
} else if ((intstat & (PCIINT|SPLTINT)) != 0) {
ahd->bus_intr(ahd);
} else {
if ((intstat & SEQINT) != 0)
ahd_handle_seqint(ahd, intstat);
if ((intstat & SCSIINT) != 0)
ahd_handle_scsiint(ahd, intstat);
}
return (1);
}
/******************************** Private Inlines *****************************/
static inline void
ahd_assert_atn(struct ahd_softc *ahd)
{
ahd_outb(ahd, SCSISIGO, ATNO);
}
/*
* Determine if the current connection has a packetized
* agreement. This does not necessarily mean that we
* are currently in a packetized transfer. We could
* just as easily be sending or receiving a message.
*/
static int
ahd_currently_packetized(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
int packetized;
saved_modes = ahd_save_modes(ahd);
if ((ahd->bugs & AHD_PKTIZED_STATUS_BUG) != 0) {
/*
* The packetized bit refers to the last
* connection, not the current one. Check
* for non-zero LQISTATE instead.
*/
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
packetized = ahd_inb(ahd, LQISTATE) != 0;
} else {
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
packetized = ahd_inb(ahd, LQISTAT2) & PACKETIZED;
}
ahd_restore_modes(ahd, saved_modes);
return (packetized);
}
static inline int
ahd_set_active_fifo(struct ahd_softc *ahd)
{
u_int active_fifo;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
active_fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO;
switch (active_fifo) {
case 0:
case 1:
ahd_set_modes(ahd, active_fifo, active_fifo);
return (1);
default:
return (0);
}
}
static inline void
ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
{
ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
}
/*
* Determine whether the sequencer reported a residual
* for this SCB/transaction.
*/
static inline void
ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
{
uint32_t sgptr;
sgptr = ahd_le32toh(scb->hscb->sgptr);
if ((sgptr & SG_STATUS_VALID) != 0)
ahd_calc_residual(ahd, scb);
}
static inline void
ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
{
uint32_t sgptr;
sgptr = ahd_le32toh(scb->hscb->sgptr);
if ((sgptr & SG_STATUS_VALID) != 0)
ahd_handle_scb_status(ahd, scb);
else
ahd_done(ahd, scb);
}
/************************* Sequencer Execution Control ************************/
/*
* Restart the sequencer program from address zero
*/
static void
ahd_restart(struct ahd_softc *ahd)
{
ahd_pause(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
/* No more pending messages */
ahd_clear_msg_state(ahd);
ahd_outb(ahd, SCSISIGO, 0); /* De-assert BSY */
ahd_outb(ahd, MSG_OUT, MSG_NOOP); /* No message to send */
ahd_outb(ahd, SXFRCTL1, ahd_inb(ahd, SXFRCTL1) & ~BITBUCKET);
ahd_outb(ahd, SEQINTCTL, 0);
ahd_outb(ahd, LASTPHASE, P_BUSFREE);
ahd_outb(ahd, SEQ_FLAGS, 0);
ahd_outb(ahd, SAVED_SCSIID, 0xFF);
ahd_outb(ahd, SAVED_LUN, 0xFF);
/*
* Ensure that the sequencer's idea of TQINPOS
* matches our own. The sequencer increments TQINPOS
* only after it sees a DMA complete and a reset could
* occur before the increment leaving the kernel to believe
* the command arrived but the sequencer to not.
*/
ahd_outb(ahd, TQINPOS, ahd->tqinfifonext);
/* Always allow reselection */
ahd_outb(ahd, SCSISEQ1,
ahd_inb(ahd, SCSISEQ_TEMPLATE) & (ENSELI|ENRSELI|ENAUTOATNP));
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
/*
* Clear any pending sequencer interrupt. It is no
* longer relevant since we're resetting the Program
* Counter.
*/
ahd_outb(ahd, CLRINT, CLRSEQINT);
ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET);
ahd_unpause(ahd);
}
static void
ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
{
ahd_mode_state saved_modes;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_FIFOS) != 0)
printk("%s: Clearing FIFO %d\n", ahd_name(ahd), fifo);
#endif
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, fifo, fifo);
ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT);
if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0)
ahd_outb(ahd, CCSGCTL, CCSGRESET);
ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
ahd_outb(ahd, SG_STATE, 0);
ahd_restore_modes(ahd, saved_modes);
}
/************************* Input/Output Queues ********************************/
/*
* Flush and completed commands that are sitting in the command
* complete queues down on the chip but have yet to be dma'ed back up.
*/
static void
ahd_flush_qoutfifo(struct ahd_softc *ahd)
{
struct scb *scb;
ahd_mode_state saved_modes;
u_int saved_scbptr;
u_int ccscbctl;
u_int scbid;
u_int next_scbid;
saved_modes = ahd_save_modes(ahd);
/*
* Flush the good status FIFO for completed packetized commands.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
saved_scbptr = ahd_get_scbptr(ahd);
while ((ahd_inb(ahd, LQISTAT2) & LQIGSAVAIL) != 0) {
u_int fifo_mode;
u_int i;
scbid = ahd_inw(ahd, GSFIFO);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printk("%s: Warning - GSFIFO SCB %d invalid\n",
ahd_name(ahd), scbid);
continue;
}
/*
* Determine if this transaction is still active in
* any FIFO. If it is, we must flush that FIFO to
* the host before completing the command.
*/
fifo_mode = 0;
rescan_fifos:
for (i = 0; i < 2; i++) {
/* Toggle to the other mode. */
fifo_mode ^= 1;
ahd_set_modes(ahd, fifo_mode, fifo_mode);
if (ahd_scb_active_in_fifo(ahd, scb) == 0)
continue;
ahd_run_data_fifo(ahd, scb);
/*
* Running this FIFO may cause a CFG4DATA for
* this same transaction to assert in the other
* FIFO or a new snapshot SAVEPTRS interrupt
* in this FIFO. Even running a FIFO may not
* clear the transaction if we are still waiting
* for data to drain to the host. We must loop
* until the transaction is not active in either
* FIFO just to be sure. Reset our loop counter
* so we will visit both FIFOs again before
* declaring this transaction finished. We
* also delay a bit so that status has a chance
* to change before we look at this FIFO again.
*/
ahd_delay(200);
goto rescan_fifos;
}
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_set_scbptr(ahd, scbid);
if ((ahd_inb_scbram(ahd, SCB_SGPTR) & SG_LIST_NULL) == 0
&& ((ahd_inb_scbram(ahd, SCB_SGPTR) & SG_FULL_RESID) != 0
|| (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR)
& SG_LIST_NULL) != 0)) {
u_int comp_head;
/*
* The transfer completed with a residual.
* Place this SCB on the complete DMA list
* so that we update our in-core copy of the
* SCB before completing the command.
*/
ahd_outb(ahd, SCB_SCSI_STATUS, 0);
ahd_outb(ahd, SCB_SGPTR,
ahd_inb_scbram(ahd, SCB_SGPTR)
| SG_STATUS_VALID);
ahd_outw(ahd, SCB_TAG, scbid);
ahd_outw(ahd, SCB_NEXT_COMPLETE, SCB_LIST_NULL);
comp_head = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
if (SCBID_IS_NULL(comp_head)) {
ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, scbid);
ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, scbid);
} else {
u_int tail;
tail = ahd_inw(ahd, COMPLETE_DMA_SCB_TAIL);
ahd_set_scbptr(ahd, tail);
ahd_outw(ahd, SCB_NEXT_COMPLETE, scbid);
ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, scbid);
ahd_set_scbptr(ahd, scbid);
}
} else
ahd_complete_scb(ahd, scb);
}
ahd_set_scbptr(ahd, saved_scbptr);
/*
* Setup for command channel portion of flush.
*/
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
/*
* Wait for any inprogress DMA to complete and clear DMA state
* if this is for an SCB in the qinfifo.
*/
while (((ccscbctl = ahd_inb(ahd, CCSCBCTL)) & (CCARREN|CCSCBEN)) != 0) {
if ((ccscbctl & (CCSCBDIR|CCARREN)) == (CCSCBDIR|CCARREN)) {
if ((ccscbctl & ARRDONE) != 0)
break;
} else if ((ccscbctl & CCSCBDONE) != 0)
break;
ahd_delay(200);
}
/*
* We leave the sequencer to cleanup in the case of DMA's to
* update the qoutfifo. In all other cases (DMA's to the
* chip or a push of an SCB from the COMPLETE_DMA_SCB list),
* we disable the DMA engine so that the sequencer will not
* attempt to handle the DMA completion.
*/
if ((ccscbctl & CCSCBDIR) != 0 || (ccscbctl & ARRDONE) != 0)
ahd_outb(ahd, CCSCBCTL, ccscbctl & ~(CCARREN|CCSCBEN));
/*
* Complete any SCBs that just finished
* being DMA'ed into the qoutfifo.
*/
ahd_run_qoutfifo(ahd);
saved_scbptr = ahd_get_scbptr(ahd);
/*
* Manually update/complete any completed SCBs that are waiting to be
* DMA'ed back up to the host.
*/
scbid = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
while (!SCBID_IS_NULL(scbid)) {
uint8_t *hscb_ptr;
u_int i;
ahd_set_scbptr(ahd, scbid);
next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printk("%s: Warning - DMA-up and complete "
"SCB %d invalid\n", ahd_name(ahd), scbid);
continue;
}
hscb_ptr = (uint8_t *)scb->hscb;
for (i = 0; i < sizeof(struct hardware_scb); i++)
*hscb_ptr++ = ahd_inb_scbram(ahd, SCB_BASE + i);
ahd_complete_scb(ahd, scb);
scbid = next_scbid;
}
ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL);
ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, SCB_LIST_NULL);
scbid = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD);
while (!SCBID_IS_NULL(scbid)) {
ahd_set_scbptr(ahd, scbid);
next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printk("%s: Warning - Complete Qfrz SCB %d invalid\n",
ahd_name(ahd), scbid);
continue;
}
ahd_complete_scb(ahd, scb);
scbid = next_scbid;
}
ahd_outw(ahd, COMPLETE_ON_QFREEZE_HEAD, SCB_LIST_NULL);
scbid = ahd_inw(ahd, COMPLETE_SCB_HEAD);
while (!SCBID_IS_NULL(scbid)) {
ahd_set_scbptr(ahd, scbid);
next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printk("%s: Warning - Complete SCB %d invalid\n",
ahd_name(ahd), scbid);
continue;
}
ahd_complete_scb(ahd, scb);
scbid = next_scbid;
}
ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL);
/*
* Restore state.
*/
ahd_set_scbptr(ahd, saved_scbptr);
ahd_restore_modes(ahd, saved_modes);
ahd->flags |= AHD_UPDATE_PEND_CMDS;
}
/*
* Determine if an SCB for a packetized transaction
* is active in a FIFO.
*/
static int
ahd_scb_active_in_fifo(struct ahd_softc *ahd, struct scb *scb)
{
/*
* The FIFO is only active for our transaction if
* the SCBPTR matches the SCB's ID and the firmware
* has installed a handler for the FIFO or we have
* a pending SAVEPTRS or CFG4DATA interrupt.
*/
if (ahd_get_scbptr(ahd) != SCB_GET_TAG(scb)
|| ((ahd_inb(ahd, LONGJMP_ADDR+1) & INVALID_ADDR) != 0
&& (ahd_inb(ahd, SEQINTSRC) & (CFG4DATA|SAVEPTRS)) == 0))
return (0);
return (1);
}
/*
* Run a data fifo to completion for a transaction we know
* has completed across the SCSI bus (good status has been
* received). We are already set to the correct FIFO mode
* on entry to this routine.
*
* This function attempts to operate exactly as the firmware
* would when running this FIFO. Care must be taken to update
* this routine any time the firmware's FIFO algorithm is
* changed.
*/
static void
ahd_run_data_fifo(struct ahd_softc *ahd, struct scb *scb)
{
u_int seqintsrc;
seqintsrc = ahd_inb(ahd, SEQINTSRC);
if ((seqintsrc & CFG4DATA) != 0) {
uint32_t datacnt;
uint32_t sgptr;
/*
* Clear full residual flag.
*/
sgptr = ahd_inl_scbram(ahd, SCB_SGPTR) & ~SG_FULL_RESID;
ahd_outb(ahd, SCB_SGPTR, sgptr);
/*
* Load datacnt and address.
*/
datacnt = ahd_inl_scbram(ahd, SCB_DATACNT);
if ((datacnt & AHD_DMA_LAST_SEG) != 0) {
sgptr |= LAST_SEG;
ahd_outb(ahd, SG_STATE, 0);
} else
ahd_outb(ahd, SG_STATE, LOADING_NEEDED);
ahd_outq(ahd, HADDR, ahd_inq_scbram(ahd, SCB_DATAPTR));
ahd_outl(ahd, HCNT, datacnt & AHD_SG_LEN_MASK);
ahd_outb(ahd, SG_CACHE_PRE, sgptr);
ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN);
/*
* Initialize Residual Fields.
*/
ahd_outb(ahd, SCB_RESIDUAL_DATACNT+3, datacnt >> 24);
ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr & SG_PTR_MASK);
/*
* Mark the SCB as having a FIFO in use.
*/
ahd_outb(ahd, SCB_FIFO_USE_COUNT,
ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) + 1);
/*
* Install a "fake" handler for this FIFO.
*/
ahd_outw(ahd, LONGJMP_ADDR, 0);
/*
* Notify the hardware that we have satisfied
* this sequencer interrupt.
*/
ahd_outb(ahd, CLRSEQINTSRC, CLRCFG4DATA);
} else if ((seqintsrc & SAVEPTRS) != 0) {
uint32_t sgptr;
uint32_t resid;
if ((ahd_inb(ahd, LONGJMP_ADDR+1)&INVALID_ADDR) != 0) {
/*
* Snapshot Save Pointers. All that
* is necessary to clear the snapshot
* is a CLRCHN.
*/
goto clrchn;
}
/*
* Disable S/G fetch so the DMA engine
* is available to future users.
*/
if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0)
ahd_outb(ahd, CCSGCTL, 0);
ahd_outb(ahd, SG_STATE, 0);
/*
* Flush the data FIFO. Strickly only
* necessary for Rev A parts.
*/
ahd_outb(ahd, DFCNTRL, ahd_inb(ahd, DFCNTRL) | FIFOFLUSH);
/*
* Calculate residual.
*/
sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
resid = ahd_inl(ahd, SHCNT);
resid |= ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT+3) << 24;
ahd_outl(ahd, SCB_RESIDUAL_DATACNT, resid);
if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG) == 0) {
/*
* Must back up to the correct S/G element.
* Typically this just means resetting our
* low byte to the offset in the SG_CACHE,
* but if we wrapped, we have to correct
* the other bytes of the sgptr too.
*/
if ((ahd_inb(ahd, SG_CACHE_SHADOW) & 0x80) != 0
&& (sgptr & 0x80) == 0)
sgptr -= 0x100;
sgptr &= ~0xFF;
sgptr |= ahd_inb(ahd, SG_CACHE_SHADOW)
& SG_ADDR_MASK;
ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr);
ahd_outb(ahd, SCB_RESIDUAL_DATACNT + 3, 0);
} else if ((resid & AHD_SG_LEN_MASK) == 0) {
ahd_outb(ahd, SCB_RESIDUAL_SGPTR,
sgptr | SG_LIST_NULL);
}
/*
* Save Pointers.
*/
ahd_outq(ahd, SCB_DATAPTR, ahd_inq(ahd, SHADDR));
ahd_outl(ahd, SCB_DATACNT, resid);
ahd_outl(ahd, SCB_SGPTR, sgptr);
ahd_outb(ahd, CLRSEQINTSRC, CLRSAVEPTRS);
ahd_outb(ahd, SEQIMODE,
ahd_inb(ahd, SEQIMODE) | ENSAVEPTRS);
/*
* If the data is to the SCSI bus, we are
* done, otherwise wait for FIFOEMP.
*/
if ((ahd_inb(ahd, DFCNTRL) & DIRECTION) != 0)
goto clrchn;
} else if ((ahd_inb(ahd, SG_STATE) & LOADING_NEEDED) != 0) {
uint32_t sgptr;
uint64_t data_addr;
uint32_t data_len;
u_int dfcntrl;
/*
* Disable S/G fetch so the DMA engine
* is available to future users. We won't
* be using the DMA engine to load segments.
*/
if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) {
ahd_outb(ahd, CCSGCTL, 0);
ahd_outb(ahd, SG_STATE, LOADING_NEEDED);
}
/*
* Wait for the DMA engine to notice that the
* host transfer is enabled and that there is
* space in the S/G FIFO for new segments before
* loading more segments.
*/
if ((ahd_inb(ahd, DFSTATUS) & PRELOAD_AVAIL) != 0
&& (ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0) {
/*
* Determine the offset of the next S/G
* element to load.
*/
sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
sgptr &= SG_PTR_MASK;
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
data_addr = sg->addr;
data_len = sg->len;
sgptr += sizeof(*sg);
} else {
struct ahd_dma_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
data_addr = sg->len & AHD_SG_HIGH_ADDR_MASK;
data_addr <<= 8;
data_addr |= sg->addr;
data_len = sg->len;
sgptr += sizeof(*sg);
}
/*
* Update residual information.
*/
ahd_outb(ahd, SCB_RESIDUAL_DATACNT+3, data_len >> 24);
ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr);
/*
* Load the S/G.
*/
if (data_len & AHD_DMA_LAST_SEG) {
sgptr |= LAST_SEG;
ahd_outb(ahd, SG_STATE, 0);
}
ahd_outq(ahd, HADDR, data_addr);
ahd_outl(ahd, HCNT, data_len & AHD_SG_LEN_MASK);
ahd_outb(ahd, SG_CACHE_PRE, sgptr & 0xFF);
/*
* Advertise the segment to the hardware.
*/
dfcntrl = ahd_inb(ahd, DFCNTRL)|PRELOADEN|HDMAEN;
if ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0) {
/*
* Use SCSIENWRDIS so that SCSIEN
* is never modified by this
* operation.
*/
dfcntrl |= SCSIENWRDIS;
}
ahd_outb(ahd, DFCNTRL, dfcntrl);
}
} else if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG_DONE) != 0) {
/*
* Transfer completed to the end of SG list
* and has flushed to the host.
*/
ahd_outb(ahd, SCB_SGPTR,
ahd_inb_scbram(ahd, SCB_SGPTR) | SG_LIST_NULL);
goto clrchn;
} else if ((ahd_inb(ahd, DFSTATUS) & FIFOEMP) != 0) {
clrchn:
/*
* Clear any handler for this FIFO, decrement
* the FIFO use count for the SCB, and release
* the FIFO.
*/
ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
ahd_outb(ahd, SCB_FIFO_USE_COUNT,
ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) - 1);
ahd_outb(ahd, DFFSXFRCTL, CLRCHN);
}
}
/*
* Look for entries in the QoutFIFO that have completed.
* The valid_tag completion field indicates the validity
* of the entry - the valid value toggles each time through
* the queue. We use the sg_status field in the completion
* entry to avoid referencing the hscb if the completion
* occurred with no errors and no residual. sg_status is
* a copy of the first byte (little endian) of the sgptr
* hscb field.
*/
static void
ahd_run_qoutfifo(struct ahd_softc *ahd)
{
struct ahd_completion *completion;
struct scb *scb;
u_int scb_index;
if ((ahd->flags & AHD_RUNNING_QOUTFIFO) != 0)
panic("ahd_run_qoutfifo recursion");
ahd->flags |= AHD_RUNNING_QOUTFIFO;
ahd_sync_qoutfifo(ahd, BUS_DMASYNC_POSTREAD);
for (;;) {
completion = &ahd->qoutfifo[ahd->qoutfifonext];
if (completion->valid_tag != ahd->qoutfifonext_valid_tag)
break;
scb_index = ahd_le16toh(completion->tag);
scb = ahd_lookup_scb(ahd, scb_index);
if (scb == NULL) {
printk("%s: WARNING no command for scb %d "
"(cmdcmplt)\nQOUTPOS = %d\n",
ahd_name(ahd), scb_index,
ahd->qoutfifonext);
ahd_dump_card_state(ahd);
} else if ((completion->sg_status & SG_STATUS_VALID) != 0) {
ahd_handle_scb_status(ahd, scb);
} else {
ahd_done(ahd, scb);
}
ahd->qoutfifonext = (ahd->qoutfifonext+1) & (AHD_QOUT_SIZE-1);
if (ahd->qoutfifonext == 0)
ahd->qoutfifonext_valid_tag ^= QOUTFIFO_ENTRY_VALID;
}
ahd->flags &= ~AHD_RUNNING_QOUTFIFO;
}
/************************* Interrupt Handling *********************************/
static void
ahd_handle_hwerrint(struct ahd_softc *ahd)
{
/*
* Some catastrophic hardware error has occurred.
* Print it for the user and disable the controller.
*/
int i;
int error;
error = ahd_inb(ahd, ERROR);
for (i = 0; i < num_errors; i++) {
if ((error & ahd_hard_errors[i].errno) != 0)
printk("%s: hwerrint, %s\n",
ahd_name(ahd), ahd_hard_errors[i].errmesg);
}
ahd_dump_card_state(ahd);
panic("BRKADRINT");
/* Tell everyone that this HBA is no longer available */
ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS,
CAM_LUN_WILDCARD, SCB_LIST_NULL, ROLE_UNKNOWN,
CAM_NO_HBA);
/* Tell the system that this controller has gone away. */
ahd_free(ahd);
}
#ifdef AHD_DEBUG
static void
ahd_dump_sglist(struct scb *scb)
{
int i;
if (scb->sg_count > 0) {
if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg_list;
sg_list = (struct ahd_dma64_seg*)scb->sg_list;
for (i = 0; i < scb->sg_count; i++) {
uint64_t addr;
uint32_t len;
addr = ahd_le64toh(sg_list[i].addr);
len = ahd_le32toh(sg_list[i].len);
printk("sg[%d] - Addr 0x%x%x : Length %d%s\n",
i,
(uint32_t)((addr >> 32) & 0xFFFFFFFF),
(uint32_t)(addr & 0xFFFFFFFF),
sg_list[i].len & AHD_SG_LEN_MASK,
(sg_list[i].len & AHD_DMA_LAST_SEG)
? " Last" : "");
}
} else {
struct ahd_dma_seg *sg_list;
sg_list = (struct ahd_dma_seg*)scb->sg_list;
for (i = 0; i < scb->sg_count; i++) {
uint32_t len;
len = ahd_le32toh(sg_list[i].len);
printk("sg[%d] - Addr 0x%x%x : Length %d%s\n",
i,
(len & AHD_SG_HIGH_ADDR_MASK) >> 24,
ahd_le32toh(sg_list[i].addr),
len & AHD_SG_LEN_MASK,
len & AHD_DMA_LAST_SEG ? " Last" : "");
}
}
}
}
#endif /* AHD_DEBUG */
static void
ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
{
u_int seqintcode;
/*
* Save the sequencer interrupt code and clear the SEQINT
* bit. We will unpause the sequencer, if appropriate,
* after servicing the request.
*/
seqintcode = ahd_inb(ahd, SEQINTCODE);
ahd_outb(ahd, CLRINT, CLRSEQINT);
if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
/*
* Unpause the sequencer and let it clear
* SEQINT by writing NO_SEQINT to it. This
* will cause the sequencer to be paused again,
* which is the expected state of this routine.
*/
ahd_unpause(ahd);
while (!ahd_is_paused(ahd))
;
ahd_outb(ahd, CLRINT, CLRSEQINT);
}
ahd_update_modes(ahd);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printk("%s: Handle Seqint Called for code %d\n",
ahd_name(ahd), seqintcode);
#endif
switch (seqintcode) {
case ENTERING_NONPACK:
{
struct scb *scb;
u_int scbid;
AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
/*
* Somehow need to know if this
* is from a selection or reselection.
* From that, we can determine target
* ID so we at least have an I_T nexus.
*/
} else {
ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
ahd_outb(ahd, SAVED_LUN, scb->hscb->lun);
ahd_outb(ahd, SEQ_FLAGS, 0x0);
}
if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0
&& (ahd_inb(ahd, SCSISIGO) & ATNO) != 0) {
/*
* Phase change after read stream with
* CRC error with P0 asserted on last
* packet.
*/
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
printk("%s: Assuming LQIPHASE_NLQ with "
"P0 assertion\n", ahd_name(ahd));
#endif
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
printk("%s: Entering NONPACK\n", ahd_name(ahd));
#endif
break;
}
case INVALID_SEQINT:
printk("%s: Invalid Sequencer interrupt occurred, "
"resetting channel.\n",
ahd_name(ahd));
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
ahd_dump_card_state(ahd);
#endif
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
break;
case STATUS_OVERRUN:
{
struct scb *scb;
u_int scbid;
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL)
ahd_print_path(ahd, scb);
else
printk("%s: ", ahd_name(ahd));
printk("SCB %d Packetized Status Overrun", scbid);
ahd_dump_card_state(ahd);
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
break;
}
case CFG4ISTAT_INTR:
{
struct scb *scb;
u_int scbid;
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
ahd_dump_card_state(ahd);
printk("CFG4ISTAT: Free SCB %d referenced", scbid);
panic("For safety");
}
ahd_outq(ahd, HADDR, scb->sense_busaddr);
ahd_outw(ahd, HCNT, AHD_SENSE_BUFSIZE);
ahd_outb(ahd, HCNT + 2, 0);
ahd_outb(ahd, SG_CACHE_PRE, SG_LAST_SEG);
ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN);
break;
}
case ILLEGAL_PHASE:
{
u_int bus_phase;
bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
printk("%s: ILLEGAL_PHASE 0x%x\n",
ahd_name(ahd), bus_phase);
switch (bus_phase) {
case P_DATAOUT:
case P_DATAIN:
case P_DATAOUT_DT:
case P_DATAIN_DT:
case P_MESGOUT:
case P_STATUS:
case P_MESGIN:
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
printk("%s: Issued Bus Reset.\n", ahd_name(ahd));
break;
case P_COMMAND:
{
struct ahd_devinfo devinfo;
struct scb *scb;
struct ahd_initiator_tinfo *targ_info;
struct ahd_tmode_tstate *tstate;
struct ahd_transinfo *tinfo;
u_int scbid;
/*
* If a target takes us into the command phase
* assume that it has been externally reset and
* has thus lost our previous packetized negotiation
* agreement. Since we have not sent an identify
* message and may not have fully qualified the
* connection, we change our command to TUR, assert
* ATN and ABORT the task when we go to message in
* phase. The OSM will see the REQUEUE_REQUEST
* status and retry the command.
*/
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printk("Invalid phase with no valid SCB. "
"Resetting bus.\n");
ahd_reset_channel(ahd, 'A',
/*Initiate Reset*/TRUE);
break;
}
ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb),
SCB_GET_TARGET(ahd, scb),
SCB_GET_LUN(scb),
SCB_GET_CHANNEL(ahd, scb),
ROLE_INITIATOR);
targ_info = ahd_fetch_transinfo(ahd,
devinfo.channel,
devinfo.our_scsiid,
devinfo.target,
&tstate);
tinfo = &targ_info->curr;
ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_ACTIVE, /*paused*/TRUE);
ahd_set_syncrate(ahd, &devinfo, /*period*/0,
/*offset*/0, /*ppr_options*/0,
AHD_TRANS_ACTIVE, /*paused*/TRUE);
/* Hand-craft TUR command */
ahd_outb(ahd, SCB_CDB_STORE, 0);
ahd_outb(ahd, SCB_CDB_STORE+1, 0);
ahd_outb(ahd, SCB_CDB_STORE+2, 0);
ahd_outb(ahd, SCB_CDB_STORE+3, 0);
ahd_outb(ahd, SCB_CDB_STORE+4, 0);
ahd_outb(ahd, SCB_CDB_STORE+5, 0);
ahd_outb(ahd, SCB_CDB_LEN, 6);
scb->hscb->control &= ~(TAG_ENB|SCB_TAG_TYPE);
scb->hscb->control |= MK_MESSAGE;
ahd_outb(ahd, SCB_CONTROL, scb->hscb->control);
ahd_outb(ahd, MSG_OUT, HOST_MSG);
ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
/*
* The lun is 0, regardless of the SCB's lun
* as we have not sent an identify message.
*/
ahd_outb(ahd, SAVED_LUN, 0);
ahd_outb(ahd, SEQ_FLAGS, 0);
ahd_assert_atn(ahd);
scb->flags &= ~SCB_PACKETIZED;
scb->flags |= SCB_ABORT|SCB_EXTERNAL_RESET;
ahd_freeze_devq(ahd, scb);
ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
ahd_freeze_scb(scb);
/* Notify XPT */
ahd_send_async(ahd, devinfo.channel, devinfo.target,
CAM_LUN_WILDCARD, AC_SENT_BDR);
/*
* Allow the sequencer to continue with
* non-pack processing.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, CLRLQOINT1, CLRLQOPHACHGINPKT);
if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) {
ahd_outb(ahd, CLRLQOINT1, 0);
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
ahd_print_path(ahd, scb);
printk("Unexpected command phase from "
"packetized target\n");
}
#endif
break;
}
}
break;
}
case CFG4OVERRUN:
{
struct scb *scb;
u_int scb_index;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
printk("%s: CFG4OVERRUN mode = %x\n", ahd_name(ahd),
ahd_inb(ahd, MODE_PTR));
}
#endif
scb_index = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scb_index);
if (scb == NULL) {
/*
* Attempt to transfer to an SCB that is
* not outstanding.
*/
ahd_assert_atn(ahd);
ahd_outb(ahd, MSG_OUT, HOST_MSG);
ahd->msgout_buf[0] = MSG_ABORT_TASK;
ahd->msgout_len = 1;
ahd->msgout_index = 0;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
/*
* Clear status received flag to prevent any
* attempt to complete this bogus SCB.
*/
ahd_outb(ahd, SCB_CONTROL,
ahd_inb_scbram(ahd, SCB_CONTROL)
& ~STATUS_RCVD);
}
break;
}
case DUMP_CARD_STATE:
{
ahd_dump_card_state(ahd);
break;
}
case PDATA_REINIT:
{
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
printk("%s: PDATA_REINIT - DFCNTRL = 0x%x "
"SG_CACHE_SHADOW = 0x%x\n",
ahd_name(ahd), ahd_inb(ahd, DFCNTRL),
ahd_inb(ahd, SG_CACHE_SHADOW));
}
#endif
ahd_reinitialize_dataptrs(ahd);
break;
}
case HOST_MSG_LOOP:
{
struct ahd_devinfo devinfo;
/*
* The sequencer has encountered a message phase
* that requires host assistance for completion.
* While handling the message phase(s), we will be
* notified by the sequencer after each byte is
* transferred so we can track bus phase changes.
*
* If this is the first time we've seen a HOST_MSG_LOOP
* interrupt, initialize the state of the host message
* loop.
*/
ahd_fetch_devinfo(ahd, &devinfo);
if (ahd->msg_type == MSG_TYPE_NONE) {
struct scb *scb;
u_int scb_index;
u_int bus_phase;
bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
if (bus_phase != P_MESGIN
&& bus_phase != P_MESGOUT) {
printk("ahd_intr: HOST_MSG_LOOP bad "
"phase 0x%x\n", bus_phase);
/*
* Probably transitioned to bus free before
* we got here. Just punt the message.
*/
ahd_dump_card_state(ahd);
ahd_clear_intstat(ahd);
ahd_restart(ahd);
return;
}
scb_index = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scb_index);
if (devinfo.role == ROLE_INITIATOR) {
if (bus_phase == P_MESGOUT)
ahd_setup_initiator_msgout(ahd,
&devinfo,
scb);
else {
ahd->msg_type =
MSG_TYPE_INITIATOR_MSGIN;
ahd->msgin_index = 0;
}
}
#ifdef AHD_TARGET_MODE
else {
if (bus_phase == P_MESGOUT) {
ahd->msg_type =
MSG_TYPE_TARGET_MSGOUT;
ahd->msgin_index = 0;
}
else
ahd_setup_target_msgin(ahd,
&devinfo,
scb);
}
#endif
}
ahd_handle_message_phase(ahd);
break;
}
case NO_MATCH:
{
/* Ensure we don't leave the selection hardware on */
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
printk("%s:%c:%d: no active SCB for reconnecting "
"target - issuing BUS DEVICE RESET\n",
ahd_name(ahd), 'A', ahd_inb(ahd, SELID) >> 4);
printk("SAVED_SCSIID == 0x%x, SAVED_LUN == 0x%x, "
"REG0 == 0x%x ACCUM = 0x%x\n",
ahd_inb(ahd, SAVED_SCSIID), ahd_inb(ahd, SAVED_LUN),
ahd_inw(ahd, REG0), ahd_inb(ahd, ACCUM));
printk("SEQ_FLAGS == 0x%x, SCBPTR == 0x%x, BTT == 0x%x, "
"SINDEX == 0x%x\n",
ahd_inb(ahd, SEQ_FLAGS), ahd_get_scbptr(ahd),
ahd_find_busy_tcl(ahd,
BUILD_TCL(ahd_inb(ahd, SAVED_SCSIID),
ahd_inb(ahd, SAVED_LUN))),
ahd_inw(ahd, SINDEX));
printk("SELID == 0x%x, SCB_SCSIID == 0x%x, SCB_LUN == 0x%x, "
"SCB_CONTROL == 0x%x\n",
ahd_inb(ahd, SELID), ahd_inb_scbram(ahd, SCB_SCSIID),
ahd_inb_scbram(ahd, SCB_LUN),
ahd_inb_scbram(ahd, SCB_CONTROL));
printk("SCSIBUS[0] == 0x%x, SCSISIGI == 0x%x\n",
ahd_inb(ahd, SCSIBUS), ahd_inb(ahd, SCSISIGI));
printk("SXFRCTL0 == 0x%x\n", ahd_inb(ahd, SXFRCTL0));
printk("SEQCTL0 == 0x%x\n", ahd_inb(ahd, SEQCTL0));
ahd_dump_card_state(ahd);
ahd->msgout_buf[0] = MSG_BUS_DEV_RESET;
ahd->msgout_len = 1;
ahd->msgout_index = 0;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
ahd_outb(ahd, MSG_OUT, HOST_MSG);
ahd_assert_atn(ahd);
break;
}
case PROTO_VIOLATION:
{
ahd_handle_proto_violation(ahd);
break;
}
case IGN_WIDE_RES:
{
struct ahd_devinfo devinfo;
ahd_fetch_devinfo(ahd, &devinfo);
ahd_handle_ign_wide_residue(ahd, &devinfo);
break;
}
case BAD_PHASE:
{
u_int lastphase;
lastphase = ahd_inb(ahd, LASTPHASE);
printk("%s:%c:%d: unknown scsi bus phase %x, "
"lastphase = 0x%x. Attempting to continue\n",
ahd_name(ahd), 'A',
SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)),
lastphase, ahd_inb(ahd, SCSISIGI));
break;
}
case MISSED_BUSFREE:
{
u_int lastphase;
lastphase = ahd_inb(ahd, LASTPHASE);
printk("%s:%c:%d: Missed busfree. "
"Lastphase = 0x%x, Curphase = 0x%x\n",
ahd_name(ahd), 'A',
SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)),
lastphase, ahd_inb(ahd, SCSISIGI));
ahd_restart(ahd);
return;
}
case DATA_OVERRUN:
{
/*
* When the sequencer detects an overrun, it
* places the controller in "BITBUCKET" mode
* and allows the target to complete its transfer.
* Unfortunately, none of the counters get updated
* when the controller is in this mode, so we have
* no way of knowing how large the overrun was.
*/
struct scb *scb;
u_int scbindex;
#ifdef AHD_DEBUG
u_int lastphase;
#endif
scbindex = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbindex);
#ifdef AHD_DEBUG
lastphase = ahd_inb(ahd, LASTPHASE);
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
ahd_print_path(ahd, scb);
printk("data overrun detected %s. Tag == 0x%x.\n",
ahd_lookup_phase_entry(lastphase)->phasemsg,
SCB_GET_TAG(scb));
ahd_print_path(ahd, scb);
printk("%s seen Data Phase. Length = %ld. "
"NumSGs = %d.\n",
ahd_inb(ahd, SEQ_FLAGS) & DPHASE
? "Have" : "Haven't",
ahd_get_transfer_length(scb), scb->sg_count);
ahd_dump_sglist(scb);
}
#endif
/*
* Set this and it will take effect when the
* target does a command complete.
*/
ahd_freeze_devq(ahd, scb);
ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
ahd_freeze_scb(scb);
break;
}
case MKMSG_FAILED:
{
struct ahd_devinfo devinfo;
struct scb *scb;
u_int scbid;
ahd_fetch_devinfo(ahd, &devinfo);
printk("%s:%c:%d:%d: Attempt to issue message failed\n",
ahd_name(ahd), devinfo.channel, devinfo.target,
devinfo.lun);
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL
&& (scb->flags & SCB_RECOVERY_SCB) != 0)
/*
* Ensure that we didn't put a second instance of this
* SCB into the QINFIFO.
*/
ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
SCB_GET_CHANNEL(ahd, scb),
SCB_GET_LUN(scb), SCB_GET_TAG(scb),
ROLE_INITIATOR, /*status*/0,
SEARCH_REMOVE);
ahd_outb(ahd, SCB_CONTROL,
ahd_inb_scbram(ahd, SCB_CONTROL) & ~MK_MESSAGE);
break;
}
case TASKMGMT_FUNC_COMPLETE:
{
u_int scbid;
struct scb *scb;
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL) {
u_int lun;
u_int tag;
cam_status error;
ahd_print_path(ahd, scb);
printk("Task Management Func 0x%x Complete\n",
scb->hscb->task_management);
lun = CAM_LUN_WILDCARD;
tag = SCB_LIST_NULL;
switch (scb->hscb->task_management) {
case SIU_TASKMGMT_ABORT_TASK:
tag = SCB_GET_TAG(scb);
case SIU_TASKMGMT_ABORT_TASK_SET:
case SIU_TASKMGMT_CLEAR_TASK_SET:
lun = scb->hscb->lun;
error = CAM_REQ_ABORTED;
ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
'A', lun, tag, ROLE_INITIATOR,
error);
break;
case SIU_TASKMGMT_LUN_RESET:
lun = scb->hscb->lun;
case SIU_TASKMGMT_TARGET_RESET:
{
struct ahd_devinfo devinfo;
ahd_scb_devinfo(ahd, &devinfo, scb);
error = CAM_BDR_SENT;
ahd_handle_devreset(ahd, &devinfo, lun,
CAM_BDR_SENT,
lun != CAM_LUN_WILDCARD
? "Lun Reset"
: "Target Reset",
/*verbose_level*/0);
break;
}
default:
panic("Unexpected TaskMgmt Func\n");
break;
}
}
break;
}
case TASKMGMT_CMD_CMPLT_OKAY:
{
u_int scbid;
struct scb *scb;
/*
* An ABORT TASK TMF failed to be delivered before
* the targeted command completed normally.
*/
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL) {
/*
* Remove the second instance of this SCB from
* the QINFIFO if it is still there.
*/
ahd_print_path(ahd, scb);
printk("SCB completes before TMF\n");
/*
* Handle losing the race. Wait until any
* current selection completes. We will then
* set the TMF back to zero in this SCB so that
* the sequencer doesn't bother to issue another
* sequencer interrupt for its completion.
*/
while ((ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0
&& (ahd_inb(ahd, SSTAT0) & SELDO) == 0
&& (ahd_inb(ahd, SSTAT1) & SELTO) == 0)
;
ahd_outb(ahd, SCB_TASK_MANAGEMENT, 0);
ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
SCB_GET_CHANNEL(ahd, scb),
SCB_GET_LUN(scb), SCB_GET_TAG(scb),
ROLE_INITIATOR, /*status*/0,
SEARCH_REMOVE);
}
break;
}
case TRACEPOINT0:
case TRACEPOINT1:
case TRACEPOINT2:
case TRACEPOINT3:
printk("%s: Tracepoint %d\n", ahd_name(ahd),
seqintcode - TRACEPOINT0);
break;
case NO_SEQINT:
break;
case SAW_HWERR:
ahd_handle_hwerrint(ahd);
break;
default:
printk("%s: Unexpected SEQINTCODE %d\n", ahd_name(ahd),
seqintcode);
break;
}
/*
* The sequencer is paused immediately on
* a SEQINT, so we should restart it when
* we're done.
*/
ahd_unpause(ahd);
}
static void
ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
{
struct scb *scb;
u_int status0;
u_int status3;
u_int status;
u_int lqistat1;
u_int lqostat0;
u_int scbid;
u_int busfreetime;
ahd_update_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
status3 = ahd_inb(ahd, SSTAT3) & (NTRAMPERR|OSRAMPERR);
status0 = ahd_inb(ahd, SSTAT0) & (IOERR|OVERRUN|SELDI|SELDO);
status = ahd_inb(ahd, SSTAT1) & (SELTO|SCSIRSTI|BUSFREE|SCSIPERR);
lqistat1 = ahd_inb(ahd, LQISTAT1);
lqostat0 = ahd_inb(ahd, LQOSTAT0);
busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME;
/*
* Ignore external resets after a bus reset.
*/
if (((status & SCSIRSTI) != 0) && (ahd->flags & AHD_BUS_RESET_ACTIVE)) {
ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
return;
}
/*
* Clear bus reset flag
*/
ahd->flags &= ~AHD_BUS_RESET_ACTIVE;
if ((status0 & (SELDI|SELDO)) != 0) {
u_int simode0;
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
simode0 = ahd_inb(ahd, SIMODE0);
status0 &= simode0 & (IOERR|OVERRUN|SELDI|SELDO);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
}
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL
&& (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0)
scb = NULL;
if ((status0 & IOERR) != 0) {
u_int now_lvd;
now_lvd = ahd_inb(ahd, SBLKCTL) & ENAB40;
printk("%s: Transceiver State Has Changed to %s mode\n",
ahd_name(ahd), now_lvd ? "LVD" : "SE");
ahd_outb(ahd, CLRSINT0, CLRIOERR);
/*
* A change in I/O mode is equivalent to a bus reset.
*/
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
ahd_pause(ahd);
ahd_setup_iocell_workaround(ahd);
ahd_unpause(ahd);
} else if ((status0 & OVERRUN) != 0) {
printk("%s: SCSI offset overrun detected. Resetting bus.\n",
ahd_name(ahd));
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
} else if ((status & SCSIRSTI) != 0) {
printk("%s: Someone reset channel A\n", ahd_name(ahd));
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE);
} else if ((status & SCSIPERR) != 0) {
/* Make sure the sequencer is in a safe location. */
ahd_clear_critical_section(ahd);
ahd_handle_transmission_error(ahd);
} else if (lqostat0 != 0) {
printk("%s: lqostat0 == 0x%x!\n", ahd_name(ahd), lqostat0);
ahd_outb(ahd, CLRLQOINT0, lqostat0);
if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0)
ahd_outb(ahd, CLRLQOINT1, 0);
} else if ((status & SELTO) != 0) {
/* Stop the selection */
ahd_outb(ahd, SCSISEQ0, 0);
/* Make sure the sequencer is in a safe location. */
ahd_clear_critical_section(ahd);
/* No more pending messages */
ahd_clear_msg_state(ahd);
/* Clear interrupt state */
ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRBUSFREE|CLRSCSIPERR);
/*
* Although the driver does not care about the
* 'Selection in Progress' status bit, the busy
* LED does. SELINGO is only cleared by a successful
* selection, so we must manually clear it to insure
* the LED turns off just incase no future successful
* selections occur (e.g. no devices on the bus).
*/
ahd_outb(ahd, CLRSINT0, CLRSELINGO);
scbid = ahd_inw(ahd, WAITING_TID_HEAD);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printk("%s: ahd_intr - referenced scb not "
"valid during SELTO scb(0x%x)\n",
ahd_name(ahd), scbid);
ahd_dump_card_state(ahd);
} else {
struct ahd_devinfo devinfo;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_SELTO) != 0) {
ahd_print_path(ahd, scb);
printk("Saw Selection Timeout for SCB 0x%x\n",
scbid);
}
#endif
ahd_scb_devinfo(ahd, &devinfo, scb);
ahd_set_transaction_status(scb, CAM_SEL_TIMEOUT);
ahd_freeze_devq(ahd, scb);
/*
* Cancel any pending transactions on the device
* now that it seems to be missing. This will
* also revert us to async/narrow transfers until
* we can renegotiate with the device.
*/
ahd_handle_devreset(ahd, &devinfo,
CAM_LUN_WILDCARD,
CAM_SEL_TIMEOUT,
"Selection Timeout",
/*verbose_level*/1);
}
ahd_outb(ahd, CLRINT, CLRSCSIINT);
ahd_iocell_first_selection(ahd);
ahd_unpause(ahd);
} else if ((status0 & (SELDI|SELDO)) != 0) {
ahd_iocell_first_selection(ahd);
ahd_unpause(ahd);
} else if (status3 != 0) {
printk("%s: SCSI Cell parity error SSTAT3 == 0x%x\n",
ahd_name(ahd), status3);
ahd_outb(ahd, CLRSINT3, status3);
} else if ((lqistat1 & (LQIPHASE_LQ|LQIPHASE_NLQ)) != 0) {
/* Make sure the sequencer is in a safe location. */
ahd_clear_critical_section(ahd);
ahd_handle_lqiphase_error(ahd, lqistat1);
} else if ((lqistat1 & LQICRCI_NLQ) != 0) {
/*
* This status can be delayed during some
* streaming operations. The SCSIPHASE
* handler has already dealt with this case
* so just clear the error.
*/
ahd_outb(ahd, CLRLQIINT1, CLRLQICRCI_NLQ);
} else if ((status & BUSFREE) != 0
|| (lqistat1 & LQOBUSFREE) != 0) {
u_int lqostat1;
int restart;
int clear_fifo;
int packetized;
u_int mode;
/*
* Clear our selection hardware as soon as possible.
* We may have an entry in the waiting Q for this target,
* that is affected by this busfree and we don't want to
* go about selecting the target while we handle the event.
*/
ahd_outb(ahd, SCSISEQ0, 0);
/* Make sure the sequencer is in a safe location. */
ahd_clear_critical_section(ahd);
/*
* Determine what we were up to at the time of
* the busfree.
*/
mode = AHD_MODE_SCSI;
busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME;
lqostat1 = ahd_inb(ahd, LQOSTAT1);
switch (busfreetime) {
case BUSFREE_DFF0:
case BUSFREE_DFF1:
{
mode = busfreetime == BUSFREE_DFF0
? AHD_MODE_DFF0 : AHD_MODE_DFF1;
ahd_set_modes(ahd, mode, mode);
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printk("%s: Invalid SCB %d in DFF%d "
"during unexpected busfree\n",
ahd_name(ahd), scbid, mode);
packetized = 0;
} else
packetized = (scb->flags & SCB_PACKETIZED) != 0;
clear_fifo = 1;
break;
}
case BUSFREE_LQO:
clear_fifo = 0;
packetized = 1;
break;
default:
clear_fifo = 0;
packetized = (lqostat1 & LQOBUSFREE) != 0;
if (!packetized
&& ahd_inb(ahd, LASTPHASE) == P_BUSFREE
&& (ahd_inb(ahd, SSTAT0) & SELDI) == 0
&& ((ahd_inb(ahd, SSTAT0) & SELDO) == 0
|| (ahd_inb(ahd, SCSISEQ0) & ENSELO) == 0))
/*
* Assume packetized if we are not
* on the bus in a non-packetized
* capacity and any pending selection
* was a packetized selection.
*/
packetized = 1;
break;
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printk("Saw Busfree. Busfreetime = 0x%x.\n",
busfreetime);
#endif
/*
* Busfrees that occur in non-packetized phases are
* handled by the nonpkt_busfree handler.
*/
if (packetized && ahd_inb(ahd, LASTPHASE) == P_BUSFREE) {
restart = ahd_handle_pkt_busfree(ahd, busfreetime);
} else {
packetized = 0;
restart = ahd_handle_nonpkt_busfree(ahd);
}
/*
* Clear the busfree interrupt status. The setting of
* the interrupt is a pulse, so in a perfect world, we
* would not need to muck with the ENBUSFREE logic. This
* would ensure that if the bus moves on to another
* connection, busfree protection is still in force. If
* BUSFREEREV is broken, however, we must manually clear
* the ENBUSFREE if the busfree occurred during a non-pack
* connection so that we don't get false positives during
* future, packetized, connections.
*/
ahd_outb(ahd, CLRSINT1, CLRBUSFREE);
if (packetized == 0
&& (ahd->bugs & AHD_BUSFREEREV_BUG) != 0)
ahd_outb(ahd, SIMODE1,
ahd_inb(ahd, SIMODE1) & ~ENBUSFREE);
if (clear_fifo)
ahd_clear_fifo(ahd, mode);
ahd_clear_msg_state(ahd);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
if (restart) {
ahd_restart(ahd);
} else {
ahd_unpause(ahd);
}
} else {
printk("%s: Missing case in ahd_handle_scsiint. status = %x\n",
ahd_name(ahd), status);
ahd_dump_card_state(ahd);
ahd_clear_intstat(ahd);
ahd_unpause(ahd);
}
}
static void
ahd_handle_transmission_error(struct ahd_softc *ahd)
{
struct scb *scb;
u_int scbid;
u_int lqistat1;
u_int lqistat2;
u_int msg_out;
u_int curphase;
u_int lastphase;
u_int perrdiag;
u_int cur_col;
int silent;
scb = NULL;
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
lqistat1 = ahd_inb(ahd, LQISTAT1) & ~(LQIPHASE_LQ|LQIPHASE_NLQ);
lqistat2 = ahd_inb(ahd, LQISTAT2);
if ((lqistat1 & (LQICRCI_NLQ|LQICRCI_LQ)) == 0
&& (ahd->bugs & AHD_NLQICRC_DELAYED_BUG) != 0) {
u_int lqistate;
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
lqistate = ahd_inb(ahd, LQISTATE);
if ((lqistate >= 0x1E && lqistate <= 0x24)
|| (lqistate == 0x29)) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
printk("%s: NLQCRC found via LQISTATE\n",
ahd_name(ahd));
}
#endif
lqistat1 |= LQICRCI_NLQ;
}
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
}
ahd_outb(ahd, CLRLQIINT1, lqistat1);
lastphase = ahd_inb(ahd, LASTPHASE);
curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
perrdiag = ahd_inb(ahd, PERRDIAG);
msg_out = MSG_INITIATOR_DET_ERR;
ahd_outb(ahd, CLRSINT1, CLRSCSIPERR);
/*
* Try to find the SCB associated with this error.
*/
silent = FALSE;
if (lqistat1 == 0
|| (lqistat1 & LQICRCI_NLQ) != 0) {
if ((lqistat1 & (LQICRCI_NLQ|LQIOVERI_NLQ)) != 0)
ahd_set_active_fifo(ahd);
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL && SCB_IS_SILENT(scb))
silent = TRUE;
}
cur_col = 0;
if (silent == FALSE) {
printk("%s: Transmission error detected\n", ahd_name(ahd));
ahd_lqistat1_print(lqistat1, &cur_col, 50);
ahd_lastphase_print(lastphase, &cur_col, 50);
ahd_scsisigi_print(curphase, &cur_col, 50);
ahd_perrdiag_print(perrdiag, &cur_col, 50);
printk("\n");
ahd_dump_card_state(ahd);
}
if ((lqistat1 & (LQIOVERI_LQ|LQIOVERI_NLQ)) != 0) {
if (silent == FALSE) {
printk("%s: Gross protocol error during incoming "
"packet. lqistat1 == 0x%x. Resetting bus.\n",
ahd_name(ahd), lqistat1);
}
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
return;
} else if ((lqistat1 & LQICRCI_LQ) != 0) {
/*
* A CRC error has been detected on an incoming LQ.
* The bus is currently hung on the last ACK.
* Hit LQIRETRY to release the last ack, and
* wait for the sequencer to determine that ATNO
* is asserted while in message out to take us
* to our host message loop. No NONPACKREQ or
* LQIPHASE type errors will occur in this
* scenario. After this first LQIRETRY, the LQI
* manager will be in ISELO where it will
* happily sit until another packet phase begins.
* Unexpected bus free detection is enabled
* through any phases that occur after we release
* this last ack until the LQI manager sees a
* packet phase. This implies we may have to
* ignore a perfectly valid "unexected busfree"
* after our "initiator detected error" message is
* sent. A busfree is the expected response after
* we tell the target that it's L_Q was corrupted.
* (SPI4R09 10.7.3.3.3)
*/
ahd_outb(ahd, LQCTL2, LQIRETRY);
printk("LQIRetry for LQICRCI_LQ to release ACK\n");
} else if ((lqistat1 & LQICRCI_NLQ) != 0) {
/*
* We detected a CRC error in a NON-LQ packet.
* The hardware has varying behavior in this situation
* depending on whether this packet was part of a
* stream or not.
*
* PKT by PKT mode:
* The hardware has already acked the complete packet.
* If the target honors our outstanding ATN condition,
* we should be (or soon will be) in MSGOUT phase.
* This will trigger the LQIPHASE_LQ status bit as the
* hardware was expecting another LQ. Unexpected
* busfree detection is enabled. Once LQIPHASE_LQ is
* true (first entry into host message loop is much
* the same), we must clear LQIPHASE_LQ and hit
* LQIRETRY so the hardware is ready to handle
* a future LQ. NONPACKREQ will not be asserted again
* once we hit LQIRETRY until another packet is
* processed. The target may either go busfree
* or start another packet in response to our message.
*
* Read Streaming P0 asserted:
* If we raise ATN and the target completes the entire
* stream (P0 asserted during the last packet), the
* hardware will ack all data and return to the ISTART
* state. When the target reponds to our ATN condition,
* LQIPHASE_LQ will be asserted. We should respond to
* this with an LQIRETRY to prepare for any future
* packets. NONPACKREQ will not be asserted again
* once we hit LQIRETRY until another packet is
* processed. The target may either go busfree or
* start another packet in response to our message.
* Busfree detection is enabled.
*
* Read Streaming P0 not asserted:
* If we raise ATN and the target transitions to
* MSGOUT in or after a packet where P0 is not
* asserted, the hardware will assert LQIPHASE_NLQ.
* We should respond to the LQIPHASE_NLQ with an
* LQIRETRY. Should the target stay in a non-pkt
* phase after we send our message, the hardware
* will assert LQIPHASE_LQ. Recovery is then just as
* listed above for the read streaming with P0 asserted.
* Busfree detection is enabled.
*/
if (silent == FALSE)
printk("LQICRC_NLQ\n");
if (scb == NULL) {
printk("%s: No SCB valid for LQICRC_NLQ. "
"Resetting bus\n", ahd_name(ahd));
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
return;
}
} else if ((lqistat1 & LQIBADLQI) != 0) {
printk("Need to handle BADLQI!\n");
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
return;
} else if ((perrdiag & (PARITYERR|PREVPHASE)) == PARITYERR) {
if ((curphase & ~P_DATAIN_DT) != 0) {
/* Ack the byte. So we can continue. */
if (silent == FALSE)
printk("Acking %s to clear perror\n",
ahd_lookup_phase_entry(curphase)->phasemsg);
ahd_inb(ahd, SCSIDAT);
}
if (curphase == P_MESGIN)
msg_out = MSG_PARITY_ERROR;
}
/*
* We've set the hardware to assert ATN if we
* get a parity error on "in" phases, so all we
* need to do is stuff the message buffer with
* the appropriate message. "In" phases have set
* mesg_out to something other than MSG_NOP.
*/
ahd->send_msg_perror = msg_out;
if (scb != NULL && msg_out == MSG_INITIATOR_DET_ERR)
scb->flags |= SCB_TRANSMISSION_ERROR;
ahd_outb(ahd, MSG_OUT, HOST_MSG);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
ahd_unpause(ahd);
}
static void
ahd_handle_lqiphase_error(struct ahd_softc *ahd, u_int lqistat1)
{
/*
* Clear the sources of the interrupts.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, CLRLQIINT1, lqistat1);
/*
* If the "illegal" phase changes were in response
* to our ATN to flag a CRC error, AND we ended up
* on packet boundaries, clear the error, restart the
* LQI manager as appropriate, and go on our merry
* way toward sending the message. Otherwise, reset
* the bus to clear the error.
*/
ahd_set_active_fifo(ahd);
if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0
&& (ahd_inb(ahd, MDFFSTAT) & DLZERO) != 0) {
if ((lqistat1 & LQIPHASE_LQ) != 0) {
printk("LQIRETRY for LQIPHASE_LQ\n");
ahd_outb(ahd, LQCTL2, LQIRETRY);
} else if ((lqistat1 & LQIPHASE_NLQ) != 0) {
printk("LQIRETRY for LQIPHASE_NLQ\n");
ahd_outb(ahd, LQCTL2, LQIRETRY);
} else
panic("ahd_handle_lqiphase_error: No phase errors\n");
ahd_dump_card_state(ahd);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
ahd_unpause(ahd);
} else {
printk("Resetting Channel for LQI Phase error\n");
ahd_dump_card_state(ahd);
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
}
}
/*
* Packetized unexpected or expected busfree.
* Entered in mode based on busfreetime.
*/
static int
ahd_handle_pkt_busfree(struct ahd_softc *ahd, u_int busfreetime)
{
u_int lqostat1;
AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
lqostat1 = ahd_inb(ahd, LQOSTAT1);
if ((lqostat1 & LQOBUSFREE) != 0) {
struct scb *scb;
u_int scbid;
u_int saved_scbptr;
u_int waiting_h;
u_int waiting_t;
u_int next;
/*
* The LQO manager detected an unexpected busfree
* either:
*
* 1) During an outgoing LQ.
* 2) After an outgoing LQ but before the first
* REQ of the command packet.
* 3) During an outgoing command packet.
*
* In all cases, CURRSCB is pointing to the
* SCB that encountered the failure. Clean
* up the queue, clear SELDO and LQOBUSFREE,
* and allow the sequencer to restart the select
* out at its lesure.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
scbid = ahd_inw(ahd, CURRSCB);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL)
panic("SCB not valid during LQOBUSFREE");
/*
* Clear the status.
*/
ahd_outb(ahd, CLRLQOINT1, CLRLQOBUSFREE);
if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0)
ahd_outb(ahd, CLRLQOINT1, 0);
ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
ahd_flush_device_writes(ahd);
ahd_outb(ahd, CLRSINT0, CLRSELDO);
/*
* Return the LQO manager to its idle loop. It will
* not do this automatically if the busfree occurs
* after the first REQ of either the LQ or command
* packet or between the LQ and command packet.
*/
ahd_outb(ahd, LQCTL2, ahd_inb(ahd, LQCTL2) | LQOTOIDLE);
/*
* Update the waiting for selection queue so
* we restart on the correct SCB.
*/
waiting_h = ahd_inw(ahd, WAITING_TID_HEAD);
saved_scbptr = ahd_get_scbptr(ahd);
if (waiting_h != scbid) {
ahd_outw(ahd, WAITING_TID_HEAD, scbid);
waiting_t = ahd_inw(ahd, WAITING_TID_TAIL);
if (waiting_t == waiting_h) {
ahd_outw(ahd, WAITING_TID_TAIL, scbid);
next = SCB_LIST_NULL;
} else {
ahd_set_scbptr(ahd, waiting_h);
next = ahd_inw_scbram(ahd, SCB_NEXT2);
}
ahd_set_scbptr(ahd, scbid);
ahd_outw(ahd, SCB_NEXT2, next);
}
ahd_set_scbptr(ahd, saved_scbptr);
if (scb->crc_retry_count < AHD_MAX_LQ_CRC_ERRORS) {
if (SCB_IS_SILENT(scb) == FALSE) {
ahd_print_path(ahd, scb);
printk("Probable outgoing LQ CRC error. "
"Retrying command\n");
}
scb->crc_retry_count++;
} else {
ahd_set_transaction_status(scb, CAM_UNCOR_PARITY);
ahd_freeze_scb(scb);
ahd_freeze_devq(ahd, scb);
}
/* Return unpausing the sequencer. */
return (0);
} else if ((ahd_inb(ahd, PERRDIAG) & PARITYERR) != 0) {
/*
* Ignore what are really parity errors that
* occur on the last REQ of a free running
* clock prior to going busfree. Some drives
* do not properly active negate just before
* going busfree resulting in a parity glitch.
*/
ahd_outb(ahd, CLRSINT1, CLRSCSIPERR|CLRBUSFREE);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MASKED_ERRORS) != 0)
printk("%s: Parity on last REQ detected "
"during busfree phase.\n",
ahd_name(ahd));
#endif
/* Return unpausing the sequencer. */
return (0);
}
if (ahd->src_mode != AHD_MODE_SCSI) {
u_int scbid;
struct scb *scb;
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
ahd_print_path(ahd, scb);
printk("Unexpected PKT busfree condition\n");
ahd_dump_card_state(ahd);
ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), 'A',
SCB_GET_LUN(scb), SCB_GET_TAG(scb),
ROLE_INITIATOR, CAM_UNEXP_BUSFREE);
/* Return restarting the sequencer. */
return (1);
}
printk("%s: Unexpected PKT busfree condition\n", ahd_name(ahd));
ahd_dump_card_state(ahd);
/* Restart the sequencer. */
return (1);
}
/*
* Non-packetized unexpected or expected busfree.
*/
static int
ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
{
struct ahd_devinfo devinfo;
struct scb *scb;
u_int lastphase;
u_int saved_scsiid;
u_int saved_lun;
u_int target;
u_int initiator_role_id;
u_int scbid;
u_int ppr_busfree;
int printerror;
/*
* Look at what phase we were last in. If its message out,
* chances are pretty good that the busfree was in response
* to one of our abort requests.
*/
lastphase = ahd_inb(ahd, LASTPHASE);
saved_scsiid = ahd_inb(ahd, SAVED_SCSIID);
saved_lun = ahd_inb(ahd, SAVED_LUN);
target = SCSIID_TARGET(ahd, saved_scsiid);
initiator_role_id = SCSIID_OUR_ID(saved_scsiid);
ahd_compile_devinfo(&devinfo, initiator_role_id,
target, saved_lun, 'A', ROLE_INITIATOR);
printerror = 1;
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL
&& (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0)
scb = NULL;
ppr_busfree = (ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0;
if (lastphase == P_MESGOUT) {
u_int tag;
tag = SCB_LIST_NULL;
if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_ABORT_TAG, TRUE)
|| ahd_sent_msg(ahd, AHDMSG_1B, MSG_ABORT, TRUE)) {
int found;
int sent_msg;
if (scb == NULL) {
ahd_print_devinfo(ahd, &devinfo);
printk("Abort for unidentified "
"connection completed.\n");
/* restart the sequencer. */
return (1);
}
sent_msg = ahd->msgout_buf[ahd->msgout_index - 1];
ahd_print_path(ahd, scb);
printk("SCB %d - Abort%s Completed.\n",
SCB_GET_TAG(scb),
sent_msg == MSG_ABORT_TAG ? "" : " Tag");
if (sent_msg == MSG_ABORT_TAG)
tag = SCB_GET_TAG(scb);
if ((scb->flags & SCB_EXTERNAL_RESET) != 0) {
/*
* This abort is in response to an
* unexpected switch to command phase
* for a packetized connection. Since
* the identify message was never sent,
* "saved lun" is 0. We really want to
* abort only the SCB that encountered
* this error, which could have a different
* lun. The SCB will be retried so the OS
* will see the UA after renegotiating to
* packetized.
*/
tag = SCB_GET_TAG(scb);
saved_lun = scb->hscb->lun;
}
found = ahd_abort_scbs(ahd, target, 'A', saved_lun,
tag, ROLE_INITIATOR,
CAM_REQ_ABORTED);
printk("found == 0x%x\n", found);
printerror = 0;
} else if (ahd_sent_msg(ahd, AHDMSG_1B,
MSG_BUS_DEV_RESET, TRUE)) {
#ifdef __FreeBSD__
/*
* Don't mark the user's request for this BDR
* as completing with CAM_BDR_SENT. CAM3
* specifies CAM_REQ_CMP.
*/
if (scb != NULL
&& scb->io_ctx->ccb_h.func_code== XPT_RESET_DEV
&& ahd_match_scb(ahd, scb, target, 'A',
CAM_LUN_WILDCARD, SCB_LIST_NULL,
ROLE_INITIATOR))
ahd_set_transaction_status(scb, CAM_REQ_CMP);
#endif
ahd_handle_devreset(ahd, &devinfo, CAM_LUN_WILDCARD,
CAM_BDR_SENT, "Bus Device Reset",
/*verbose_level*/0);
printerror = 0;
} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, FALSE)
&& ppr_busfree == 0) {
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
/*
* PPR Rejected.
*
* If the previous negotiation was packetized,
* this could be because the device has been
* reset without our knowledge. Force our
* current negotiation to async and retry the
* negotiation. Otherwise retry the command
* with non-ppr negotiation.
*/
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk("PPR negotiation rejected busfree.\n");
#endif
tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
devinfo.our_scsiid,
devinfo.target, &tstate);
if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ)!=0) {
ahd_set_width(ahd, &devinfo,
MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR,
/*paused*/TRUE);
ahd_set_syncrate(ahd, &devinfo,
/*period*/0, /*offset*/0,
/*ppr_options*/0,
AHD_TRANS_CUR,
/*paused*/TRUE);
/*
* The expect PPR busfree handler below
* will effect the retry and necessary
* abort.
*/
} else {
tinfo->curr.transport_version = 2;
tinfo->goal.transport_version = 2;
tinfo->goal.ppr_options = 0;
if (scb != NULL) {
/*
* Remove any SCBs in the waiting
* for selection queue that may
* also be for this target so that
* command ordering is preserved.
*/
ahd_freeze_devq(ahd, scb);
ahd_qinfifo_requeue_tail(ahd, scb);
}
printerror = 0;
}
} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, FALSE)
&& ppr_busfree == 0) {
/*
* Negotiation Rejected. Go-narrow and
* retry command.
*/
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk("WDTR negotiation rejected busfree.\n");
#endif
ahd_set_width(ahd, &devinfo,
MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR|AHD_TRANS_GOAL,
/*paused*/TRUE);
if (scb != NULL) {
/*
* Remove any SCBs in the waiting for
* selection queue that may also be for
* this target so that command ordering
* is preserved.
*/
ahd_freeze_devq(ahd, scb);
ahd_qinfifo_requeue_tail(ahd, scb);
}
printerror = 0;
} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, FALSE)
&& ppr_busfree == 0) {
/*
* Negotiation Rejected. Go-async and
* retry command.
*/
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk("SDTR negotiation rejected busfree.\n");
#endif
ahd_set_syncrate(ahd, &devinfo,
/*period*/0, /*offset*/0,
/*ppr_options*/0,
AHD_TRANS_CUR|AHD_TRANS_GOAL,
/*paused*/TRUE);
if (scb != NULL) {
/*
* Remove any SCBs in the waiting for
* selection queue that may also be for
* this target so that command ordering
* is preserved.
*/
ahd_freeze_devq(ahd, scb);
ahd_qinfifo_requeue_tail(ahd, scb);
}
printerror = 0;
} else if ((ahd->msg_flags & MSG_FLAG_EXPECT_IDE_BUSFREE) != 0
&& ahd_sent_msg(ahd, AHDMSG_1B,
MSG_INITIATOR_DET_ERR, TRUE)) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk("Expected IDE Busfree\n");
#endif
printerror = 0;
} else if ((ahd->msg_flags & MSG_FLAG_EXPECT_QASREJ_BUSFREE)
&& ahd_sent_msg(ahd, AHDMSG_1B,
MSG_MESSAGE_REJECT, TRUE)) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk("Expected QAS Reject Busfree\n");
#endif
printerror = 0;
}
}
/*
* The busfree required flag is honored at the end of
* the message phases. We check it last in case we
* had to send some other message that caused a busfree.
*/
if (scb != NULL && printerror != 0
&& (lastphase == P_MESGIN || lastphase == P_MESGOUT)
&& ((ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0)) {
ahd_freeze_devq(ahd, scb);
ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
ahd_freeze_scb(scb);
if ((ahd->msg_flags & MSG_FLAG_IU_REQ_CHANGED) != 0) {
ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
SCB_GET_CHANNEL(ahd, scb),
SCB_GET_LUN(scb), SCB_LIST_NULL,
ROLE_INITIATOR, CAM_REQ_ABORTED);
} else {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk("PPR Negotiation Busfree.\n");
#endif
ahd_done(ahd, scb);
}
printerror = 0;
}
if (printerror != 0) {
int aborted;
aborted = 0;
if (scb != NULL) {
u_int tag;
if ((scb->hscb->control & TAG_ENB) != 0)
tag = SCB_GET_TAG(scb);
else
tag = SCB_LIST_NULL;
ahd_print_path(ahd, scb);
aborted = ahd_abort_scbs(ahd, target, 'A',
SCB_GET_LUN(scb), tag,
ROLE_INITIATOR,
CAM_UNEXP_BUSFREE);
} else {
/*
* We had not fully identified this connection,
* so we cannot abort anything.
*/
printk("%s: ", ahd_name(ahd));
}
printk("Unexpected busfree %s, %d SCBs aborted, "
"PRGMCNT == 0x%x\n",
ahd_lookup_phase_entry(lastphase)->phasemsg,
aborted,
ahd_inw(ahd, PRGMCNT));
ahd_dump_card_state(ahd);
if (lastphase != P_BUSFREE)
ahd_force_renegotiation(ahd, &devinfo);
}
/* Always restart the sequencer. */
return (1);
}
static void
ahd_handle_proto_violation(struct ahd_softc *ahd)
{
struct ahd_devinfo devinfo;
struct scb *scb;
u_int scbid;
u_int seq_flags;
u_int curphase;
u_int lastphase;
int found;
ahd_fetch_devinfo(ahd, &devinfo);
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
seq_flags = ahd_inb(ahd, SEQ_FLAGS);
curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
lastphase = ahd_inb(ahd, LASTPHASE);
if ((seq_flags & NOT_IDENTIFIED) != 0) {
/*
* The reconnecting target either did not send an
* identify message, or did, but we didn't find an SCB
* to match.
*/
ahd_print_devinfo(ahd, &devinfo);
printk("Target did not send an IDENTIFY message. "
"LASTPHASE = 0x%x.\n", lastphase);
scb = NULL;
} else if (scb == NULL) {
/*
* We don't seem to have an SCB active for this
* transaction. Print an error and reset the bus.
*/
ahd_print_devinfo(ahd, &devinfo);
printk("No SCB found during protocol violation\n");
goto proto_violation_reset;
} else {
ahd_set_transaction_status(scb, CAM_SEQUENCE_FAIL);
if ((seq_flags & NO_CDB_SENT) != 0) {
ahd_print_path(ahd, scb);
printk("No or incomplete CDB sent to device.\n");
} else if ((ahd_inb_scbram(ahd, SCB_CONTROL)
& STATUS_RCVD) == 0) {
/*
* The target never bothered to provide status to
* us prior to completing the command. Since we don't
* know the disposition of this command, we must attempt
* to abort it. Assert ATN and prepare to send an abort
* message.
*/
ahd_print_path(ahd, scb);
printk("Completed command without status.\n");
} else {
ahd_print_path(ahd, scb);
printk("Unknown protocol violation.\n");
ahd_dump_card_state(ahd);
}
}
if ((lastphase & ~P_DATAIN_DT) == 0
|| lastphase == P_COMMAND) {
proto_violation_reset:
/*
* Target either went directly to data
* phase or didn't respond to our ATN.
* The only safe thing to do is to blow
* it away with a bus reset.
*/
found = ahd_reset_channel(ahd, 'A', TRUE);
printk("%s: Issued Channel %c Bus Reset. "
"%d SCBs aborted\n", ahd_name(ahd), 'A', found);
} else {
/*
* Leave the selection hardware off in case
* this abort attempt will affect yet to
* be sent commands.
*/
ahd_outb(ahd, SCSISEQ0,
ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
ahd_assert_atn(ahd);
ahd_outb(ahd, MSG_OUT, HOST_MSG);
if (scb == NULL) {
ahd_print_devinfo(ahd, &devinfo);
ahd->msgout_buf[0] = MSG_ABORT_TASK;
ahd->msgout_len = 1;
ahd->msgout_index = 0;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
} else {
ahd_print_path(ahd, scb);
scb->flags |= SCB_ABORT;
}
printk("Protocol violation %s. Attempting to abort.\n",
ahd_lookup_phase_entry(curphase)->phasemsg);
}
}
/*
* Force renegotiation to occur the next time we initiate
* a command to the current device.
*/
static void
ahd_force_renegotiation(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
struct ahd_initiator_tinfo *targ_info;
struct ahd_tmode_tstate *tstate;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
ahd_print_devinfo(ahd, devinfo);
printk("Forcing renegotiation\n");
}
#endif
targ_info = ahd_fetch_transinfo(ahd,
devinfo->channel,
devinfo->our_scsiid,
devinfo->target,
&tstate);
ahd_update_neg_request(ahd, devinfo, tstate,
targ_info, AHD_NEG_IF_NON_ASYNC);
}
#define AHD_MAX_STEPS 2000
static void
ahd_clear_critical_section(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
int stepping;
int steps;
int first_instr;
u_int simode0;
u_int simode1;
u_int simode3;
u_int lqimode0;
u_int lqimode1;
u_int lqomode0;
u_int lqomode1;
if (ahd->num_critical_sections == 0)
return;
stepping = FALSE;
steps = 0;
first_instr = 0;
simode0 = 0;
simode1 = 0;
simode3 = 0;
lqimode0 = 0;
lqimode1 = 0;
lqomode0 = 0;
lqomode1 = 0;
saved_modes = ahd_save_modes(ahd);
for (;;) {
struct cs *cs;
u_int seqaddr;
u_int i;
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
seqaddr = ahd_inw(ahd, CURADDR);
cs = ahd->critical_sections;
for (i = 0; i < ahd->num_critical_sections; i++, cs++) {
if (cs->begin < seqaddr && cs->end >= seqaddr)
break;
}
if (i == ahd->num_critical_sections)
break;
if (steps > AHD_MAX_STEPS) {
printk("%s: Infinite loop in critical section\n"
"%s: First Instruction 0x%x now 0x%x\n",
ahd_name(ahd), ahd_name(ahd), first_instr,
seqaddr);
ahd_dump_card_state(ahd);
panic("critical section loop");
}
steps++;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printk("%s: Single stepping at 0x%x\n", ahd_name(ahd),
seqaddr);
#endif
if (stepping == FALSE) {
first_instr = seqaddr;
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
simode0 = ahd_inb(ahd, SIMODE0);
simode3 = ahd_inb(ahd, SIMODE3);
lqimode0 = ahd_inb(ahd, LQIMODE0);
lqimode1 = ahd_inb(ahd, LQIMODE1);
lqomode0 = ahd_inb(ahd, LQOMODE0);
lqomode1 = ahd_inb(ahd, LQOMODE1);
ahd_outb(ahd, SIMODE0, 0);
ahd_outb(ahd, SIMODE3, 0);
ahd_outb(ahd, LQIMODE0, 0);
ahd_outb(ahd, LQIMODE1, 0);
ahd_outb(ahd, LQOMODE0, 0);
ahd_outb(ahd, LQOMODE1, 0);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
simode1 = ahd_inb(ahd, SIMODE1);
/*
* We don't clear ENBUSFREE. Unfortunately
* we cannot re-enable busfree detection within
* the current connection, so we must leave it
* on while single stepping.
*/
ahd_outb(ahd, SIMODE1, simode1 & ENBUSFREE);
ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) | STEP);
stepping = TRUE;
}
ahd_outb(ahd, CLRSINT1, CLRBUSFREE);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
ahd_outb(ahd, HCNTRL, ahd->unpause);
while (!ahd_is_paused(ahd))
ahd_delay(200);
ahd_update_modes(ahd);
}
if (stepping) {
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
ahd_outb(ahd, SIMODE0, simode0);
ahd_outb(ahd, SIMODE3, simode3);
ahd_outb(ahd, LQIMODE0, lqimode0);
ahd_outb(ahd, LQIMODE1, lqimode1);
ahd_outb(ahd, LQOMODE0, lqomode0);
ahd_outb(ahd, LQOMODE1, lqomode1);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) & ~STEP);
ahd_outb(ahd, SIMODE1, simode1);
/*
* SCSIINT seems to glitch occasionally when
* the interrupt masks are restored. Clear SCSIINT
* one more time so that only persistent errors
* are seen as a real interrupt.
*/
ahd_outb(ahd, CLRINT, CLRSCSIINT);
}
ahd_restore_modes(ahd, saved_modes);
}
/*
* Clear any pending interrupt status.
*/
static void
ahd_clear_intstat(struct ahd_softc *ahd)
{
AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
/* Clear any interrupt conditions this may have caused */
ahd_outb(ahd, CLRLQIINT0, CLRLQIATNQAS|CLRLQICRCT1|CLRLQICRCT2
|CLRLQIBADLQT|CLRLQIATNLQ|CLRLQIATNCMD);
ahd_outb(ahd, CLRLQIINT1, CLRLQIPHASE_LQ|CLRLQIPHASE_NLQ|CLRLIQABORT
|CLRLQICRCI_LQ|CLRLQICRCI_NLQ|CLRLQIBADLQI
|CLRLQIOVERI_LQ|CLRLQIOVERI_NLQ|CLRNONPACKREQ);
ahd_outb(ahd, CLRLQOINT0, CLRLQOTARGSCBPERR|CLRLQOSTOPT2|CLRLQOATNLQ
|CLRLQOATNPKT|CLRLQOTCRC);
ahd_outb(ahd, CLRLQOINT1, CLRLQOINITSCBPERR|CLRLQOSTOPI2|CLRLQOBADQAS
|CLRLQOBUSFREE|CLRLQOPHACHGINPKT);
if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) {
ahd_outb(ahd, CLRLQOINT0, 0);
ahd_outb(ahd, CLRLQOINT1, 0);
}
ahd_outb(ahd, CLRSINT3, CLRNTRAMPERR|CLROSRAMPERR);
ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRATNO|CLRSCSIRSTI
|CLRBUSFREE|CLRSCSIPERR|CLRREQINIT);
ahd_outb(ahd, CLRSINT0, CLRSELDO|CLRSELDI|CLRSELINGO
|CLRIOERR|CLROVERRUN);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
}
/**************************** Debugging Routines ******************************/
#ifdef AHD_DEBUG
uint32_t ahd_debug = AHD_DEBUG_OPTS;
#endif
#if 0
void
ahd_print_scb(struct scb *scb)
{
struct hardware_scb *hscb;
int i;
hscb = scb->hscb;
printk("scb:%p control:0x%x scsiid:0x%x lun:%d cdb_len:%d\n",
(void *)scb,
hscb->control,
hscb->scsiid,
hscb->lun,
hscb->cdb_len);
printk("Shared Data: ");
for (i = 0; i < sizeof(hscb->shared_data.idata.cdb); i++)
printk("%#02x", hscb->shared_data.idata.cdb[i]);
printk(" dataptr:%#x%x datacnt:%#x sgptr:%#x tag:%#x\n",
(uint32_t)((ahd_le64toh(hscb->dataptr) >> 32) & 0xFFFFFFFF),
(uint32_t)(ahd_le64toh(hscb->dataptr) & 0xFFFFFFFF),
ahd_le32toh(hscb->datacnt),
ahd_le32toh(hscb->sgptr),
SCB_GET_TAG(scb));
ahd_dump_sglist(scb);
}
#endif /* 0 */
/************************* Transfer Negotiation *******************************/
/*
* Allocate per target mode instance (ID we respond to as a target)
* transfer negotiation data structures.
*/
static struct ahd_tmode_tstate *
ahd_alloc_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel)
{
struct ahd_tmode_tstate *master_tstate;
struct ahd_tmode_tstate *tstate;
int i;
master_tstate = ahd->enabled_targets[ahd->our_id];
if (ahd->enabled_targets[scsi_id] != NULL
&& ahd->enabled_targets[scsi_id] != master_tstate)
panic("%s: ahd_alloc_tstate - Target already allocated",
ahd_name(ahd));
tstate = kmalloc(sizeof(*tstate), GFP_ATOMIC);
if (tstate == NULL)
return (NULL);
/*
* If we have allocated a master tstate, copy user settings from
* the master tstate (taken from SRAM or the EEPROM) for this
* channel, but reset our current and goal settings to async/narrow
* until an initiator talks to us.
*/
if (master_tstate != NULL) {
memcpy(tstate, master_tstate, sizeof(*tstate));
memset(tstate->enabled_luns, 0, sizeof(tstate->enabled_luns));
for (i = 0; i < 16; i++) {
memset(&tstate->transinfo[i].curr, 0,
sizeof(tstate->transinfo[i].curr));
memset(&tstate->transinfo[i].goal, 0,
sizeof(tstate->transinfo[i].goal));
}
} else
memset(tstate, 0, sizeof(*tstate));
ahd->enabled_targets[scsi_id] = tstate;
return (tstate);
}
#ifdef AHD_TARGET_MODE
/*
* Free per target mode instance (ID we respond to as a target)
* transfer negotiation data structures.
*/
static void
ahd_free_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel, int force)
{
struct ahd_tmode_tstate *tstate;
/*
* Don't clean up our "master" tstate.
* It has our default user settings.
*/
if (scsi_id == ahd->our_id
&& force == FALSE)
return;
tstate = ahd->enabled_targets[scsi_id];
if (tstate != NULL)
kfree(tstate);
ahd->enabled_targets[scsi_id] = NULL;
}
#endif
/*
* Called when we have an active connection to a target on the bus,
* this function finds the nearest period to the input period limited
* by the capabilities of the bus connectivity of and sync settings for
* the target.
*/
static void
ahd_devlimited_syncrate(struct ahd_softc *ahd,
struct ahd_initiator_tinfo *tinfo,
u_int *period, u_int *ppr_options, role_t role)
{
struct ahd_transinfo *transinfo;
u_int maxsync;
if ((ahd_inb(ahd, SBLKCTL) & ENAB40) != 0
&& (ahd_inb(ahd, SSTAT2) & EXP_ACTIVE) == 0) {
maxsync = AHD_SYNCRATE_PACED;
} else {
maxsync = AHD_SYNCRATE_ULTRA;
/* Can't do DT related options on an SE bus */
*ppr_options &= MSG_EXT_PPR_QAS_REQ;
}
/*
* Never allow a value higher than our current goal
* period otherwise we may allow a target initiated
* negotiation to go above the limit as set by the
* user. In the case of an initiator initiated
* sync negotiation, we limit based on the user
* setting. This allows the system to still accept
* incoming negotiations even if target initiated
* negotiation is not performed.
*/
if (role == ROLE_TARGET)
transinfo = &tinfo->user;
else
transinfo = &tinfo->goal;
*ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN);
if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
maxsync = max(maxsync, (u_int)AHD_SYNCRATE_ULTRA2);
*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
}
if (transinfo->period == 0) {
*period = 0;
*ppr_options = 0;
} else {
*period = max(*period, (u_int)transinfo->period);
ahd_find_syncrate(ahd, period, ppr_options, maxsync);
}
}
/*
* Look up the valid period to SCSIRATE conversion in our table.
* Return the period and offset that should be sent to the target
* if this was the beginning of an SDTR.
*/
void
ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
u_int *ppr_options, u_int maxsync)
{
if (*period < maxsync)
*period = maxsync;
if ((*ppr_options & MSG_EXT_PPR_DT_REQ) != 0
&& *period > AHD_SYNCRATE_MIN_DT)
*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
if (*period > AHD_SYNCRATE_MIN)
*period = 0;
/* Honor PPR option conformance rules. */
if (*period > AHD_SYNCRATE_PACED)
*ppr_options &= ~MSG_EXT_PPR_RTI;
if ((*ppr_options & MSG_EXT_PPR_IU_REQ) == 0)
*ppr_options &= (MSG_EXT_PPR_DT_REQ|MSG_EXT_PPR_QAS_REQ);
if ((*ppr_options & MSG_EXT_PPR_DT_REQ) == 0)
*ppr_options &= MSG_EXT_PPR_QAS_REQ;
/* Skip all PACED only entries if IU is not available */
if ((*ppr_options & MSG_EXT_PPR_IU_REQ) == 0
&& *period < AHD_SYNCRATE_DT)
*period = AHD_SYNCRATE_DT;
/* Skip all DT only entries if DT is not available */
if ((*ppr_options & MSG_EXT_PPR_DT_REQ) == 0
&& *period < AHD_SYNCRATE_ULTRA2)
*period = AHD_SYNCRATE_ULTRA2;
}
/*
* Truncate the given synchronous offset to a value the
* current adapter type and syncrate are capable of.
*/
static void
ahd_validate_offset(struct ahd_softc *ahd,
struct ahd_initiator_tinfo *tinfo,
u_int period, u_int *offset, int wide,
role_t role)
{
u_int maxoffset;
/* Limit offset to what we can do */
if (period == 0)
maxoffset = 0;
else if (period <= AHD_SYNCRATE_PACED) {
if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0)
maxoffset = MAX_OFFSET_PACED_BUG;
else
maxoffset = MAX_OFFSET_PACED;
} else
maxoffset = MAX_OFFSET_NON_PACED;
*offset = min(*offset, maxoffset);
if (tinfo != NULL) {
if (role == ROLE_TARGET)
*offset = min(*offset, (u_int)tinfo->user.offset);
else
*offset = min(*offset, (u_int)tinfo->goal.offset);
}
}
/*
* Truncate the given transfer width parameter to a value the
* current adapter type is capable of.
*/
static void
ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
u_int *bus_width, role_t role)
{
switch (*bus_width) {
default:
if (ahd->features & AHD_WIDE) {
/* Respond Wide */
*bus_width = MSG_EXT_WDTR_BUS_16_BIT;
break;
}
/* FALLTHROUGH */
case MSG_EXT_WDTR_BUS_8_BIT:
*bus_width = MSG_EXT_WDTR_BUS_8_BIT;
break;
}
if (tinfo != NULL) {
if (role == ROLE_TARGET)
*bus_width = min((u_int)tinfo->user.width, *bus_width);
else
*bus_width = min((u_int)tinfo->goal.width, *bus_width);
}
}
/*
* Update the bitmask of targets for which the controller should
* negotiate with at the next convenient opportunity. This currently
* means the next time we send the initial identify messages for
* a new transaction.
*/
int
ahd_update_neg_request(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
struct ahd_tmode_tstate *tstate,
struct ahd_initiator_tinfo *tinfo, ahd_neg_type neg_type)
{
u_int auto_negotiate_orig;
auto_negotiate_orig = tstate->auto_negotiate;
if (neg_type == AHD_NEG_ALWAYS) {
/*
* Force our "current" settings to be
* unknown so that unless a bus reset
* occurs the need to renegotiate is
* recorded persistently.
*/
if ((ahd->features & AHD_WIDE) != 0)
tinfo->curr.width = AHD_WIDTH_UNKNOWN;
tinfo->curr.period = AHD_PERIOD_UNKNOWN;
tinfo->curr.offset = AHD_OFFSET_UNKNOWN;
}
if (tinfo->curr.period != tinfo->goal.period
|| tinfo->curr.width != tinfo->goal.width
|| tinfo->curr.offset != tinfo->goal.offset
|| tinfo->curr.ppr_options != tinfo->goal.ppr_options
|| (neg_type == AHD_NEG_IF_NON_ASYNC
&& (tinfo->goal.offset != 0
|| tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT
|| tinfo->goal.ppr_options != 0)))
tstate->auto_negotiate |= devinfo->target_mask;
else
tstate->auto_negotiate &= ~devinfo->target_mask;
return (auto_negotiate_orig != tstate->auto_negotiate);
}
/*
* Update the user/goal/curr tables of synchronous negotiation
* parameters as well as, in the case of a current or active update,
* any data structures on the host controller. In the case of an
* active update, the specified target is currently talking to us on
* the bus, so the transfer parameter update must take effect
* immediately.
*/
void
ahd_set_syncrate(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int period, u_int offset, u_int ppr_options,
u_int type, int paused)
{
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
u_int old_period;
u_int old_offset;
u_int old_ppr;
int active;
int update_needed;
active = (type & AHD_TRANS_ACTIVE) == AHD_TRANS_ACTIVE;
update_needed = 0;
if (period == 0 || offset == 0) {
period = 0;
offset = 0;
}
tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
devinfo->target, &tstate);
if ((type & AHD_TRANS_USER) != 0) {
tinfo->user.period = period;
tinfo->user.offset = offset;
tinfo->user.ppr_options = ppr_options;
}
if ((type & AHD_TRANS_GOAL) != 0) {
tinfo->goal.period = period;
tinfo->goal.offset = offset;
tinfo->goal.ppr_options = ppr_options;
}
old_period = tinfo->curr.period;
old_offset = tinfo->curr.offset;
old_ppr = tinfo->curr.ppr_options;
if ((type & AHD_TRANS_CUR) != 0
&& (old_period != period
|| old_offset != offset
|| old_ppr != ppr_options)) {
update_needed++;
tinfo->curr.period = period;
tinfo->curr.offset = offset;
tinfo->curr.ppr_options = ppr_options;
ahd_send_async(ahd, devinfo->channel, devinfo->target,
CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
if (bootverbose) {
if (offset != 0) {
int options;
printk("%s: target %d synchronous with "
"period = 0x%x, offset = 0x%x",
ahd_name(ahd), devinfo->target,
period, offset);
options = 0;
if ((ppr_options & MSG_EXT_PPR_RD_STRM) != 0) {
printk("(RDSTRM");
options++;
}
if ((ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
printk("%s", options ? "|DT" : "(DT");
options++;
}
if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
printk("%s", options ? "|IU" : "(IU");
options++;
}
if ((ppr_options & MSG_EXT_PPR_RTI) != 0) {
printk("%s", options ? "|RTI" : "(RTI");
options++;
}
if ((ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
printk("%s", options ? "|QAS" : "(QAS");
options++;
}
if (options != 0)
printk(")\n");
else
printk("\n");
} else {
printk("%s: target %d using "
"asynchronous transfers%s\n",
ahd_name(ahd), devinfo->target,
(ppr_options & MSG_EXT_PPR_QAS_REQ) != 0
? "(QAS)" : "");
}
}
}
/*
* Always refresh the neg-table to handle the case of the
* sequencer setting the ENATNO bit for a MK_MESSAGE request.
* We will always renegotiate in that case if this is a
* packetized request. Also manage the busfree expected flag
* from this common routine so that we catch changes due to
* WDTR or SDTR messages.
*/
if ((type & AHD_TRANS_CUR) != 0) {
if (!paused)
ahd_pause(ahd);
ahd_update_neg_table(ahd, devinfo, &tinfo->curr);
if (!paused)
ahd_unpause(ahd);
if (ahd->msg_type != MSG_TYPE_NONE) {
if ((old_ppr & MSG_EXT_PPR_IU_REQ)
!= (ppr_options & MSG_EXT_PPR_IU_REQ)) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
ahd_print_devinfo(ahd, devinfo);
printk("Expecting IU Change busfree\n");
}
#endif
ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE
| MSG_FLAG_IU_REQ_CHANGED;
}
if ((old_ppr & MSG_EXT_PPR_IU_REQ) != 0) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk("PPR with IU_REQ outstanding\n");
#endif
ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE;
}
}
}
update_needed += ahd_update_neg_request(ahd, devinfo, tstate,
tinfo, AHD_NEG_TO_GOAL);
if (update_needed && active)
ahd_update_pending_scbs(ahd);
}
/*
* Update the user/goal/curr tables of wide negotiation
* parameters as well as, in the case of a current or active update,
* any data structures on the host controller. In the case of an
* active update, the specified target is currently talking to us on
* the bus, so the transfer parameter update must take effect
* immediately.
*/
void
ahd_set_width(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int width, u_int type, int paused)
{
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
u_int oldwidth;
int active;
int update_needed;
active = (type & AHD_TRANS_ACTIVE) == AHD_TRANS_ACTIVE;
update_needed = 0;
tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
devinfo->target, &tstate);
if ((type & AHD_TRANS_USER) != 0)
tinfo->user.width = width;
if ((type & AHD_TRANS_GOAL) != 0)
tinfo->goal.width = width;
oldwidth = tinfo->curr.width;
if ((type & AHD_TRANS_CUR) != 0 && oldwidth != width) {
update_needed++;
tinfo->curr.width = width;
ahd_send_async(ahd, devinfo->channel, devinfo->target,
CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
if (bootverbose) {
printk("%s: target %d using %dbit transfers\n",
ahd_name(ahd), devinfo->target,
8 * (0x01 << width));
}
}
if ((type & AHD_TRANS_CUR) != 0) {
if (!paused)
ahd_pause(ahd);
ahd_update_neg_table(ahd, devinfo, &tinfo->curr);
if (!paused)
ahd_unpause(ahd);
}
update_needed += ahd_update_neg_request(ahd, devinfo, tstate,
tinfo, AHD_NEG_TO_GOAL);
if (update_needed && active)
ahd_update_pending_scbs(ahd);
}
/*
* Update the current state of tagged queuing for a given target.
*/
static void
ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
struct ahd_devinfo *devinfo, ahd_queue_alg alg)
{
struct scsi_device *sdev = cmd->device;
ahd_platform_set_tags(ahd, sdev, devinfo, alg);
ahd_send_async(ahd, devinfo->channel, devinfo->target,
devinfo->lun, AC_TRANSFER_NEG);
}
static void
ahd_update_neg_table(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
struct ahd_transinfo *tinfo)
{
ahd_mode_state saved_modes;
u_int period;
u_int ppr_opts;
u_int con_opts;
u_int offset;
u_int saved_negoaddr;
uint8_t iocell_opts[sizeof(ahd->iocell_opts)];
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
saved_negoaddr = ahd_inb(ahd, NEGOADDR);
ahd_outb(ahd, NEGOADDR, devinfo->target);
period = tinfo->period;
offset = tinfo->offset;
memcpy(iocell_opts, ahd->iocell_opts, sizeof(ahd->iocell_opts));
ppr_opts = tinfo->ppr_options & (MSG_EXT_PPR_QAS_REQ|MSG_EXT_PPR_DT_REQ
|MSG_EXT_PPR_IU_REQ|MSG_EXT_PPR_RTI);
con_opts = 0;
if (period == 0)
period = AHD_SYNCRATE_ASYNC;
if (period == AHD_SYNCRATE_160) {
if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) {
/*
* When the SPI4 spec was finalized, PACE transfers
* was not made a configurable option in the PPR
* message. Instead it is assumed to be enabled for
* any syncrate faster than 80MHz. Nevertheless,
* Harpoon2A4 allows this to be configurable.
*
* Harpoon2A4 also assumes at most 2 data bytes per
* negotiated REQ/ACK offset. Paced transfers take
* 4, so we must adjust our offset.
*/
ppr_opts |= PPROPT_PACE;
offset *= 2;
/*
* Harpoon2A assumed that there would be a
* fallback rate between 160MHz and 80MHz,
* so 7 is used as the period factor rather
* than 8 for 160MHz.
*/
period = AHD_SYNCRATE_REVA_160;
}
if ((tinfo->ppr_options & MSG_EXT_PPR_PCOMP_EN) == 0)
iocell_opts[AHD_PRECOMP_SLEW_INDEX] &=
~AHD_PRECOMP_MASK;
} else {
/*
* Precomp should be disabled for non-paced transfers.
*/
iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_PRECOMP_MASK;
if ((ahd->features & AHD_NEW_IOCELL_OPTS) != 0
&& (ppr_opts & MSG_EXT_PPR_DT_REQ) != 0
&& (ppr_opts & MSG_EXT_PPR_IU_REQ) == 0) {
/*
* Slow down our CRC interval to be
* compatible with non-packetized
* U160 devices that can't handle a
* CRC at full speed.
*/
con_opts |= ENSLOWCRC;
}
if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) {
/*
* On H2A4, revert to a slower slewrate
* on non-paced transfers.
*/
iocell_opts[AHD_PRECOMP_SLEW_INDEX] &=
~AHD_SLEWRATE_MASK;
}
}
ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PRECOMP_SLEW);
ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_PRECOMP_SLEW_INDEX]);
ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_AMPLITUDE);
ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_AMPLITUDE_INDEX]);
ahd_outb(ahd, NEGPERIOD, period);
ahd_outb(ahd, NEGPPROPTS, ppr_opts);
ahd_outb(ahd, NEGOFFSET, offset);
if (tinfo->width == MSG_EXT_WDTR_BUS_16_BIT)
con_opts |= WIDEXFER;
/*
* Slow down our CRC interval to be
* compatible with packetized U320 devices
* that can't handle a CRC at full speed
*/
if (ahd->features & AHD_AIC79XXB_SLOWCRC) {
con_opts |= ENSLOWCRC;
}
/*
* During packetized transfers, the target will
* give us the opportunity to send command packets
* without us asserting attention.
*/
if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) == 0)
con_opts |= ENAUTOATNO;
ahd_outb(ahd, NEGCONOPTS, con_opts);
ahd_outb(ahd, NEGOADDR, saved_negoaddr);
ahd_restore_modes(ahd, saved_modes);
}
/*
* When the transfer settings for a connection change, setup for
* negotiation in pending SCBs to effect the change as quickly as
* possible. We also cancel any negotiations that are scheduled
* for inflight SCBs that have not been started yet.
*/
static void
ahd_update_pending_scbs(struct ahd_softc *ahd)
{
struct scb *pending_scb;
int pending_scb_count;
int paused;
u_int saved_scbptr;
ahd_mode_state saved_modes;
/*
* Traverse the pending SCB list and ensure that all of the
* SCBs there have the proper settings. We can only safely
* clear the negotiation required flag (setting requires the
* execution queue to be modified) and this is only possible
* if we are not already attempting to select out for this
* SCB. For this reason, all callers only call this routine
* if we are changing the negotiation settings for the currently
* active transaction on the bus.
*/
pending_scb_count = 0;
LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
struct ahd_devinfo devinfo;
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
ahd_scb_devinfo(ahd, &devinfo, pending_scb);
tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
devinfo.our_scsiid,
devinfo.target, &tstate);
if ((tstate->auto_negotiate & devinfo.target_mask) == 0
&& (pending_scb->flags & SCB_AUTO_NEGOTIATE) != 0) {
pending_scb->flags &= ~SCB_AUTO_NEGOTIATE;
pending_scb->hscb->control &= ~MK_MESSAGE;
}
ahd_sync_scb(ahd, pending_scb,
BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
pending_scb_count++;
}
if (pending_scb_count == 0)
return;
if (ahd_is_paused(ahd)) {
paused = 1;
} else {
paused = 0;
ahd_pause(ahd);
}
/*
* Force the sequencer to reinitialize the selection for
* the command at the head of the execution queue if it
* has already been setup. The negotiation changes may
* effect whether we select-out with ATN. It is only
* safe to clear ENSELO when the bus is not free and no
* selection is in progres or completed.
*/
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
if ((ahd_inb(ahd, SCSISIGI) & BSYI) != 0
&& (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) == 0)
ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
saved_scbptr = ahd_get_scbptr(ahd);
/* Ensure that the hscbs down on the card match the new information */
LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
u_int scb_tag;
u_int control;
scb_tag = SCB_GET_TAG(pending_scb);
ahd_set_scbptr(ahd, scb_tag);
control = ahd_inb_scbram(ahd, SCB_CONTROL);
control &= ~MK_MESSAGE;
control |= pending_scb->hscb->control & MK_MESSAGE;
ahd_outb(ahd, SCB_CONTROL, control);
}
ahd_set_scbptr(ahd, saved_scbptr);
ahd_restore_modes(ahd, saved_modes);
if (paused == 0)
ahd_unpause(ahd);
}
/**************************** Pathing Information *****************************/
static void
ahd_fetch_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
ahd_mode_state saved_modes;
u_int saved_scsiid;
role_t role;
int our_id;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
if (ahd_inb(ahd, SSTAT0) & TARGET)
role = ROLE_TARGET;
else
role = ROLE_INITIATOR;
if (role == ROLE_TARGET
&& (ahd_inb(ahd, SEQ_FLAGS) & CMDPHASE_PENDING) != 0) {
/* We were selected, so pull our id from TARGIDIN */
our_id = ahd_inb(ahd, TARGIDIN) & OID;
} else if (role == ROLE_TARGET)
our_id = ahd_inb(ahd, TOWNID);
else
our_id = ahd_inb(ahd, IOWNID);
saved_scsiid = ahd_inb(ahd, SAVED_SCSIID);
ahd_compile_devinfo(devinfo,
our_id,
SCSIID_TARGET(ahd, saved_scsiid),
ahd_inb(ahd, SAVED_LUN),
SCSIID_CHANNEL(ahd, saved_scsiid),
role);
ahd_restore_modes(ahd, saved_modes);
}
void
ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
printk("%s:%c:%d:%d: ", ahd_name(ahd), 'A',
devinfo->target, devinfo->lun);
}
static const struct ahd_phase_table_entry*
ahd_lookup_phase_entry(int phase)
{
const struct ahd_phase_table_entry *entry;
const struct ahd_phase_table_entry *last_entry;
/*
* num_phases doesn't include the default entry which
* will be returned if the phase doesn't match.
*/
last_entry = &ahd_phase_table[num_phases];
for (entry = ahd_phase_table; entry < last_entry; entry++) {
if (phase == entry->phase)
break;
}
return (entry);
}
void
ahd_compile_devinfo(struct ahd_devinfo *devinfo, u_int our_id, u_int target,
u_int lun, char channel, role_t role)
{
devinfo->our_scsiid = our_id;
devinfo->target = target;
devinfo->lun = lun;
devinfo->target_offset = target;
devinfo->channel = channel;
devinfo->role = role;
if (channel == 'B')
devinfo->target_offset += 8;
devinfo->target_mask = (0x01 << devinfo->target_offset);
}
static void
ahd_scb_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
struct scb *scb)
{
role_t role;
int our_id;
our_id = SCSIID_OUR_ID(scb->hscb->scsiid);
role = ROLE_INITIATOR;
if ((scb->hscb->control & TARGET_SCB) != 0)
role = ROLE_TARGET;
ahd_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahd, scb),
SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahd, scb), role);
}
/************************ Message Phase Processing ****************************/
/*
* When an initiator transaction with the MK_MESSAGE flag either reconnects
* or enters the initial message out phase, we are interrupted. Fill our
* outgoing message buffer with the appropriate message and beging handing
* the message phase(s) manually.
*/
static void
ahd_setup_initiator_msgout(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
struct scb *scb)
{
/*
* To facilitate adding multiple messages together,
* each routine should increment the index and len
* variables instead of setting them explicitly.
*/
ahd->msgout_index = 0;
ahd->msgout_len = 0;
if (ahd_currently_packetized(ahd))
ahd->msg_flags |= MSG_FLAG_PACKETIZED;
if (ahd->send_msg_perror
&& ahd_inb(ahd, MSG_OUT) == HOST_MSG) {
ahd->msgout_buf[ahd->msgout_index++] = ahd->send_msg_perror;
ahd->msgout_len++;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk("Setting up for Parity Error delivery\n");
#endif
return;
} else if (scb == NULL) {
printk("%s: WARNING. No pending message for "
"I_T msgin. Issuing NO-OP\n", ahd_name(ahd));
ahd->msgout_buf[ahd->msgout_index++] = MSG_NOOP;
ahd->msgout_len++;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
return;
}
if ((scb->flags & SCB_DEVICE_RESET) == 0
&& (scb->flags & SCB_PACKETIZED) == 0
&& ahd_inb(ahd, MSG_OUT) == MSG_IDENTIFYFLAG) {
u_int identify_msg;
identify_msg = MSG_IDENTIFYFLAG | SCB_GET_LUN(scb);
if ((scb->hscb->control & DISCENB) != 0)
identify_msg |= MSG_IDENTIFY_DISCFLAG;
ahd->msgout_buf[ahd->msgout_index++] = identify_msg;
ahd->msgout_len++;
if ((scb->hscb->control & TAG_ENB) != 0) {
ahd->msgout_buf[ahd->msgout_index++] =
scb->hscb->control & (TAG_ENB|SCB_TAG_TYPE);
ahd->msgout_buf[ahd->msgout_index++] = SCB_GET_TAG(scb);
ahd->msgout_len += 2;
}
}
if (scb->flags & SCB_DEVICE_RESET) {
ahd->msgout_buf[ahd->msgout_index++] = MSG_BUS_DEV_RESET;
ahd->msgout_len++;
ahd_print_path(ahd, scb);
printk("Bus Device Reset Message Sent\n");
/*
* Clear our selection hardware in advance of
* the busfree. We may have an entry in the waiting
* Q for this target, and we don't want to go about
* selecting while we handle the busfree and blow it
* away.
*/
ahd_outb(ahd, SCSISEQ0, 0);
} else if ((scb->flags & SCB_ABORT) != 0) {
if ((scb->hscb->control & TAG_ENB) != 0) {
ahd->msgout_buf[ahd->msgout_index++] = MSG_ABORT_TAG;
} else {
ahd->msgout_buf[ahd->msgout_index++] = MSG_ABORT;
}
ahd->msgout_len++;
ahd_print_path(ahd, scb);
printk("Abort%s Message Sent\n",
(scb->hscb->control & TAG_ENB) != 0 ? " Tag" : "");
/*
* Clear our selection hardware in advance of
* the busfree. We may have an entry in the waiting
* Q for this target, and we don't want to go about
* selecting while we handle the busfree and blow it
* away.
*/
ahd_outb(ahd, SCSISEQ0, 0);
} else if ((scb->flags & (SCB_AUTO_NEGOTIATE|SCB_NEGOTIATE)) != 0) {
ahd_build_transfer_msg(ahd, devinfo);
/*
* Clear our selection hardware in advance of potential
* PPR IU status change busfree. We may have an entry in
* the waiting Q for this target, and we don't want to go
* about selecting while we handle the busfree and blow
* it away.
*/
ahd_outb(ahd, SCSISEQ0, 0);
} else {
printk("ahd_intr: AWAITING_MSG for an SCB that "
"does not have a waiting message\n");
printk("SCSIID = %x, target_mask = %x\n", scb->hscb->scsiid,
devinfo->target_mask);
panic("SCB = %d, SCB Control = %x:%x, MSG_OUT = %x "
"SCB flags = %x", SCB_GET_TAG(scb), scb->hscb->control,
ahd_inb_scbram(ahd, SCB_CONTROL), ahd_inb(ahd, MSG_OUT),
scb->flags);
}
/*
* Clear the MK_MESSAGE flag from the SCB so we aren't
* asked to send this message again.
*/
ahd_outb(ahd, SCB_CONTROL,
ahd_inb_scbram(ahd, SCB_CONTROL) & ~MK_MESSAGE);
scb->hscb->control &= ~MK_MESSAGE;
ahd->msgout_index = 0;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
}
/*
* Build an appropriate transfer negotiation message for the
* currently active target.
*/
static void
ahd_build_transfer_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
/*
* We need to initiate transfer negotiations.
* If our current and goal settings are identical,
* we want to renegotiate due to a check condition.
*/
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
int dowide;
int dosync;
int doppr;
u_int period;
u_int ppr_options;
u_int offset;
tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
devinfo->target, &tstate);
/*
* Filter our period based on the current connection.
* If we can't perform DT transfers on this segment (not in LVD
* mode for instance), then our decision to issue a PPR message
* may change.
*/
period = tinfo->goal.period;
offset = tinfo->goal.offset;
ppr_options = tinfo->goal.ppr_options;
/* Target initiated PPR is not allowed in the SCSI spec */
if (devinfo->role == ROLE_TARGET)
ppr_options = 0;
ahd_devlimited_syncrate(ahd, tinfo, &period,
&ppr_options, devinfo->role);
dowide = tinfo->curr.width != tinfo->goal.width;
dosync = tinfo->curr.offset != offset || tinfo->curr.period != period;
/*
* Only use PPR if we have options that need it, even if the device
* claims to support it. There might be an expander in the way
* that doesn't.
*/
doppr = ppr_options != 0;
if (!dowide && !dosync && !doppr) {
dowide = tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT;
dosync = tinfo->goal.offset != 0;
}
if (!dowide && !dosync && !doppr) {
/*
* Force async with a WDTR message if we have a wide bus,
* or just issue an SDTR with a 0 offset.
*/
if ((ahd->features & AHD_WIDE) != 0)
dowide = 1;
else
dosync = 1;
if (bootverbose) {
ahd_print_devinfo(ahd, devinfo);
printk("Ensuring async\n");
}
}
/* Target initiated PPR is not allowed in the SCSI spec */
if (devinfo->role == ROLE_TARGET)
doppr = 0;
/*
* Both the PPR message and SDTR message require the
* goal syncrate to be limited to what the target device
* is capable of handling (based on whether an LVD->SE
* expander is on the bus), so combine these two cases.
* Regardless, guarantee that if we are using WDTR and SDTR
* messages that WDTR comes first.
*/
if (doppr || (dosync && !dowide)) {
offset = tinfo->goal.offset;
ahd_validate_offset(ahd, tinfo, period, &offset,
doppr ? tinfo->goal.width
: tinfo->curr.width,
devinfo->role);
if (doppr) {
ahd_construct_ppr(ahd, devinfo, period, offset,
tinfo->goal.width, ppr_options);
} else {
ahd_construct_sdtr(ahd, devinfo, period, offset);
}
} else {
ahd_construct_wdtr(ahd, devinfo, tinfo->goal.width);
}
}
/*
* Build a synchronous negotiation message in our message
* buffer based on the input parameters.
*/
static void
ahd_construct_sdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int period, u_int offset)
{
if (offset == 0)
period = AHD_ASYNC_XFER_PERIOD;
ahd->msgout_index += spi_populate_sync_msg(
ahd->msgout_buf + ahd->msgout_index, period, offset);
ahd->msgout_len += 5;
if (bootverbose) {
printk("(%s:%c:%d:%d): Sending SDTR period %x, offset %x\n",
ahd_name(ahd), devinfo->channel, devinfo->target,
devinfo->lun, period, offset);
}
}
/*
* Build a wide negotiateion message in our message
* buffer based on the input parameters.
*/
static void
ahd_construct_wdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int bus_width)
{
ahd->msgout_index += spi_populate_width_msg(
ahd->msgout_buf + ahd->msgout_index, bus_width);
ahd->msgout_len += 4;
if (bootverbose) {
printk("(%s:%c:%d:%d): Sending WDTR %x\n",
ahd_name(ahd), devinfo->channel, devinfo->target,
devinfo->lun, bus_width);
}
}
/*
* Build a parallel protocol request message in our message
* buffer based on the input parameters.
*/
static void
ahd_construct_ppr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int period, u_int offset, u_int bus_width,
u_int ppr_options)
{
/*
* Always request precompensation from
* the other target if we are running
* at paced syncrates.
*/
if (period <= AHD_SYNCRATE_PACED)
ppr_options |= MSG_EXT_PPR_PCOMP_EN;
if (offset == 0)
period = AHD_ASYNC_XFER_PERIOD;
ahd->msgout_index += spi_populate_ppr_msg(
ahd->msgout_buf + ahd->msgout_index, period, offset,
bus_width, ppr_options);
ahd->msgout_len += 8;
if (bootverbose) {
printk("(%s:%c:%d:%d): Sending PPR bus_width %x, period %x, "
"offset %x, ppr_options %x\n", ahd_name(ahd),
devinfo->channel, devinfo->target, devinfo->lun,
bus_width, period, offset, ppr_options);
}
}
/*
* Clear any active message state.
*/
static void
ahd_clear_msg_state(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd->send_msg_perror = 0;
ahd->msg_flags = MSG_FLAG_NONE;
ahd->msgout_len = 0;
ahd->msgin_index = 0;
ahd->msg_type = MSG_TYPE_NONE;
if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0) {
/*
* The target didn't care to respond to our
* message request, so clear ATN.
*/
ahd_outb(ahd, CLRSINT1, CLRATNO);
}
ahd_outb(ahd, MSG_OUT, MSG_NOOP);
ahd_outb(ahd, SEQ_FLAGS2,
ahd_inb(ahd, SEQ_FLAGS2) & ~TARGET_MSG_PENDING);
ahd_restore_modes(ahd, saved_modes);
}
/*
* Manual message loop handler.
*/
static void
ahd_handle_message_phase(struct ahd_softc *ahd)
{
struct ahd_devinfo devinfo;
u_int bus_phase;
int end_session;
ahd_fetch_devinfo(ahd, &devinfo);
end_session = FALSE;
bus_phase = ahd_inb(ahd, LASTPHASE);
if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0) {
printk("LQIRETRY for LQIPHASE_OUTPKT\n");
ahd_outb(ahd, LQCTL2, LQIRETRY);
}
reswitch:
switch (ahd->msg_type) {
case MSG_TYPE_INITIATOR_MSGOUT:
{
int lastbyte;
int phasemis;
int msgdone;
if (ahd->msgout_len == 0 && ahd->send_msg_perror == 0)
panic("HOST_MSG_LOOP interrupt with no active message");
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
ahd_print_devinfo(ahd, &devinfo);
printk("INITIATOR_MSG_OUT");
}
#endif
phasemis = bus_phase != P_MESGOUT;
if (phasemis) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
printk(" PHASEMIS %s\n",
ahd_lookup_phase_entry(bus_phase)
->phasemsg);
}
#endif
if (bus_phase == P_MESGIN) {
/*
* Change gears and see if
* this messages is of interest to
* us or should be passed back to
* the sequencer.
*/
ahd_outb(ahd, CLRSINT1, CLRATNO);
ahd->send_msg_perror = 0;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGIN;
ahd->msgin_index = 0;
goto reswitch;
}
end_session = TRUE;
break;
}
if (ahd->send_msg_perror) {
ahd_outb(ahd, CLRSINT1, CLRATNO);
ahd_outb(ahd, CLRSINT1, CLRREQINIT);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk(" byte 0x%x\n", ahd->send_msg_perror);
#endif
/*
* If we are notifying the target of a CRC error
* during packetized operations, the target is
* within its rights to acknowledge our message
* with a busfree.
*/
if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0
&& ahd->send_msg_perror == MSG_INITIATOR_DET_ERR)
ahd->msg_flags |= MSG_FLAG_EXPECT_IDE_BUSFREE;
ahd_outb(ahd, RETURN_2, ahd->send_msg_perror);
ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE);
break;
}
msgdone = ahd->msgout_index == ahd->msgout_len;
if (msgdone) {
/*
* The target has requested a retry.
* Re-assert ATN, reset our message index to
* 0, and try again.
*/
ahd->msgout_index = 0;
ahd_assert_atn(ahd);
}
lastbyte = ahd->msgout_index == (ahd->msgout_len - 1);
if (lastbyte) {
/* Last byte is signified by dropping ATN */
ahd_outb(ahd, CLRSINT1, CLRATNO);
}
/*
* Clear our interrupt status and present
* the next byte on the bus.
*/
ahd_outb(ahd, CLRSINT1, CLRREQINIT);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk(" byte 0x%x\n",
ahd->msgout_buf[ahd->msgout_index]);
#endif
ahd_outb(ahd, RETURN_2, ahd->msgout_buf[ahd->msgout_index++]);
ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE);
break;
}
case MSG_TYPE_INITIATOR_MSGIN:
{
int phasemis;
int message_done;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
ahd_print_devinfo(ahd, &devinfo);
printk("INITIATOR_MSG_IN");
}
#endif
phasemis = bus_phase != P_MESGIN;
if (phasemis) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
printk(" PHASEMIS %s\n",
ahd_lookup_phase_entry(bus_phase)
->phasemsg);
}
#endif
ahd->msgin_index = 0;
if (bus_phase == P_MESGOUT
&& (ahd->send_msg_perror != 0
|| (ahd->msgout_len != 0
&& ahd->msgout_index == 0))) {
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
goto reswitch;
}
end_session = TRUE;
break;
}
/* Pull the byte in without acking it */
ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIBUS);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk(" byte 0x%x\n",
ahd->msgin_buf[ahd->msgin_index]);
#endif
message_done = ahd_parse_msg(ahd, &devinfo);
if (message_done) {
/*
* Clear our incoming message buffer in case there
* is another message following this one.
*/
ahd->msgin_index = 0;
/*
* If this message illicited a response,
* assert ATN so the target takes us to the
* message out phase.
*/
if (ahd->msgout_len != 0) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
ahd_print_devinfo(ahd, &devinfo);
printk("Asserting ATN for response\n");
}
#endif
ahd_assert_atn(ahd);
}
} else
ahd->msgin_index++;
if (message_done == MSGLOOP_TERMINATED) {
end_session = TRUE;
} else {
/* Ack the byte */
ahd_outb(ahd, CLRSINT1, CLRREQINIT);
ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_READ);
}
break;
}
case MSG_TYPE_TARGET_MSGIN:
{
int msgdone;
int msgout_request;
/*
* By default, the message loop will continue.
*/
ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG);
if (ahd->msgout_len == 0)
panic("Target MSGIN with no active message");
/*
* If we interrupted a mesgout session, the initiator
* will not know this until our first REQ. So, we
* only honor mesgout requests after we've sent our
* first byte.
*/
if ((ahd_inb(ahd, SCSISIGI) & ATNI) != 0
&& ahd->msgout_index > 0)
msgout_request = TRUE;
else
msgout_request = FALSE;
if (msgout_request) {
/*
* Change gears and see if
* this messages is of interest to
* us or should be passed back to
* the sequencer.
*/
ahd->msg_type = MSG_TYPE_TARGET_MSGOUT;
ahd_outb(ahd, SCSISIGO, P_MESGOUT | BSYO);
ahd->msgin_index = 0;
/* Dummy read to REQ for first byte */
ahd_inb(ahd, SCSIDAT);
ahd_outb(ahd, SXFRCTL0,
ahd_inb(ahd, SXFRCTL0) | SPIOEN);
break;
}
msgdone = ahd->msgout_index == ahd->msgout_len;
if (msgdone) {
ahd_outb(ahd, SXFRCTL0,
ahd_inb(ahd, SXFRCTL0) & ~SPIOEN);
end_session = TRUE;
break;
}
/*
* Present the next byte on the bus.
*/
ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) | SPIOEN);
ahd_outb(ahd, SCSIDAT, ahd->msgout_buf[ahd->msgout_index++]);
break;
}
case MSG_TYPE_TARGET_MSGOUT:
{
int lastbyte;
int msgdone;
/*
* By default, the message loop will continue.
*/
ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG);
/*
* The initiator signals that this is
* the last byte by dropping ATN.
*/
lastbyte = (ahd_inb(ahd, SCSISIGI) & ATNI) == 0;
/*
* Read the latched byte, but turn off SPIOEN first
* so that we don't inadvertently cause a REQ for the
* next byte.
*/
ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) & ~SPIOEN);
ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIDAT);
msgdone = ahd_parse_msg(ahd, &devinfo);
if (msgdone == MSGLOOP_TERMINATED) {
/*
* The message is *really* done in that it caused
* us to go to bus free. The sequencer has already
* been reset at this point, so pull the ejection
* handle.
*/
return;
}
ahd->msgin_index++;
/*
* XXX Read spec about initiator dropping ATN too soon
* and use msgdone to detect it.
*/
if (msgdone == MSGLOOP_MSGCOMPLETE) {
ahd->msgin_index = 0;
/*
* If this message illicited a response, transition
* to the Message in phase and send it.
*/
if (ahd->msgout_len != 0) {
ahd_outb(ahd, SCSISIGO, P_MESGIN | BSYO);
ahd_outb(ahd, SXFRCTL0,
ahd_inb(ahd, SXFRCTL0) | SPIOEN);
ahd->msg_type = MSG_TYPE_TARGET_MSGIN;
ahd->msgin_index = 0;
break;
}
}
if (lastbyte)
end_session = TRUE;
else {
/* Ask for the next byte. */
ahd_outb(ahd, SXFRCTL0,
ahd_inb(ahd, SXFRCTL0) | SPIOEN);
}
break;
}
default:
panic("Unknown REQINIT message type");
}
if (end_session) {
if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0) {
printk("%s: Returning to Idle Loop\n",
ahd_name(ahd));
ahd_clear_msg_state(ahd);
/*
* Perform the equivalent of a clear_target_state.
*/
ahd_outb(ahd, LASTPHASE, P_BUSFREE);
ahd_outb(ahd, SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT);
ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET);
} else {
ahd_clear_msg_state(ahd);
ahd_outb(ahd, RETURN_1, EXIT_MSG_LOOP);
}
}
}
/*
* See if we sent a particular extended message to the target.
* If "full" is true, return true only if the target saw the full
* message. If "full" is false, return true if the target saw at
* least the first byte of the message.
*/
static int
ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type, u_int msgval, int full)
{
int found;
u_int index;
found = FALSE;
index = 0;
while (index < ahd->msgout_len) {
if (ahd->msgout_buf[index] == MSG_EXTENDED) {
u_int end_index;
end_index = index + 1 + ahd->msgout_buf[index + 1];
if (ahd->msgout_buf[index+2] == msgval
&& type == AHDMSG_EXT) {
if (full) {
if (ahd->msgout_index > end_index)
found = TRUE;
} else if (ahd->msgout_index > index)
found = TRUE;
}
index = end_index;
} else if (ahd->msgout_buf[index] >= MSG_SIMPLE_TASK
&& ahd->msgout_buf[index] <= MSG_IGN_WIDE_RESIDUE) {
/* Skip tag type and tag id or residue param*/
index += 2;
} else {
/* Single byte message */
if (type == AHDMSG_1B
&& ahd->msgout_index > index
&& (ahd->msgout_buf[index] == msgval
|| ((ahd->msgout_buf[index] & MSG_IDENTIFYFLAG) != 0
&& msgval == MSG_IDENTIFYFLAG)))
found = TRUE;
index++;
}
if (found)
break;
}
return (found);
}
/*
* Wait for a complete incoming message, parse it, and respond accordingly.
*/
static int
ahd_parse_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
int reject;
int done;
int response;
done = MSGLOOP_IN_PROG;
response = FALSE;
reject = FALSE;
tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
devinfo->target, &tstate);
/*
* Parse as much of the message as is available,
* rejecting it if we don't support it. When
* the entire message is available and has been
* handled, return MSGLOOP_MSGCOMPLETE, indicating
* that we have parsed an entire message.
*
* In the case of extended messages, we accept the length
* byte outright and perform more checking once we know the
* extended message type.
*/
switch (ahd->msgin_buf[0]) {
case MSG_DISCONNECT:
case MSG_SAVEDATAPOINTER:
case MSG_CMDCOMPLETE:
case MSG_RESTOREPOINTERS:
case MSG_IGN_WIDE_RESIDUE:
/*
* End our message loop as these are messages
* the sequencer handles on its own.
*/
done = MSGLOOP_TERMINATED;
break;
case MSG_MESSAGE_REJECT:
response = ahd_handle_msg_reject(ahd, devinfo);
/* FALLTHROUGH */
case MSG_NOOP:
done = MSGLOOP_MSGCOMPLETE;
break;
case MSG_EXTENDED:
{
/* Wait for enough of the message to begin validation */
if (ahd->msgin_index < 2)
break;
switch (ahd->msgin_buf[2]) {
case MSG_EXT_SDTR:
{
u_int period;
u_int ppr_options;
u_int offset;
u_int saved_offset;
if (ahd->msgin_buf[1] != MSG_EXT_SDTR_LEN) {
reject = TRUE;
break;
}
/*
* Wait until we have both args before validating
* and acting on this message.
*
* Add one to MSG_EXT_SDTR_LEN to account for
* the extended message preamble.
*/
if (ahd->msgin_index < (MSG_EXT_SDTR_LEN + 1))
break;
period = ahd->msgin_buf[3];
ppr_options = 0;
saved_offset = offset = ahd->msgin_buf[4];
ahd_devlimited_syncrate(ahd, tinfo, &period,
&ppr_options, devinfo->role);
ahd_validate_offset(ahd, tinfo, period, &offset,
tinfo->curr.width, devinfo->role);
if (bootverbose) {
printk("(%s:%c:%d:%d): Received "
"SDTR period %x, offset %x\n\t"
"Filtered to period %x, offset %x\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun,
ahd->msgin_buf[3], saved_offset,
period, offset);
}
ahd_set_syncrate(ahd, devinfo, period,
offset, ppr_options,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
/*
* See if we initiated Sync Negotiation
* and didn't have to fall down to async
* transfers.
*/
if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, TRUE)) {
/* We started it */
if (saved_offset != offset) {
/* Went too low - force async */
reject = TRUE;
}
} else {
/*
* Send our own SDTR in reply
*/
if (bootverbose
&& devinfo->role == ROLE_INITIATOR) {
printk("(%s:%c:%d:%d): Target "
"Initiated SDTR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
}
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_construct_sdtr(ahd, devinfo,
period, offset);
ahd->msgout_index = 0;
response = TRUE;
}
done = MSGLOOP_MSGCOMPLETE;
break;
}
case MSG_EXT_WDTR:
{
u_int bus_width;
u_int saved_width;
u_int sending_reply;
sending_reply = FALSE;
if (ahd->msgin_buf[1] != MSG_EXT_WDTR_LEN) {
reject = TRUE;
break;
}
/*
* Wait until we have our arg before validating
* and acting on this message.
*
* Add one to MSG_EXT_WDTR_LEN to account for
* the extended message preamble.
*/
if (ahd->msgin_index < (MSG_EXT_WDTR_LEN + 1))
break;
bus_width = ahd->msgin_buf[3];
saved_width = bus_width;
ahd_validate_width(ahd, tinfo, &bus_width,
devinfo->role);
if (bootverbose) {
printk("(%s:%c:%d:%d): Received WDTR "
"%x filtered to %x\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun,
saved_width, bus_width);
}
if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, TRUE)) {
/*
* Don't send a WDTR back to the
* target, since we asked first.
* If the width went higher than our
* request, reject it.
*/
if (saved_width > bus_width) {
reject = TRUE;
printk("(%s:%c:%d:%d): requested %dBit "
"transfers. Rejecting...\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun,
8 * (0x01 << bus_width));
bus_width = 0;
}
} else {
/*
* Send our own WDTR in reply
*/
if (bootverbose
&& devinfo->role == ROLE_INITIATOR) {
printk("(%s:%c:%d:%d): Target "
"Initiated WDTR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
}
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_construct_wdtr(ahd, devinfo, bus_width);
ahd->msgout_index = 0;
response = TRUE;
sending_reply = TRUE;
}
/*
* After a wide message, we are async, but
* some devices don't seem to honor this portion
* of the spec. Force a renegotiation of the
* sync component of our transfer agreement even
* if our goal is async. By updating our width
* after forcing the negotiation, we avoid
* renegotiating for width.
*/
ahd_update_neg_request(ahd, devinfo, tstate,
tinfo, AHD_NEG_ALWAYS);
ahd_set_width(ahd, devinfo, bus_width,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
if (sending_reply == FALSE && reject == FALSE) {
/*
* We will always have an SDTR to send.
*/
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_build_transfer_msg(ahd, devinfo);
ahd->msgout_index = 0;
response = TRUE;
}
done = MSGLOOP_MSGCOMPLETE;
break;
}
case MSG_EXT_PPR:
{
u_int period;
u_int offset;
u_int bus_width;
u_int ppr_options;
u_int saved_width;
u_int saved_offset;
u_int saved_ppr_options;
if (ahd->msgin_buf[1] != MSG_EXT_PPR_LEN) {
reject = TRUE;
break;
}
/*
* Wait until we have all args before validating
* and acting on this message.
*
* Add one to MSG_EXT_PPR_LEN to account for
* the extended message preamble.
*/
if (ahd->msgin_index < (MSG_EXT_PPR_LEN + 1))
break;
period = ahd->msgin_buf[3];
offset = ahd->msgin_buf[5];
bus_width = ahd->msgin_buf[6];
saved_width = bus_width;
ppr_options = ahd->msgin_buf[7];
/*
* According to the spec, a DT only
* period factor with no DT option
* set implies async.
*/
if ((ppr_options & MSG_EXT_PPR_DT_REQ) == 0
&& period <= 9)
offset = 0;
saved_ppr_options = ppr_options;
saved_offset = offset;
/*
* Transfer options are only available if we
* are negotiating wide.
*/
if (bus_width == 0)
ppr_options &= MSG_EXT_PPR_QAS_REQ;
ahd_validate_width(ahd, tinfo, &bus_width,
devinfo->role);
ahd_devlimited_syncrate(ahd, tinfo, &period,
&ppr_options, devinfo->role);
ahd_validate_offset(ahd, tinfo, period, &offset,
bus_width, devinfo->role);
if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, TRUE)) {
/*
* If we are unable to do any of the
* requested options (we went too low),
* then we'll have to reject the message.
*/
if (saved_width > bus_width
|| saved_offset != offset
|| saved_ppr_options != ppr_options) {
reject = TRUE;
period = 0;
offset = 0;
bus_width = 0;
ppr_options = 0;
}
} else {
if (devinfo->role != ROLE_TARGET)
printk("(%s:%c:%d:%d): Target "
"Initiated PPR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
else
printk("(%s:%c:%d:%d): Initiator "
"Initiated PPR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_construct_ppr(ahd, devinfo, period, offset,
bus_width, ppr_options);
ahd->msgout_index = 0;
response = TRUE;
}
if (bootverbose) {
printk("(%s:%c:%d:%d): Received PPR width %x, "
"period %x, offset %x,options %x\n"
"\tFiltered to width %x, period %x, "
"offset %x, options %x\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun,
saved_width, ahd->msgin_buf[3],
saved_offset, saved_ppr_options,
bus_width, period, offset, ppr_options);
}
ahd_set_width(ahd, devinfo, bus_width,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
ahd_set_syncrate(ahd, devinfo, period,
offset, ppr_options,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
done = MSGLOOP_MSGCOMPLETE;
break;
}
default:
/* Unknown extended message. Reject it. */
reject = TRUE;
break;
}
break;
}
#ifdef AHD_TARGET_MODE
case MSG_BUS_DEV_RESET:
ahd_handle_devreset(ahd, devinfo, CAM_LUN_WILDCARD,
CAM_BDR_SENT,
"Bus Device Reset Received",
/*verbose_level*/0);
ahd_restart(ahd);
done = MSGLOOP_TERMINATED;
break;
case MSG_ABORT_TAG:
case MSG_ABORT:
case MSG_CLEAR_QUEUE:
{
int tag;
/* Target mode messages */
if (devinfo->role != ROLE_TARGET) {
reject = TRUE;
break;
}
tag = SCB_LIST_NULL;
if (ahd->msgin_buf[0] == MSG_ABORT_TAG)
tag = ahd_inb(ahd, INITIATOR_TAG);
ahd_abort_scbs(ahd, devinfo->target, devinfo->channel,
devinfo->lun, tag, ROLE_TARGET,
CAM_REQ_ABORTED);
tstate = ahd->enabled_targets[devinfo->our_scsiid];
if (tstate != NULL) {
struct ahd_tmode_lstate* lstate;
lstate = tstate->enabled_luns[devinfo->lun];
if (lstate != NULL) {
ahd_queue_lstate_event(ahd, lstate,
devinfo->our_scsiid,
ahd->msgin_buf[0],
/*arg*/tag);
ahd_send_lstate_events(ahd, lstate);
}
}
ahd_restart(ahd);
done = MSGLOOP_TERMINATED;
break;
}
#endif
case MSG_QAS_REQUEST:
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printk("%s: QAS request. SCSISIGI == 0x%x\n",
ahd_name(ahd), ahd_inb(ahd, SCSISIGI));
#endif
ahd->msg_flags |= MSG_FLAG_EXPECT_QASREJ_BUSFREE;
/* FALLTHROUGH */
case MSG_TERM_IO_PROC:
default:
reject = TRUE;
break;
}
if (reject) {
/*
* Setup to reject the message.
*/
ahd->msgout_index = 0;
ahd->msgout_len = 1;
ahd->msgout_buf[0] = MSG_MESSAGE_REJECT;
done = MSGLOOP_MSGCOMPLETE;
response = TRUE;
}
if (done != MSGLOOP_IN_PROG && !response)
/* Clear the outgoing message buffer */
ahd->msgout_len = 0;
return (done);
}
/*
* Process a message reject message.
*/
static int
ahd_handle_msg_reject(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
/*
* What we care about here is if we had an
* outstanding SDTR or WDTR message for this
* target. If we did, this is a signal that
* the target is refusing negotiation.
*/
struct scb *scb;
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
u_int scb_index;
u_int last_msg;
int response = 0;
scb_index = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scb_index);
tinfo = ahd_fetch_transinfo(ahd, devinfo->channel,
devinfo->our_scsiid,
devinfo->target, &tstate);
/* Might be necessary */
last_msg = ahd_inb(ahd, LAST_MSG);
if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, /*full*/FALSE)) {
if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, /*full*/TRUE)
&& tinfo->goal.period <= AHD_SYNCRATE_PACED) {
/*
* Target may not like our SPI-4 PPR Options.
* Attempt to negotiate 80MHz which will turn
* off these options.
*/
if (bootverbose) {
printk("(%s:%c:%d:%d): PPR Rejected. "
"Trying simple U160 PPR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
}
tinfo->goal.period = AHD_SYNCRATE_DT;
tinfo->goal.ppr_options &= MSG_EXT_PPR_IU_REQ
| MSG_EXT_PPR_QAS_REQ
| MSG_EXT_PPR_DT_REQ;
} else {
/*
* Target does not support the PPR message.
* Attempt to negotiate SPI-2 style.
*/
if (bootverbose) {
printk("(%s:%c:%d:%d): PPR Rejected. "
"Trying WDTR/SDTR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
}
tinfo->goal.ppr_options = 0;
tinfo->curr.transport_version = 2;
tinfo->goal.transport_version = 2;
}
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_build_transfer_msg(ahd, devinfo);
ahd->msgout_index = 0;
response = 1;
} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, /*full*/FALSE)) {
/* note 8bit xfers */
printk("(%s:%c:%d:%d): refuses WIDE negotiation. Using "
"8bit transfers\n", ahd_name(ahd),
devinfo->channel, devinfo->target, devinfo->lun);
ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
/*
* No need to clear the sync rate. If the target
* did not accept the command, our syncrate is
* unaffected. If the target started the negotiation,
* but rejected our response, we already cleared the
* sync rate before sending our WDTR.
*/
if (tinfo->goal.offset != tinfo->curr.offset) {
/* Start the sync negotiation */
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_build_transfer_msg(ahd, devinfo);
ahd->msgout_index = 0;
response = 1;
}
} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, /*full*/FALSE)) {
/* note asynch xfers and clear flag */
ahd_set_syncrate(ahd, devinfo, /*period*/0,
/*offset*/0, /*ppr_options*/0,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
printk("(%s:%c:%d:%d): refuses synchronous negotiation. "
"Using asynchronous transfers\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
} else if ((scb->hscb->control & MSG_SIMPLE_TASK) != 0) {
int tag_type;
int mask;
tag_type = (scb->hscb->control & MSG_SIMPLE_TASK);
if (tag_type == MSG_SIMPLE_TASK) {
printk("(%s:%c:%d:%d): refuses tagged commands. "
"Performing non-tagged I/O\n", ahd_name(ahd),
devinfo->channel, devinfo->target, devinfo->lun);
ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_NONE);
mask = ~0x23;
} else {
printk("(%s:%c:%d:%d): refuses %s tagged commands. "
"Performing simple queue tagged I/O only\n",
ahd_name(ahd), devinfo->channel, devinfo->target,
devinfo->lun, tag_type == MSG_ORDERED_TASK
? "ordered" : "head of queue");
ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_BASIC);
mask = ~0x03;
}
/*
* Resend the identify for this CCB as the target
* may believe that the selection is invalid otherwise.
*/
ahd_outb(ahd, SCB_CONTROL,
ahd_inb_scbram(ahd, SCB_CONTROL) & mask);
scb->hscb->control &= mask;
ahd_set_transaction_tag(scb, /*enabled*/FALSE,
/*type*/MSG_SIMPLE_TASK);
ahd_outb(ahd, MSG_OUT, MSG_IDENTIFYFLAG);
ahd_assert_atn(ahd);
ahd_busy_tcl(ahd, BUILD_TCL(scb->hscb->scsiid, devinfo->lun),
SCB_GET_TAG(scb));
/*
* Requeue all tagged commands for this target
* currently in our possession so they can be
* converted to untagged commands.
*/
ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
SCB_GET_CHANNEL(ahd, scb),
SCB_GET_LUN(scb), /*tag*/SCB_LIST_NULL,
ROLE_INITIATOR, CAM_REQUEUE_REQ,
SEARCH_COMPLETE);
} else if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_IDENTIFYFLAG, TRUE)) {
/*
* Most likely the device believes that we had
* previously negotiated packetized.
*/
ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE
| MSG_FLAG_IU_REQ_CHANGED;
ahd_force_renegotiation(ahd, devinfo);
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_build_transfer_msg(ahd, devinfo);
ahd->msgout_index = 0;
response = 1;
} else {
/*
* Otherwise, we ignore it.
*/
printk("%s:%c:%d: Message reject for %x -- ignored\n",
ahd_name(ahd), devinfo->channel, devinfo->target,
last_msg);
}
return (response);
}
/*
* Process an ingnore wide residue message.
*/
static void
ahd_handle_ign_wide_residue(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
u_int scb_index;
struct scb *scb;
scb_index = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scb_index);
/*
* XXX Actually check data direction in the sequencer?
* Perhaps add datadir to some spare bits in the hscb?
*/
if ((ahd_inb(ahd, SEQ_FLAGS) & DPHASE) == 0
|| ahd_get_transfer_dir(scb) != CAM_DIR_IN) {
/*
* Ignore the message if we haven't
* seen an appropriate data phase yet.
*/
} else {
/*
* If the residual occurred on the last
* transfer and the transfer request was
* expected to end on an odd count, do
* nothing. Otherwise, subtract a byte
* and update the residual count accordingly.
*/
uint32_t sgptr;
sgptr = ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR);
if ((sgptr & SG_LIST_NULL) != 0
&& (ahd_inb_scbram(ahd, SCB_TASK_ATTRIBUTE)
& SCB_XFERLEN_ODD) != 0) {
/*
* If the residual occurred on the last
* transfer and the transfer request was
* expected to end on an odd count, do
* nothing.
*/
} else {
uint32_t data_cnt;
uint64_t data_addr;
uint32_t sglen;
/* Pull in the rest of the sgptr */
sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
data_cnt = ahd_inl_scbram(ahd, SCB_RESIDUAL_DATACNT);
if ((sgptr & SG_LIST_NULL) != 0) {
/*
* The residual data count is not updated
* for the command run to completion case.
* Explicitly zero the count.
*/
data_cnt &= ~AHD_SG_LEN_MASK;
}
data_addr = ahd_inq(ahd, SHADDR);
data_cnt += 1;
data_addr -= 1;
sgptr &= SG_PTR_MASK;
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
/*
* The residual sg ptr points to the next S/G
* to load so we must go back one.
*/
sg--;
sglen = ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
if (sg != scb->sg_list
&& sglen < (data_cnt & AHD_SG_LEN_MASK)) {
sg--;
sglen = ahd_le32toh(sg->len);
/*
* Preserve High Address and SG_LIST
* bits while setting the count to 1.
*/
data_cnt = 1|(sglen&(~AHD_SG_LEN_MASK));
data_addr = ahd_le64toh(sg->addr)
+ (sglen & AHD_SG_LEN_MASK)
- 1;
/*
* Increment sg so it points to the
* "next" sg.
*/
sg++;
sgptr = ahd_sg_virt_to_bus(ahd, scb,
sg);
}
} else {
struct ahd_dma_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
/*
* The residual sg ptr points to the next S/G
* to load so we must go back one.
*/
sg--;
sglen = ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
if (sg != scb->sg_list
&& sglen < (data_cnt & AHD_SG_LEN_MASK)) {
sg--;
sglen = ahd_le32toh(sg->len);
/*
* Preserve High Address and SG_LIST
* bits while setting the count to 1.
*/
data_cnt = 1|(sglen&(~AHD_SG_LEN_MASK));
data_addr = ahd_le32toh(sg->addr)
+ (sglen & AHD_SG_LEN_MASK)
- 1;
/*
* Increment sg so it points to the
* "next" sg.
*/
sg++;
sgptr = ahd_sg_virt_to_bus(ahd, scb,
sg);
}
}
/*
* Toggle the "oddness" of the transfer length
* to handle this mid-transfer ignore wide
* residue. This ensures that the oddness is
* correct for subsequent data transfers.
*/
ahd_outb(ahd, SCB_TASK_ATTRIBUTE,
ahd_inb_scbram(ahd, SCB_TASK_ATTRIBUTE)
^ SCB_XFERLEN_ODD);
ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr);
ahd_outl(ahd, SCB_RESIDUAL_DATACNT, data_cnt);
/*
* The FIFO's pointers will be updated if/when the
* sequencer re-enters a data phase.
*/
}
}
}
/*
* Reinitialize the data pointers for the active transfer
* based on its current residual.
*/
static void
ahd_reinitialize_dataptrs(struct ahd_softc *ahd)
{
struct scb *scb;
ahd_mode_state saved_modes;
u_int scb_index;
u_int wait;
uint32_t sgptr;
uint32_t resid;
uint64_t dataptr;
AHD_ASSERT_MODES(ahd, AHD_MODE_DFF0_MSK|AHD_MODE_DFF1_MSK,
AHD_MODE_DFF0_MSK|AHD_MODE_DFF1_MSK);
scb_index = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scb_index);
/*
* Release and reacquire the FIFO so we
* have a clean slate.
*/
ahd_outb(ahd, DFFSXFRCTL, CLRCHN);
wait = 1000;
while (--wait && !(ahd_inb(ahd, MDFFSTAT) & FIFOFREE))
ahd_delay(100);
if (wait == 0) {
ahd_print_path(ahd, scb);
printk("ahd_reinitialize_dataptrs: Forcing FIFO free.\n");
ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT);
}
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, DFFSTAT,
ahd_inb(ahd, DFFSTAT)
| (saved_modes == 0x11 ? CURRFIFO_1 : CURRFIFO_0));
/*
* Determine initial values for data_addr and data_cnt
* for resuming the data phase.
*/
sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
sgptr &= SG_PTR_MASK;
resid = (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 2) << 16)
| (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 1) << 8)
| ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT);
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
/* The residual sg_ptr always points to the next sg */
sg--;
dataptr = ahd_le64toh(sg->addr)
+ (ahd_le32toh(sg->len) & AHD_SG_LEN_MASK)
- resid;
ahd_outl(ahd, HADDR + 4, dataptr >> 32);
} else {
struct ahd_dma_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
/* The residual sg_ptr always points to the next sg */
sg--;
dataptr = ahd_le32toh(sg->addr)
+ (ahd_le32toh(sg->len) & AHD_SG_LEN_MASK)
- resid;
ahd_outb(ahd, HADDR + 4,
(ahd_le32toh(sg->len) & ~AHD_SG_LEN_MASK) >> 24);
}
ahd_outl(ahd, HADDR, dataptr);
ahd_outb(ahd, HCNT + 2, resid >> 16);
ahd_outb(ahd, HCNT + 1, resid >> 8);
ahd_outb(ahd, HCNT, resid);
}
/*
* Handle the effects of issuing a bus device reset message.
*/
static void
ahd_handle_devreset(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int lun, cam_status status, char *message,
int verbose_level)
{
#ifdef AHD_TARGET_MODE
struct ahd_tmode_tstate* tstate;
#endif
int found;
found = ahd_abort_scbs(ahd, devinfo->target, devinfo->channel,
lun, SCB_LIST_NULL, devinfo->role,
status);
#ifdef AHD_TARGET_MODE
/*
* Send an immediate notify ccb to all target mord peripheral
* drivers affected by this action.
*/
tstate = ahd->enabled_targets[devinfo->our_scsiid];
if (tstate != NULL) {
u_int cur_lun;
u_int max_lun;
if (lun != CAM_LUN_WILDCARD) {
cur_lun = 0;
max_lun = AHD_NUM_LUNS - 1;
} else {
cur_lun = lun;
max_lun = lun;
}
for (;cur_lun <= max_lun; cur_lun++) {
struct ahd_tmode_lstate* lstate;
lstate = tstate->enabled_luns[cur_lun];
if (lstate == NULL)
continue;
ahd_queue_lstate_event(ahd, lstate, devinfo->our_scsiid,
MSG_BUS_DEV_RESET, /*arg*/0);
ahd_send_lstate_events(ahd, lstate);
}
}
#endif
/*
* Go back to async/narrow transfers and renegotiate.
*/
ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR, /*paused*/TRUE);
ahd_set_syncrate(ahd, devinfo, /*period*/0, /*offset*/0,
/*ppr_options*/0, AHD_TRANS_CUR,
/*paused*/TRUE);
if (status != CAM_SEL_TIMEOUT)
ahd_send_async(ahd, devinfo->channel, devinfo->target,
CAM_LUN_WILDCARD, AC_SENT_BDR);
if (message != NULL && bootverbose)
printk("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd),
message, devinfo->channel, devinfo->target, found);
}
#ifdef AHD_TARGET_MODE
static void
ahd_setup_target_msgin(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
struct scb *scb)
{
/*
* To facilitate adding multiple messages together,
* each routine should increment the index and len
* variables instead of setting them explicitly.
*/
ahd->msgout_index = 0;
ahd->msgout_len = 0;
if (scb != NULL && (scb->flags & SCB_AUTO_NEGOTIATE) != 0)
ahd_build_transfer_msg(ahd, devinfo);
else
panic("ahd_intr: AWAITING target message with no message");
ahd->msgout_index = 0;
ahd->msg_type = MSG_TYPE_TARGET_MSGIN;
}
#endif
/**************************** Initialization **********************************/
static u_int
ahd_sglist_size(struct ahd_softc *ahd)
{
bus_size_t list_size;
list_size = sizeof(struct ahd_dma_seg) * AHD_NSEG;
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
list_size = sizeof(struct ahd_dma64_seg) * AHD_NSEG;
return (list_size);
}
/*
* Calculate the optimum S/G List allocation size. S/G elements used
* for a given transaction must be physically contiguous. Assume the
* OS will allocate full pages to us, so it doesn't make sense to request
* less than a page.
*/
static u_int
ahd_sglist_allocsize(struct ahd_softc *ahd)
{
bus_size_t sg_list_increment;
bus_size_t sg_list_size;
bus_size_t max_list_size;
bus_size_t best_list_size;
/* Start out with the minimum required for AHD_NSEG. */
sg_list_increment = ahd_sglist_size(ahd);
sg_list_size = sg_list_increment;
/* Get us as close as possible to a page in size. */
while ((sg_list_size + sg_list_increment) <= PAGE_SIZE)
sg_list_size += sg_list_increment;
/*
* Try to reduce the amount of wastage by allocating
* multiple pages.
*/
best_list_size = sg_list_size;
max_list_size = roundup(sg_list_increment, PAGE_SIZE);
if (max_list_size < 4 * PAGE_SIZE)
max_list_size = 4 * PAGE_SIZE;
if (max_list_size > (AHD_SCB_MAX_ALLOC * sg_list_increment))
max_list_size = (AHD_SCB_MAX_ALLOC * sg_list_increment);
while ((sg_list_size + sg_list_increment) <= max_list_size
&& (sg_list_size % PAGE_SIZE) != 0) {
bus_size_t new_mod;
bus_size_t best_mod;
sg_list_size += sg_list_increment;
new_mod = sg_list_size % PAGE_SIZE;
best_mod = best_list_size % PAGE_SIZE;
if (new_mod > best_mod || new_mod == 0) {
best_list_size = sg_list_size;
}
}
return (best_list_size);
}
/*
* Allocate a controller structure for a new device
* and perform initial initializion.
*/
struct ahd_softc *
ahd_alloc(void *platform_arg, char *name)
{
struct ahd_softc *ahd;
#ifndef __FreeBSD__
ahd = kmalloc(sizeof(*ahd), GFP_ATOMIC);
if (!ahd) {
printk("aic7xxx: cannot malloc softc!\n");
kfree(name);
return NULL;
}
#else
ahd = device_get_softc((device_t)platform_arg);
#endif
memset(ahd, 0, sizeof(*ahd));
ahd->seep_config = kmalloc(sizeof(*ahd->seep_config), GFP_ATOMIC);
if (ahd->seep_config == NULL) {
#ifndef __FreeBSD__
kfree(ahd);
#endif
kfree(name);
return (NULL);
}
LIST_INIT(&ahd->pending_scbs);
/* We don't know our unit number until the OSM sets it */
ahd->name = name;
ahd->unit = -1;
ahd->description = NULL;
ahd->bus_description = NULL;
ahd->channel = 'A';
ahd->chip = AHD_NONE;
ahd->features = AHD_FENONE;
ahd->bugs = AHD_BUGNONE;
ahd->flags = AHD_SPCHK_ENB_A|AHD_RESET_BUS_A|AHD_TERM_ENB_A
| AHD_EXTENDED_TRANS_A|AHD_STPWLEVEL_A;
timer_setup(&ahd->stat_timer, ahd_stat_timer, 0);
ahd->int_coalescing_timer = AHD_INT_COALESCING_TIMER_DEFAULT;
ahd->int_coalescing_maxcmds = AHD_INT_COALESCING_MAXCMDS_DEFAULT;
ahd->int_coalescing_mincmds = AHD_INT_COALESCING_MINCMDS_DEFAULT;
ahd->int_coalescing_threshold = AHD_INT_COALESCING_THRESHOLD_DEFAULT;
ahd->int_coalescing_stop_threshold =
AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MEMORY) != 0) {
printk("%s: scb size = 0x%x, hscb size = 0x%x\n",
ahd_name(ahd), (u_int)sizeof(struct scb),
(u_int)sizeof(struct hardware_scb));
}
#endif
if (ahd_platform_alloc(ahd, platform_arg) != 0) {
ahd_free(ahd);
ahd = NULL;
}
return (ahd);
}
int
ahd_softc_init(struct ahd_softc *ahd)
{
ahd->unpause = 0;
ahd->pause = PAUSE;
return (0);
}
void
ahd_set_unit(struct ahd_softc *ahd, int unit)
{
ahd->unit = unit;
}
void
ahd_set_name(struct ahd_softc *ahd, char *name)
{
if (ahd->name != NULL)
kfree(ahd->name);
ahd->name = name;
}
void
ahd_free(struct ahd_softc *ahd)
{
int i;
switch (ahd->init_level) {
default:
case 5:
ahd_shutdown(ahd);
/* FALLTHROUGH */
case 4:
ahd_dmamap_unload(ahd, ahd->shared_data_dmat,
ahd->shared_data_map.dmamap);
/* FALLTHROUGH */
case 3:
ahd_dmamem_free(ahd, ahd->shared_data_dmat, ahd->qoutfifo,
ahd->shared_data_map.dmamap);
ahd_dmamap_destroy(ahd, ahd->shared_data_dmat,
ahd->shared_data_map.dmamap);
/* FALLTHROUGH */
case 2:
ahd_dma_tag_destroy(ahd, ahd->shared_data_dmat);
case 1:
break;
case 0:
break;
}
ahd_platform_free(ahd);
ahd_fini_scbdata(ahd);
for (i = 0; i < AHD_NUM_TARGETS; i++) {
struct ahd_tmode_tstate *tstate;
tstate = ahd->enabled_targets[i];
if (tstate != NULL) {
#ifdef AHD_TARGET_MODE
int j;
for (j = 0; j < AHD_NUM_LUNS; j++) {
struct ahd_tmode_lstate *lstate;
lstate = tstate->enabled_luns[j];
if (lstate != NULL) {
xpt_free_path(lstate->path);
kfree(lstate);
}
}
#endif
kfree(tstate);
}
}
#ifdef AHD_TARGET_MODE
if (ahd->black_hole != NULL) {
xpt_free_path(ahd->black_hole->path);
kfree(ahd->black_hole);
}
#endif
if (ahd->name != NULL)
kfree(ahd->name);
if (ahd->seep_config != NULL)
kfree(ahd->seep_config);
if (ahd->saved_stack != NULL)
kfree(ahd->saved_stack);
#ifndef __FreeBSD__
kfree(ahd);
#endif
return;
}
static void
ahd_shutdown(void *arg)
{
struct ahd_softc *ahd;
ahd = (struct ahd_softc *)arg;
/*
* Stop periodic timer callbacks.
*/
del_timer_sync(&ahd->stat_timer);
/* This will reset most registers to 0, but not all */
ahd_reset(ahd, /*reinit*/FALSE);
}
/*
* Reset the controller and record some information about it
* that is only available just after a reset. If "reinit" is
* non-zero, this reset occurred after initial configuration
* and the caller requests that the chip be fully reinitialized
* to a runable state. Chip interrupts are *not* enabled after
* a reinitialization. The caller must enable interrupts via
* ahd_intr_enable().
*/
int
ahd_reset(struct ahd_softc *ahd, int reinit)
{
u_int sxfrctl1;
int wait;
uint32_t cmd;
/*
* Preserve the value of the SXFRCTL1 register for all channels.
* It contains settings that affect termination and we don't want
* to disturb the integrity of the bus.
*/
ahd_pause(ahd);
ahd_update_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
sxfrctl1 = ahd_inb(ahd, SXFRCTL1);
cmd = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2);
if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) {
uint32_t mod_cmd;
/*
* A4 Razor #632
* During the assertion of CHIPRST, the chip
* does not disable its parity logic prior to
* the start of the reset. This may cause a
* parity error to be detected and thus a
* spurious SERR or PERR assertion. Disable
* PERR and SERR responses during the CHIPRST.
*/
mod_cmd = cmd & ~(PCIM_CMD_PERRESPEN|PCIM_CMD_SERRESPEN);
ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
mod_cmd, /*bytes*/2);
}
ahd_outb(ahd, HCNTRL, CHIPRST | ahd->pause);
/*
* Ensure that the reset has finished. We delay 1000us
* prior to reading the register to make sure the chip
* has sufficiently completed its reset to handle register
* accesses.
*/
wait = 1000;
do {
ahd_delay(1000);
} while (--wait && !(ahd_inb(ahd, HCNTRL) & CHIPRSTACK));
if (wait == 0) {
printk("%s: WARNING - Failed chip reset! "
"Trying to initialize anyway.\n", ahd_name(ahd));
}
ahd_outb(ahd, HCNTRL, ahd->pause);
if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) {
/*
* Clear any latched PCI error status and restore
* previous SERR and PERR response enables.
*/
ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1,
0xFF, /*bytes*/1);
ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
cmd, /*bytes*/2);
}
/*
* Mode should be SCSI after a chip reset, but lets
* set it just to be safe. We touch the MODE_PTR
* register directly so as to bypass the lazy update
* code in ahd_set_modes().
*/
ahd_known_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, MODE_PTR,
ahd_build_mode_state(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI));
/*
* Restore SXFRCTL1.
*
* We must always initialize STPWEN to 1 before we
* restore the saved values. STPWEN is initialized
* to a tri-state condition which can only be cleared
* by turning it on.
*/
ahd_outb(ahd, SXFRCTL1, sxfrctl1|STPWEN);
ahd_outb(ahd, SXFRCTL1, sxfrctl1);
/* Determine chip configuration */
ahd->features &= ~AHD_WIDE;
if ((ahd_inb(ahd, SBLKCTL) & SELWIDE) != 0)
ahd->features |= AHD_WIDE;
/*
* If a recovery action has forced a chip reset,
* re-initialize the chip to our liking.
*/
if (reinit != 0)
ahd_chip_init(ahd);
return (0);
}
/*
* Determine the number of SCBs available on the controller
*/
static int
ahd_probe_scbs(struct ahd_softc *ahd) {
int i;
AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
for (i = 0; i < AHD_SCB_MAX; i++) {
int j;
ahd_set_scbptr(ahd, i);
ahd_outw(ahd, SCB_BASE, i);
for (j = 2; j < 64; j++)
ahd_outb(ahd, SCB_BASE+j, 0);
/* Start out life as unallocated (needing an abort) */
ahd_outb(ahd, SCB_CONTROL, MK_MESSAGE);
if (ahd_inw_scbram(ahd, SCB_BASE) != i)
break;
ahd_set_scbptr(ahd, 0);
if (ahd_inw_scbram(ahd, SCB_BASE) != 0)
break;
}
return (i);
}
static void
ahd_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
{
dma_addr_t *baddr;
baddr = (dma_addr_t *)arg;
*baddr = segs->ds_addr;
}
static void
ahd_initialize_hscbs(struct ahd_softc *ahd)
{
int i;
for (i = 0; i < ahd->scb_data.maxhscbs; i++) {
ahd_set_scbptr(ahd, i);
/* Clear the control byte. */
ahd_outb(ahd, SCB_CONTROL, 0);
/* Set the next pointer */
ahd_outw(ahd, SCB_NEXT, SCB_LIST_NULL);
}
}
static int
ahd_init_scbdata(struct ahd_softc *ahd)
{
struct scb_data *scb_data;
int i;
scb_data = &ahd->scb_data;
TAILQ_INIT(&scb_data->free_scbs);
for (i = 0; i < AHD_NUM_TARGETS * AHD_NUM_LUNS_NONPKT; i++)
LIST_INIT(&scb_data->free_scb_lists[i]);
LIST_INIT(&scb_data->any_dev_free_scb_list);
SLIST_INIT(&scb_data->hscb_maps);
SLIST_INIT(&scb_data->sg_maps);
SLIST_INIT(&scb_data->sense_maps);
/* Determine the number of hardware SCBs and initialize them */
scb_data->maxhscbs = ahd_probe_scbs(ahd);
if (scb_data->maxhscbs == 0) {
printk("%s: No SCB space found\n", ahd_name(ahd));
return (ENXIO);
}
ahd_initialize_hscbs(ahd);
/*
* Create our DMA tags. These tags define the kinds of device
* accessible memory allocations and memory mappings we will
* need to perform during normal operation.
*
* Unless we need to further restrict the allocation, we rely
* on the restrictions of the parent dmat, hence the common
* use of MAXADDR and MAXSIZE.
*/
/* DMA tag for our hardware scb structures */
if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
PAGE_SIZE, /*nsegments*/1,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &scb_data->hscb_dmat) != 0) {
goto error_exit;
}
scb_data->init_level++;
/* DMA tag for our S/G structures. */
if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/8,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
ahd_sglist_allocsize(ahd), /*nsegments*/1,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &scb_data->sg_dmat) != 0) {
goto error_exit;
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MEMORY) != 0)
printk("%s: ahd_sglist_allocsize = 0x%x\n", ahd_name(ahd),
ahd_sglist_allocsize(ahd));
#endif
scb_data->init_level++;
/* DMA tag for our sense buffers. We allocate in page sized chunks */
if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
PAGE_SIZE, /*nsegments*/1,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &scb_data->sense_dmat) != 0) {
goto error_exit;
}
scb_data->init_level++;
/* Perform initial CCB allocation */
ahd_alloc_scbs(ahd);
if (scb_data->numscbs == 0) {
printk("%s: ahd_init_scbdata - "
"Unable to allocate initial scbs\n",
ahd_name(ahd));
goto error_exit;
}
/*
* Note that we were successful
*/
return (0);
error_exit:
return (ENOMEM);
}
static struct scb *
ahd_find_scb_by_tag(struct ahd_softc *ahd, u_int tag)
{
struct scb *scb;
/*
* Look on the pending list.
*/
LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
if (SCB_GET_TAG(scb) == tag)
return (scb);
}
/*
* Then on all of the collision free lists.
*/
TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
struct scb *list_scb;
list_scb = scb;
do {
if (SCB_GET_TAG(list_scb) == tag)
return (list_scb);
list_scb = LIST_NEXT(list_scb, collision_links);
} while (list_scb);
}
/*
* And finally on the generic free list.
*/
LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) {
if (SCB_GET_TAG(scb) == tag)
return (scb);
}
return (NULL);
}
static void
ahd_fini_scbdata(struct ahd_softc *ahd)
{
struct scb_data *scb_data;
scb_data = &ahd->scb_data;
if (scb_data == NULL)
return;
switch (scb_data->init_level) {
default:
case 7:
{
struct map_node *sns_map;
while ((sns_map = SLIST_FIRST(&scb_data->sense_maps)) != NULL) {
SLIST_REMOVE_HEAD(&scb_data->sense_maps, links);
ahd_dmamap_unload(ahd, scb_data->sense_dmat,
sns_map->dmamap);
ahd_dmamem_free(ahd, scb_data->sense_dmat,
sns_map->vaddr, sns_map->dmamap);
kfree(sns_map);
}
ahd_dma_tag_destroy(ahd, scb_data->sense_dmat);
/* FALLTHROUGH */
}
case 6:
{
struct map_node *sg_map;
while ((sg_map = SLIST_FIRST(&scb_data->sg_maps)) != NULL) {
SLIST_REMOVE_HEAD(&scb_data->sg_maps, links);
ahd_dmamap_unload(ahd, scb_data->sg_dmat,
sg_map->dmamap);
ahd_dmamem_free(ahd, scb_data->sg_dmat,
sg_map->vaddr, sg_map->dmamap);
kfree(sg_map);
}
ahd_dma_tag_destroy(ahd, scb_data->sg_dmat);
/* FALLTHROUGH */
}
case 5:
{
struct map_node *hscb_map;
while ((hscb_map = SLIST_FIRST(&scb_data->hscb_maps)) != NULL) {
SLIST_REMOVE_HEAD(&scb_data->hscb_maps, links);
ahd_dmamap_unload(ahd, scb_data->hscb_dmat,
hscb_map->dmamap);
ahd_dmamem_free(ahd, scb_data->hscb_dmat,
hscb_map->vaddr, hscb_map->dmamap);
kfree(hscb_map);
}
ahd_dma_tag_destroy(ahd, scb_data->hscb_dmat);
/* FALLTHROUGH */
}
case 4:
case 3:
case 2:
case 1:
case 0:
break;
}
}
/*
* DSP filter Bypass must be enabled until the first selection
* after a change in bus mode (Razor #491 and #493).
*/
static void
ahd_setup_iocell_workaround(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
ahd_outb(ahd, DSPDATACTL, ahd_inb(ahd, DSPDATACTL)
| BYPASSENAB | RCVROFFSTDIS | XMITOFFSTDIS);
ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) | (ENSELDO|ENSELDI));
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printk("%s: Setting up iocell workaround\n", ahd_name(ahd));
#endif
ahd_restore_modes(ahd, saved_modes);
ahd->flags &= ~AHD_HAD_FIRST_SEL;
}
static void
ahd_iocell_first_selection(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
u_int sblkctl;
if ((ahd->flags & AHD_HAD_FIRST_SEL) != 0)
return;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
sblkctl = ahd_inb(ahd, SBLKCTL);
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printk("%s: iocell first selection\n", ahd_name(ahd));
#endif
if ((sblkctl & ENAB40) != 0) {
ahd_outb(ahd, DSPDATACTL,
ahd_inb(ahd, DSPDATACTL) & ~BYPASSENAB);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printk("%s: BYPASS now disabled\n", ahd_name(ahd));
#endif
}
ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) & ~(ENSELDO|ENSELDI));
ahd_outb(ahd, CLRINT, CLRSCSIINT);
ahd_restore_modes(ahd, saved_modes);
ahd->flags |= AHD_HAD_FIRST_SEL;
}
/*************************** SCB Management ***********************************/
static void
ahd_add_col_list(struct ahd_softc *ahd, struct scb *scb, u_int col_idx)
{
struct scb_list *free_list;
struct scb_tailq *free_tailq;
struct scb *first_scb;
scb->flags |= SCB_ON_COL_LIST;
AHD_SET_SCB_COL_IDX(scb, col_idx);
free_list = &ahd->scb_data.free_scb_lists[col_idx];
free_tailq = &ahd->scb_data.free_scbs;
first_scb = LIST_FIRST(free_list);
if (first_scb != NULL) {
LIST_INSERT_AFTER(first_scb, scb, collision_links);
} else {
LIST_INSERT_HEAD(free_list, scb, collision_links);
TAILQ_INSERT_TAIL(free_tailq, scb, links.tqe);
}
}
static void
ahd_rem_col_list(struct ahd_softc *ahd, struct scb *scb)
{
struct scb_list *free_list;
struct scb_tailq *free_tailq;
struct scb *first_scb;
u_int col_idx;
scb->flags &= ~SCB_ON_COL_LIST;
col_idx = AHD_GET_SCB_COL_IDX(ahd, scb);
free_list = &ahd->scb_data.free_scb_lists[col_idx];
free_tailq = &ahd->scb_data.free_scbs;
first_scb = LIST_FIRST(free_list);
if (first_scb == scb) {
struct scb *next_scb;
/*
* Maintain order in the collision free
* lists for fairness if this device has
* other colliding tags active.
*/
next_scb = LIST_NEXT(scb, collision_links);
if (next_scb != NULL) {
TAILQ_INSERT_AFTER(free_tailq, scb,
next_scb, links.tqe);
}
TAILQ_REMOVE(free_tailq, scb, links.tqe);
}
LIST_REMOVE(scb, collision_links);
}
/*
* Get a free scb. If there are none, see if we can allocate a new SCB.
*/
struct scb *
ahd_get_scb(struct ahd_softc *ahd, u_int col_idx)
{
struct scb *scb;
int tries;
tries = 0;
look_again:
TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
if (AHD_GET_SCB_COL_IDX(ahd, scb) != col_idx) {
ahd_rem_col_list(ahd, scb);
goto found;
}
}
if ((scb = LIST_FIRST(&ahd->scb_data.any_dev_free_scb_list)) == NULL) {
if (tries++ != 0)
return (NULL);
ahd_alloc_scbs(ahd);
goto look_again;
}
LIST_REMOVE(scb, links.le);
if (col_idx != AHD_NEVER_COL_IDX
&& (scb->col_scb != NULL)
&& (scb->col_scb->flags & SCB_ACTIVE) == 0) {
LIST_REMOVE(scb->col_scb, links.le);
ahd_add_col_list(ahd, scb->col_scb, col_idx);
}
found:
scb->flags |= SCB_ACTIVE;
return (scb);
}
/*
* Return an SCB resource to the free list.
*/
void
ahd_free_scb(struct ahd_softc *ahd, struct scb *scb)
{
/* Clean up for the next user */
scb->flags = SCB_FLAG_NONE;
scb->hscb->control = 0;
ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = NULL;
if (scb->col_scb == NULL) {
/*
* No collision possible. Just free normally.
*/
LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
scb, links.le);
} else if ((scb->col_scb->flags & SCB_ON_COL_LIST) != 0) {
/*
* The SCB we might have collided with is on
* a free collision list. Put both SCBs on
* the generic list.
*/
ahd_rem_col_list(ahd, scb->col_scb);
LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
scb, links.le);
LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
scb->col_scb, links.le);
} else if ((scb->col_scb->flags
& (SCB_PACKETIZED|SCB_ACTIVE)) == SCB_ACTIVE
&& (scb->col_scb->hscb->control & TAG_ENB) != 0) {
/*
* The SCB we might collide with on the next allocation
* is still active in a non-packetized, tagged, context.
* Put us on the SCB collision list.
*/
ahd_add_col_list(ahd, scb,
AHD_GET_SCB_COL_IDX(ahd, scb->col_scb));
} else {
/*
* The SCB we might collide with on the next allocation
* is either active in a packetized context, or free.
* Since we can't collide, put this SCB on the generic
* free list.
*/
LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
scb, links.le);
}
ahd_platform_scb_free(ahd, scb);
}
static void
ahd_alloc_scbs(struct ahd_softc *ahd)
{
struct scb_data *scb_data;
struct scb *next_scb;
struct hardware_scb *hscb;
struct map_node *hscb_map;
struct map_node *sg_map;
struct map_node *sense_map;
uint8_t *segs;
uint8_t *sense_data;
dma_addr_t hscb_busaddr;
dma_addr_t sg_busaddr;
dma_addr_t sense_busaddr;
int newcount;
int i;
scb_data = &ahd->scb_data;
if (scb_data->numscbs >= AHD_SCB_MAX_ALLOC)
/* Can't allocate any more */
return;
if (scb_data->scbs_left != 0) {
int offset;
offset = (PAGE_SIZE / sizeof(*hscb)) - scb_data->scbs_left;
hscb_map = SLIST_FIRST(&scb_data->hscb_maps);
hscb = &((struct hardware_scb *)hscb_map->vaddr)[offset];
hscb_busaddr = hscb_map->physaddr + (offset * sizeof(*hscb));
} else {
hscb_map = kmalloc(sizeof(*hscb_map), GFP_ATOMIC);
if (hscb_map == NULL)
return;
/* Allocate the next batch of hardware SCBs */
if (ahd_dmamem_alloc(ahd, scb_data->hscb_dmat,
(void **)&hscb_map->vaddr,
BUS_DMA_NOWAIT, &hscb_map->dmamap) != 0) {
kfree(hscb_map);
return;
}
SLIST_INSERT_HEAD(&scb_data->hscb_maps, hscb_map, links);
ahd_dmamap_load(ahd, scb_data->hscb_dmat, hscb_map->dmamap,
hscb_map->vaddr, PAGE_SIZE, ahd_dmamap_cb,
&hscb_map->physaddr, /*flags*/0);
hscb = (struct hardware_scb *)hscb_map->vaddr;
hscb_busaddr = hscb_map->physaddr;
scb_data->scbs_left = PAGE_SIZE / sizeof(*hscb);
}
if (scb_data->sgs_left != 0) {
int offset;
offset = ((ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd))
- scb_data->sgs_left) * ahd_sglist_size(ahd);
sg_map = SLIST_FIRST(&scb_data->sg_maps);
segs = sg_map->vaddr + offset;
sg_busaddr = sg_map->physaddr + offset;
} else {
sg_map = kmalloc(sizeof(*sg_map), GFP_ATOMIC);
if (sg_map == NULL)
return;
/* Allocate the next batch of S/G lists */
if (ahd_dmamem_alloc(ahd, scb_data->sg_dmat,
(void **)&sg_map->vaddr,
BUS_DMA_NOWAIT, &sg_map->dmamap) != 0) {
kfree(sg_map);
return;
}
SLIST_INSERT_HEAD(&scb_data->sg_maps, sg_map, links);
ahd_dmamap_load(ahd, scb_data->sg_dmat, sg_map->dmamap,
sg_map->vaddr, ahd_sglist_allocsize(ahd),
ahd_dmamap_cb, &sg_map->physaddr, /*flags*/0);
segs = sg_map->vaddr;
sg_busaddr = sg_map->physaddr;
scb_data->sgs_left =
ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd);
#ifdef AHD_DEBUG
if (ahd_debug & AHD_SHOW_MEMORY)
printk("Mapped SG data\n");
#endif
}
if (scb_data->sense_left != 0) {
int offset;
offset = PAGE_SIZE - (AHD_SENSE_BUFSIZE * scb_data->sense_left);
sense_map = SLIST_FIRST(&scb_data->sense_maps);
sense_data = sense_map->vaddr + offset;
sense_busaddr = sense_map->physaddr + offset;
} else {
sense_map = kmalloc(sizeof(*sense_map), GFP_ATOMIC);
if (sense_map == NULL)
return;
/* Allocate the next batch of sense buffers */
if (ahd_dmamem_alloc(ahd, scb_data->sense_dmat,
(void **)&sense_map->vaddr,
BUS_DMA_NOWAIT, &sense_map->dmamap) != 0) {
kfree(sense_map);
return;
}
SLIST_INSERT_HEAD(&scb_data->sense_maps, sense_map, links);
ahd_dmamap_load(ahd, scb_data->sense_dmat, sense_map->dmamap,
sense_map->vaddr, PAGE_SIZE, ahd_dmamap_cb,
&sense_map->physaddr, /*flags*/0);
sense_data = sense_map->vaddr;
sense_busaddr = sense_map->physaddr;
scb_data->sense_left = PAGE_SIZE / AHD_SENSE_BUFSIZE;
#ifdef AHD_DEBUG
if (ahd_debug & AHD_SHOW_MEMORY)
printk("Mapped sense data\n");
#endif
}
newcount = min(scb_data->sense_left, scb_data->scbs_left);
newcount = min(newcount, scb_data->sgs_left);
newcount = min(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));
for (i = 0; i < newcount; i++) {
struct scb_platform_data *pdata;
u_int col_tag;
next_scb = kmalloc(sizeof(*next_scb), GFP_ATOMIC);
if (next_scb == NULL)
break;
pdata = kmalloc(sizeof(*pdata), GFP_ATOMIC);
if (pdata == NULL) {
kfree(next_scb);
break;
}
next_scb->platform_data = pdata;
next_scb->hscb_map = hscb_map;
next_scb->sg_map = sg_map;
next_scb->sense_map = sense_map;
next_scb->sg_list = segs;
next_scb->sense_data = sense_data;
next_scb->sense_busaddr = sense_busaddr;
memset(hscb, 0, sizeof(*hscb));
next_scb->hscb = hscb;
hscb->hscb_busaddr = ahd_htole32(hscb_busaddr);
/*
* The sequencer always starts with the second entry.
* The first entry is embedded in the scb.
*/
next_scb->sg_list_busaddr = sg_busaddr;
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
next_scb->sg_list_busaddr
+= sizeof(struct ahd_dma64_seg);
else
next_scb->sg_list_busaddr += sizeof(struct ahd_dma_seg);
next_scb->ahd_softc = ahd;
next_scb->flags = SCB_FLAG_NONE;
next_scb->hscb->tag = ahd_htole16(scb_data->numscbs);
col_tag = scb_data->numscbs ^ 0x100;
next_scb->col_scb = ahd_find_scb_by_tag(ahd, col_tag);
if (next_scb->col_scb != NULL)
next_scb->col_scb->col_scb = next_scb;
ahd_free_scb(ahd, next_scb);
hscb++;
hscb_busaddr += sizeof(*hscb);
segs += ahd_sglist_size(ahd);
sg_busaddr += ahd_sglist_size(ahd);
sense_data += AHD_SENSE_BUFSIZE;
sense_busaddr += AHD_SENSE_BUFSIZE;
scb_data->numscbs++;
scb_data->sense_left--;
scb_data->scbs_left--;
scb_data->sgs_left--;
}
}
void
ahd_controller_info(struct ahd_softc *ahd, char *buf)
{
const char *speed;
const char *type;
int len;
len = sprintf(buf, "%s: ", ahd_chip_names[ahd->chip & AHD_CHIPID_MASK]);
buf += len;
speed = "Ultra320 ";
if ((ahd->features & AHD_WIDE) != 0) {
type = "Wide ";
} else {
type = "Single ";
}
len = sprintf(buf, "%s%sChannel %c, SCSI Id=%d, ",
speed, type, ahd->channel, ahd->our_id);
buf += len;
sprintf(buf, "%s, %d SCBs", ahd->bus_description,
ahd->scb_data.maxhscbs);
}
static const char *channel_strings[] = {
"Primary Low",
"Primary High",
"Secondary Low",
"Secondary High"
};
static const char *termstat_strings[] = {
"Terminated Correctly",
"Over Terminated",
"Under Terminated",
"Not Configured"
};
/***************************** Timer Facilities *******************************/
static void
ahd_timer_reset(struct timer_list *timer, int usec)
{
del_timer(timer);
timer->expires = jiffies + (usec * HZ)/1000000;
add_timer(timer);
}
/*
* Start the board, ready for normal operation
*/
int
ahd_init(struct ahd_softc *ahd)
{
uint8_t *next_vaddr;
dma_addr_t next_baddr;
size_t driver_data_size;
int i;
int error;
u_int warn_user;
uint8_t current_sensing;
uint8_t fstat;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
ahd->stack_size = ahd_probe_stack_size(ahd);
ahd->saved_stack = kmalloc_array(ahd->stack_size, sizeof(uint16_t),
GFP_ATOMIC);
if (ahd->saved_stack == NULL)
return (ENOMEM);
/*
* Verify that the compiler hasn't over-aggressively
* padded important structures.
*/
if (sizeof(struct hardware_scb) != 64)
panic("Hardware SCB size is incorrect");
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_DEBUG_SEQUENCER) != 0)
ahd->flags |= AHD_SEQUENCER_DEBUG;
#endif
/*
* Default to allowing initiator operations.
*/
ahd->flags |= AHD_INITIATORROLE;
/*
* Only allow target mode features if this unit has them enabled.
*/
if ((AHD_TMODE_ENABLE & (0x1 << ahd->unit)) == 0)
ahd->features &= ~AHD_TARGETMODE;
ahd->init_level++;
/*
* DMA tag for our command fifos and other data in system memory
* the card's sequencer must be able to access. For initiator
* roles, we need to allocate space for the qoutfifo. When providing
* for the target mode role, we must additionally provide space for
* the incoming target command fifo.
*/
driver_data_size = AHD_SCB_MAX * sizeof(*ahd->qoutfifo)
+ sizeof(struct hardware_scb);
if ((ahd->features & AHD_TARGETMODE) != 0)
driver_data_size += AHD_TMODE_CMDS * sizeof(struct target_cmd);
if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0)
driver_data_size += PKT_OVERRUN_BUFSIZE;
if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
driver_data_size,
/*nsegments*/1,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &ahd->shared_data_dmat) != 0) {
return (ENOMEM);
}
ahd->init_level++;
/* Allocation of driver data */
if (ahd_dmamem_alloc(ahd, ahd->shared_data_dmat,
(void **)&ahd->shared_data_map.vaddr,
BUS_DMA_NOWAIT,
&ahd->shared_data_map.dmamap) != 0) {
return (ENOMEM);
}
ahd->init_level++;
/* And permanently map it in */
ahd_dmamap_load(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap,
ahd->shared_data_map.vaddr, driver_data_size,
ahd_dmamap_cb, &ahd->shared_data_map.physaddr,
/*flags*/0);
ahd->qoutfifo = (struct ahd_completion *)ahd->shared_data_map.vaddr;
next_vaddr = (uint8_t *)&ahd->qoutfifo[AHD_QOUT_SIZE];
next_baddr = ahd->shared_data_map.physaddr
+ AHD_QOUT_SIZE*sizeof(struct ahd_completion);
if ((ahd->features & AHD_TARGETMODE) != 0) {
ahd->targetcmds = (struct target_cmd *)next_vaddr;
next_vaddr += AHD_TMODE_CMDS * sizeof(struct target_cmd);
next_baddr += AHD_TMODE_CMDS * sizeof(struct target_cmd);
}
if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) {
ahd->overrun_buf = next_vaddr;
next_vaddr += PKT_OVERRUN_BUFSIZE;
next_baddr += PKT_OVERRUN_BUFSIZE;
}
/*
* We need one SCB to serve as the "next SCB". Since the
* tag identifier in this SCB will never be used, there is
* no point in using a valid HSCB tag from an SCB pulled from
* the standard free pool. So, we allocate this "sentinel"
* specially from the DMA safe memory chunk used for the QOUTFIFO.
*/
ahd->next_queued_hscb = (struct hardware_scb *)next_vaddr;
ahd->next_queued_hscb_map = &ahd->shared_data_map;
ahd->next_queued_hscb->hscb_busaddr = ahd_htole32(next_baddr);
ahd->init_level++;
/* Allocate SCB data now that buffer_dmat is initialized */
if (ahd_init_scbdata(ahd) != 0)
return (ENOMEM);
if ((ahd->flags & AHD_INITIATORROLE) == 0)
ahd->flags &= ~AHD_RESET_BUS_A;
/*
* Before committing these settings to the chip, give
* the OSM one last chance to modify our configuration.
*/
ahd_platform_init(ahd);
/* Bring up the chip. */
ahd_chip_init(ahd);
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
if ((ahd->flags & AHD_CURRENT_SENSING) == 0)
goto init_done;
/*
* Verify termination based on current draw and
* warn user if the bus is over/under terminated.
*/
error = ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL,
CURSENSE_ENB);
if (error != 0) {
printk("%s: current sensing timeout 1\n", ahd_name(ahd));
goto init_done;
}
for (i = 20, fstat = FLX_FSTAT_BUSY;
(fstat & FLX_FSTAT_BUSY) != 0 && i; i--) {
error = ahd_read_flexport(ahd, FLXADDR_FLEXSTAT, &fstat);
if (error != 0) {
printk("%s: current sensing timeout 2\n",
ahd_name(ahd));
goto init_done;
}
}
if (i == 0) {
printk("%s: Timedout during current-sensing test\n",
ahd_name(ahd));
goto init_done;
}
/* Latch Current Sensing status. */
error = ahd_read_flexport(ahd, FLXADDR_CURRENT_STAT, ¤t_sensing);
if (error != 0) {
printk("%s: current sensing timeout 3\n", ahd_name(ahd));
goto init_done;
}
/* Diable current sensing. */
ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, 0);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_TERMCTL) != 0) {
printk("%s: current_sensing == 0x%x\n",
ahd_name(ahd), current_sensing);
}
#endif
warn_user = 0;
for (i = 0; i < 4; i++, current_sensing >>= FLX_CSTAT_SHIFT) {
u_int term_stat;
term_stat = (current_sensing & FLX_CSTAT_MASK);
switch (term_stat) {
case FLX_CSTAT_OVER:
case FLX_CSTAT_UNDER:
warn_user++;
case FLX_CSTAT_INVALID:
case FLX_CSTAT_OKAY:
if (warn_user == 0 && bootverbose == 0)
break;
printk("%s: %s Channel %s\n", ahd_name(ahd),
channel_strings[i], termstat_strings[term_stat]);
break;
}
}
if (warn_user) {
printk("%s: WARNING. Termination is not configured correctly.\n"
"%s: WARNING. SCSI bus operations may FAIL.\n",
ahd_name(ahd), ahd_name(ahd));
}
init_done:
ahd_restart(ahd);
ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US);
return (0);
}
/*
* (Re)initialize chip state after a chip reset.
*/
static void
ahd_chip_init(struct ahd_softc *ahd)
{
uint32_t busaddr;
u_int sxfrctl1;
u_int scsiseq_template;
u_int wait;
u_int i;
u_int target;
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
/*
* Take the LED out of diagnostic mode
*/
ahd_outb(ahd, SBLKCTL, ahd_inb(ahd, SBLKCTL) & ~(DIAGLEDEN|DIAGLEDON));
/*
* Return HS_MAILBOX to its default value.
*/
ahd->hs_mailbox = 0;
ahd_outb(ahd, HS_MAILBOX, 0);
/* Set the SCSI Id, SXFRCTL0, SXFRCTL1, and SIMODE1. */
ahd_outb(ahd, IOWNID, ahd->our_id);
ahd_outb(ahd, TOWNID, ahd->our_id);
sxfrctl1 = (ahd->flags & AHD_TERM_ENB_A) != 0 ? STPWEN : 0;
sxfrctl1 |= (ahd->flags & AHD_SPCHK_ENB_A) != 0 ? ENSPCHK : 0;
if ((ahd->bugs & AHD_LONG_SETIMO_BUG)
&& (ahd->seltime != STIMESEL_MIN)) {
/*
* The selection timer duration is twice as long
* as it should be. Halve it by adding "1" to
* the user specified setting.
*/
sxfrctl1 |= ahd->seltime + STIMESEL_BUG_ADJ;
} else {
sxfrctl1 |= ahd->seltime;
}
ahd_outb(ahd, SXFRCTL0, DFON);
ahd_outb(ahd, SXFRCTL1, sxfrctl1|ahd->seltime|ENSTIMER|ACTNEGEN);
ahd_outb(ahd, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
/*
* Now that termination is set, wait for up
* to 500ms for our transceivers to settle. If
* the adapter does not have a cable attached,
* the transceivers may never settle, so don't
* complain if we fail here.
*/
for (wait = 10000;
(ahd_inb(ahd, SBLKCTL) & (ENAB40|ENAB20)) == 0 && wait;
wait--)
ahd_delay(100);
/* Clear any false bus resets due to the transceivers settling */
ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
/* Initialize mode specific S/G state. */
for (i = 0; i < 2; i++) {
ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
ahd_outb(ahd, SG_STATE, 0);
ahd_outb(ahd, CLRSEQINTSRC, 0xFF);
ahd_outb(ahd, SEQIMODE,
ENSAVEPTRS|ENCFG4DATA|ENCFG4ISTAT
|ENCFG4TSTAT|ENCFG4ICMD|ENCFG4TCMD);
}
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
ahd_outb(ahd, DSCOMMAND0, ahd_inb(ahd, DSCOMMAND0)|MPARCKEN|CACHETHEN);
ahd_outb(ahd, DFF_THRSH, RD_DFTHRSH_75|WR_DFTHRSH_75);
ahd_outb(ahd, SIMODE0, ENIOERR|ENOVERRUN);
ahd_outb(ahd, SIMODE3, ENNTRAMPERR|ENOSRAMPERR);
if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
ahd_outb(ahd, OPTIONMODE, AUTOACKEN|AUTO_MSGOUT_DE);
} else {
ahd_outb(ahd, OPTIONMODE, AUTOACKEN|BUSFREEREV|AUTO_MSGOUT_DE);
}
ahd_outb(ahd, SCSCHKN, CURRFIFODEF|WIDERESEN|SHVALIDSTDIS);
if ((ahd->chip & AHD_BUS_MASK) == AHD_PCIX)
/*
* Do not issue a target abort when a split completion
* error occurs. Let our PCIX interrupt handler deal
* with it instead. H2A4 Razor #625
*/
ahd_outb(ahd, PCIXCTL, ahd_inb(ahd, PCIXCTL) | SPLTSTADIS);
if ((ahd->bugs & AHD_LQOOVERRUN_BUG) != 0)
ahd_outb(ahd, LQOSCSCTL, LQONOCHKOVER);
/*
* Tweak IOCELL settings.
*/
if ((ahd->flags & AHD_HP_BOARD) != 0) {
for (i = 0; i < NUMDSPS; i++) {
ahd_outb(ahd, DSPSELECT, i);
ahd_outb(ahd, WRTBIASCTL, WRTBIASCTL_HP_DEFAULT);
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printk("%s: WRTBIASCTL now 0x%x\n", ahd_name(ahd),
WRTBIASCTL_HP_DEFAULT);
#endif
}
ahd_setup_iocell_workaround(ahd);
/*
* Enable LQI Manager interrupts.
*/
ahd_outb(ahd, LQIMODE1, ENLQIPHASE_LQ|ENLQIPHASE_NLQ|ENLIQABORT
| ENLQICRCI_LQ|ENLQICRCI_NLQ|ENLQIBADLQI
| ENLQIOVERI_LQ|ENLQIOVERI_NLQ);
ahd_outb(ahd, LQOMODE0, ENLQOATNLQ|ENLQOATNPKT|ENLQOTCRC);
/*
* We choose to have the sequencer catch LQOPHCHGINPKT errors
* manually for the command phase at the start of a packetized
* selection case. ENLQOBUSFREE should be made redundant by
* the BUSFREE interrupt, but it seems that some LQOBUSFREE
* events fail to assert the BUSFREE interrupt so we must
* also enable LQOBUSFREE interrupts.
*/
ahd_outb(ahd, LQOMODE1, ENLQOBUSFREE);
/*
* Setup sequencer interrupt handlers.
*/
ahd_outw(ahd, INTVEC1_ADDR, ahd_resolve_seqaddr(ahd, LABEL_seq_isr));
ahd_outw(ahd, INTVEC2_ADDR, ahd_resolve_seqaddr(ahd, LABEL_timer_isr));
/*
* Setup SCB Offset registers.
*/
if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb,
pkt_long_lun));
} else {
ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb, lun));
}
ahd_outb(ahd, CMDLENPTR, offsetof(struct hardware_scb, cdb_len));
ahd_outb(ahd, ATTRPTR, offsetof(struct hardware_scb, task_attribute));
ahd_outb(ahd, FLAGPTR, offsetof(struct hardware_scb, task_management));
ahd_outb(ahd, CMDPTR, offsetof(struct hardware_scb,
shared_data.idata.cdb));
ahd_outb(ahd, QNEXTPTR,
offsetof(struct hardware_scb, next_hscb_busaddr));
ahd_outb(ahd, ABRTBITPTR, MK_MESSAGE_BIT_OFFSET);
ahd_outb(ahd, ABRTBYTEPTR, offsetof(struct hardware_scb, control));
if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
ahd_outb(ahd, LUNLEN,
sizeof(ahd->next_queued_hscb->pkt_long_lun) - 1);
} else {
ahd_outb(ahd, LUNLEN, LUNLEN_SINGLE_LEVEL_LUN);
}
ahd_outb(ahd, CDBLIMIT, SCB_CDB_LEN_PTR - 1);
ahd_outb(ahd, MAXCMD, 0xFF);
ahd_outb(ahd, SCBAUTOPTR,
AUSCBPTR_EN | offsetof(struct hardware_scb, tag));
/* We haven't been enabled for target mode yet. */
ahd_outb(ahd, MULTARGID, 0);
ahd_outb(ahd, MULTARGID + 1, 0);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
/* Initialize the negotiation table. */
if ((ahd->features & AHD_NEW_IOCELL_OPTS) == 0) {
/*
* Clear the spare bytes in the neg table to avoid
* spurious parity errors.
*/
for (target = 0; target < AHD_NUM_TARGETS; target++) {
ahd_outb(ahd, NEGOADDR, target);
ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PER_DEV0);
for (i = 0; i < AHD_NUM_PER_DEV_ANNEXCOLS; i++)
ahd_outb(ahd, ANNEXDAT, 0);
}
}
for (target = 0; target < AHD_NUM_TARGETS; target++) {
struct ahd_devinfo devinfo;
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
target, &tstate);
ahd_compile_devinfo(&devinfo, ahd->our_id,
target, CAM_LUN_WILDCARD,
'A', ROLE_INITIATOR);
ahd_update_neg_table(ahd, &devinfo, &tinfo->curr);
}
ahd_outb(ahd, CLRSINT3, NTRAMPERR|OSRAMPERR);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
#ifdef NEEDS_MORE_TESTING
/*
* Always enable abort on incoming L_Qs if this feature is
* supported. We use this to catch invalid SCB references.
*/
if ((ahd->bugs & AHD_ABORT_LQI_BUG) == 0)
ahd_outb(ahd, LQCTL1, ABORTPENDING);
else
#endif
ahd_outb(ahd, LQCTL1, 0);
/* All of our queues are empty */
ahd->qoutfifonext = 0;
ahd->qoutfifonext_valid_tag = QOUTFIFO_ENTRY_VALID;
ahd_outb(ahd, QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID);
for (i = 0; i < AHD_QOUT_SIZE; i++)
ahd->qoutfifo[i].valid_tag = 0;
ahd_sync_qoutfifo(ahd, BUS_DMASYNC_PREREAD);
ahd->qinfifonext = 0;
for (i = 0; i < AHD_QIN_SIZE; i++)
ahd->qinfifo[i] = SCB_LIST_NULL;
if ((ahd->features & AHD_TARGETMODE) != 0) {
/* All target command blocks start out invalid. */
for (i = 0; i < AHD_TMODE_CMDS; i++)
ahd->targetcmds[i].cmd_valid = 0;
ahd_sync_tqinfifo(ahd, BUS_DMASYNC_PREREAD);
ahd->tqinfifonext = 1;
ahd_outb(ahd, KERNEL_TQINPOS, ahd->tqinfifonext - 1);
ahd_outb(ahd, TQINPOS, ahd->tqinfifonext);
}
/* Initialize Scratch Ram. */
ahd_outb(ahd, SEQ_FLAGS, 0);
ahd_outb(ahd, SEQ_FLAGS2, 0);
/* We don't have any waiting selections */
ahd_outw(ahd, WAITING_TID_HEAD, SCB_LIST_NULL);
ahd_outw(ahd, WAITING_TID_TAIL, SCB_LIST_NULL);
ahd_outw(ahd, MK_MESSAGE_SCB, SCB_LIST_NULL);
ahd_outw(ahd, MK_MESSAGE_SCSIID, 0xFF);
for (i = 0; i < AHD_NUM_TARGETS; i++)
ahd_outw(ahd, WAITING_SCB_TAILS + (2 * i), SCB_LIST_NULL);
/*
* Nobody is waiting to be DMAed into the QOUTFIFO.
*/
ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL);
ahd_outw(ahd, COMPLETE_SCB_DMAINPROG_HEAD, SCB_LIST_NULL);
ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL);
ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, SCB_LIST_NULL);
ahd_outw(ahd, COMPLETE_ON_QFREEZE_HEAD, SCB_LIST_NULL);
/*
* The Freeze Count is 0.
*/
ahd->qfreeze_cnt = 0;
ahd_outw(ahd, QFREEZE_COUNT, 0);
ahd_outw(ahd, KERNEL_QFREEZE_COUNT, 0);
/*
* Tell the sequencer where it can find our arrays in memory.
*/
busaddr = ahd->shared_data_map.physaddr;
ahd_outl(ahd, SHARED_DATA_ADDR, busaddr);
ahd_outl(ahd, QOUTFIFO_NEXT_ADDR, busaddr);
/*
* Setup the allowed SCSI Sequences based on operational mode.
* If we are a target, we'll enable select in operations once
* we've had a lun enabled.
*/
scsiseq_template = ENAUTOATNP;
if ((ahd->flags & AHD_INITIATORROLE) != 0)
scsiseq_template |= ENRSELI;
ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq_template);
/* There are no busy SCBs yet. */
for (target = 0; target < AHD_NUM_TARGETS; target++) {
int lun;
for (lun = 0; lun < AHD_NUM_LUNS_NONPKT; lun++)
ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(target, 'A', lun));
}
/*
* Initialize the group code to command length table.
* Vendor Unique codes are set to 0 so we only capture
* the first byte of the cdb. These can be overridden
* when target mode is enabled.
*/
ahd_outb(ahd, CMDSIZE_TABLE, 5);
ahd_outb(ahd, CMDSIZE_TABLE + 1, 9);
ahd_outb(ahd, CMDSIZE_TABLE + 2, 9);
ahd_outb(ahd, CMDSIZE_TABLE + 3, 0);
ahd_outb(ahd, CMDSIZE_TABLE + 4, 15);
ahd_outb(ahd, CMDSIZE_TABLE + 5, 11);
ahd_outb(ahd, CMDSIZE_TABLE + 6, 0);
ahd_outb(ahd, CMDSIZE_TABLE + 7, 0);
/* Tell the sequencer of our initial queue positions */
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
ahd_outb(ahd, QOFF_CTLSTA, SCB_QSIZE_512);
ahd->qinfifonext = 0;
ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
ahd_set_hescb_qoff(ahd, 0);
ahd_set_snscb_qoff(ahd, 0);
ahd_set_sescb_qoff(ahd, 0);
ahd_set_sdscb_qoff(ahd, 0);
/*
* Tell the sequencer which SCB will be the next one it receives.
*/
busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr);
ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr);
/*
* Default to coalescing disabled.
*/
ahd_outw(ahd, INT_COALESCING_CMDCOUNT, 0);
ahd_outw(ahd, CMDS_PENDING, 0);
ahd_update_coalescing_values(ahd, ahd->int_coalescing_timer,
ahd->int_coalescing_maxcmds,
ahd->int_coalescing_mincmds);
ahd_enable_coalescing(ahd, FALSE);
ahd_loadseq(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
if (ahd->features & AHD_AIC79XXB_SLOWCRC) {
u_int negodat3 = ahd_inb(ahd, NEGCONOPTS);
negodat3 |= ENSLOWCRC;
ahd_outb(ahd, NEGCONOPTS, negodat3);
negodat3 = ahd_inb(ahd, NEGCONOPTS);
if (!(negodat3 & ENSLOWCRC))
printk("aic79xx: failed to set the SLOWCRC bit\n");
else
printk("aic79xx: SLOWCRC bit set\n");
}
}
/*
* Setup default device and controller settings.
* This should only be called if our probe has
* determined that no configuration data is available.
*/
int
ahd_default_config(struct ahd_softc *ahd)
{
int targ;
ahd->our_id = 7;
/*
* Allocate a tstate to house information for our
* initiator presence on the bus as well as the user
* data for any target mode initiator.
*/
if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) {
printk("%s: unable to allocate ahd_tmode_tstate. "
"Failing attach\n", ahd_name(ahd));
return (ENOMEM);
}
for (targ = 0; targ < AHD_NUM_TARGETS; targ++) {
struct ahd_devinfo devinfo;
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
uint16_t target_mask;
tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
targ, &tstate);
/*
* We support SPC2 and SPI4.
*/
tinfo->user.protocol_version = 4;
tinfo->user.transport_version = 4;
target_mask = 0x01 << targ;
ahd->user_discenable |= target_mask;
tstate->discenable |= target_mask;
ahd->user_tagenable |= target_mask;
#ifdef AHD_FORCE_160
tinfo->user.period = AHD_SYNCRATE_DT;
#else
tinfo->user.period = AHD_SYNCRATE_160;
#endif
tinfo->user.offset = MAX_OFFSET;
tinfo->user.ppr_options = MSG_EXT_PPR_RD_STRM
| MSG_EXT_PPR_WR_FLOW
| MSG_EXT_PPR_HOLD_MCS
| MSG_EXT_PPR_IU_REQ
| MSG_EXT_PPR_QAS_REQ
| MSG_EXT_PPR_DT_REQ;
if ((ahd->features & AHD_RTI) != 0)
tinfo->user.ppr_options |= MSG_EXT_PPR_RTI;
tinfo->user.width = MSG_EXT_WDTR_BUS_16_BIT;
/*
* Start out Async/Narrow/Untagged and with
* conservative protocol support.
*/
tinfo->goal.protocol_version = 2;
tinfo->goal.transport_version = 2;
tinfo->curr.protocol_version = 2;
tinfo->curr.transport_version = 2;
ahd_compile_devinfo(&devinfo, ahd->our_id,
targ, CAM_LUN_WILDCARD,
'A', ROLE_INITIATOR);
tstate->tagenable &= ~target_mask;
ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR|AHD_TRANS_GOAL, /*paused*/TRUE);
ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
/*ppr_options*/0, AHD_TRANS_CUR|AHD_TRANS_GOAL,
/*paused*/TRUE);
}
return (0);
}
/*
* Parse device configuration information.
*/
int
ahd_parse_cfgdata(struct ahd_softc *ahd, struct seeprom_config *sc)
{
int targ;
int max_targ;
max_targ = sc->max_targets & CFMAXTARG;
ahd->our_id = sc->brtime_id & CFSCSIID;
/*
* Allocate a tstate to house information for our
* initiator presence on the bus as well as the user
* data for any target mode initiator.
*/
if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) {
printk("%s: unable to allocate ahd_tmode_tstate. "
"Failing attach\n", ahd_name(ahd));
return (ENOMEM);
}
for (targ = 0; targ < max_targ; targ++) {
struct ahd_devinfo devinfo;
struct ahd_initiator_tinfo *tinfo;
struct ahd_transinfo *user_tinfo;
struct ahd_tmode_tstate *tstate;
uint16_t target_mask;
tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
targ, &tstate);
user_tinfo = &tinfo->user;
/*
* We support SPC2 and SPI4.
*/
tinfo->user.protocol_version = 4;
tinfo->user.transport_version = 4;
target_mask = 0x01 << targ;
ahd->user_discenable &= ~target_mask;
tstate->discenable &= ~target_mask;
ahd->user_tagenable &= ~target_mask;
if (sc->device_flags[targ] & CFDISC) {
tstate->discenable |= target_mask;
ahd->user_discenable |= target_mask;
ahd->user_tagenable |= target_mask;
} else {
/*
* Cannot be packetized without disconnection.
*/
sc->device_flags[targ] &= ~CFPACKETIZED;
}
user_tinfo->ppr_options = 0;
user_tinfo->period = (sc->device_flags[targ] & CFXFER);
if (user_tinfo->period < CFXFER_ASYNC) {
if (user_tinfo->period <= AHD_PERIOD_10MHz)
user_tinfo->ppr_options |= MSG_EXT_PPR_DT_REQ;
user_tinfo->offset = MAX_OFFSET;
} else {
user_tinfo->offset = 0;
user_tinfo->period = AHD_ASYNC_XFER_PERIOD;
}
#ifdef AHD_FORCE_160
if (user_tinfo->period <= AHD_SYNCRATE_160)
user_tinfo->period = AHD_SYNCRATE_DT;
#endif
if ((sc->device_flags[targ] & CFPACKETIZED) != 0) {
user_tinfo->ppr_options |= MSG_EXT_PPR_RD_STRM
| MSG_EXT_PPR_WR_FLOW
| MSG_EXT_PPR_HOLD_MCS
| MSG_EXT_PPR_IU_REQ;
if ((ahd->features & AHD_RTI) != 0)
user_tinfo->ppr_options |= MSG_EXT_PPR_RTI;
}
if ((sc->device_flags[targ] & CFQAS) != 0)
user_tinfo->ppr_options |= MSG_EXT_PPR_QAS_REQ;
if ((sc->device_flags[targ] & CFWIDEB) != 0)
user_tinfo->width = MSG_EXT_WDTR_BUS_16_BIT;
else
user_tinfo->width = MSG_EXT_WDTR_BUS_8_BIT;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printk("(%d): %x:%x:%x:%x\n", targ, user_tinfo->width,
user_tinfo->period, user_tinfo->offset,
user_tinfo->ppr_options);
#endif
/*
* Start out Async/Narrow/Untagged and with
* conservative protocol support.
*/
tstate->tagenable &= ~target_mask;
tinfo->goal.protocol_version = 2;
tinfo->goal.transport_version = 2;
tinfo->curr.protocol_version = 2;
tinfo->curr.transport_version = 2;
ahd_compile_devinfo(&devinfo, ahd->our_id,
targ, CAM_LUN_WILDCARD,
'A', ROLE_INITIATOR);
ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR|AHD_TRANS_GOAL, /*paused*/TRUE);
ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
/*ppr_options*/0, AHD_TRANS_CUR|AHD_TRANS_GOAL,
/*paused*/TRUE);
}
ahd->flags &= ~AHD_SPCHK_ENB_A;
if (sc->bios_control & CFSPARITY)
ahd->flags |= AHD_SPCHK_ENB_A;
ahd->flags &= ~AHD_RESET_BUS_A;
if (sc->bios_control & CFRESETB)
ahd->flags |= AHD_RESET_BUS_A;
ahd->flags &= ~AHD_EXTENDED_TRANS_A;
if (sc->bios_control & CFEXTEND)
ahd->flags |= AHD_EXTENDED_TRANS_A;
ahd->flags &= ~AHD_BIOS_ENABLED;
if ((sc->bios_control & CFBIOSSTATE) == CFBS_ENABLED)
ahd->flags |= AHD_BIOS_ENABLED;
ahd->flags &= ~AHD_STPWLEVEL_A;
if ((sc->adapter_control & CFSTPWLEVEL) != 0)
ahd->flags |= AHD_STPWLEVEL_A;
return (0);
}
/*
* Parse device configuration information.
*/
int
ahd_parse_vpddata(struct ahd_softc *ahd, struct vpd_config *vpd)
{
int error;
error = ahd_verify_vpd_cksum(vpd);
if (error == 0)
return (EINVAL);
if ((vpd->bios_flags & VPDBOOTHOST) != 0)
ahd->flags |= AHD_BOOT_CHANNEL;
return (0);
}
void
ahd_intr_enable(struct ahd_softc *ahd, int enable)
{
u_int hcntrl;
hcntrl = ahd_inb(ahd, HCNTRL);
hcntrl &= ~INTEN;
ahd->pause &= ~INTEN;
ahd->unpause &= ~INTEN;
if (enable) {
hcntrl |= INTEN;
ahd->pause |= INTEN;
ahd->unpause |= INTEN;
}
ahd_outb(ahd, HCNTRL, hcntrl);
}
static void
ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
u_int mincmds)
{
if (timer > AHD_TIMER_MAX_US)
timer = AHD_TIMER_MAX_US;
ahd->int_coalescing_timer = timer;
if (maxcmds > AHD_INT_COALESCING_MAXCMDS_MAX)
maxcmds = AHD_INT_COALESCING_MAXCMDS_MAX;
if (mincmds > AHD_INT_COALESCING_MINCMDS_MAX)
mincmds = AHD_INT_COALESCING_MINCMDS_MAX;
ahd->int_coalescing_maxcmds = maxcmds;
ahd_outw(ahd, INT_COALESCING_TIMER, timer / AHD_TIMER_US_PER_TICK);
ahd_outb(ahd, INT_COALESCING_MAXCMDS, -maxcmds);
ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds);
}
static void
ahd_enable_coalescing(struct ahd_softc *ahd, int enable)
{
ahd->hs_mailbox &= ~ENINT_COALESCE;
if (enable)
ahd->hs_mailbox |= ENINT_COALESCE;
ahd_outb(ahd, HS_MAILBOX, ahd->hs_mailbox);
ahd_flush_device_writes(ahd);
ahd_run_qoutfifo(ahd);
}
/*
* Ensure that the card is paused in a location
* outside of all critical sections and that all
* pending work is completed prior to returning.
* This routine should only be called from outside
* an interrupt context.
*/
void
ahd_pause_and_flushwork(struct ahd_softc *ahd)
{
u_int intstat;
u_int maxloops;
maxloops = 1000;
ahd->flags |= AHD_ALL_INTERRUPTS;
ahd_pause(ahd);
/*
* Freeze the outgoing selections. We do this only
* until we are safely paused without further selections
* pending.
*/
ahd->qfreeze_cnt--;
ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt);
ahd_outb(ahd, SEQ_FLAGS2, ahd_inb(ahd, SEQ_FLAGS2) | SELECTOUT_QFROZEN);
do {
ahd_unpause(ahd);
/*
* Give the sequencer some time to service
* any active selections.
*/
ahd_delay(500);
ahd_intr(ahd);
ahd_pause(ahd);
intstat = ahd_inb(ahd, INTSTAT);
if ((intstat & INT_PEND) == 0) {
ahd_clear_critical_section(ahd);
intstat = ahd_inb(ahd, INTSTAT);
}
} while (--maxloops
&& (intstat != 0xFF || (ahd->features & AHD_REMOVABLE) == 0)
&& ((intstat & INT_PEND) != 0
|| (ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0
|| (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0));
if (maxloops == 0) {
printk("Infinite interrupt loop, INTSTAT = %x",
ahd_inb(ahd, INTSTAT));
}
ahd->qfreeze_cnt++;
ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt);
ahd_flush_qoutfifo(ahd);
ahd->flags &= ~AHD_ALL_INTERRUPTS;
}
#ifdef CONFIG_PM
int
ahd_suspend(struct ahd_softc *ahd)
{
ahd_pause_and_flushwork(ahd);
if (LIST_FIRST(&ahd->pending_scbs) != NULL) {
ahd_unpause(ahd);
return (EBUSY);
}
ahd_shutdown(ahd);
return (0);
}
void
ahd_resume(struct ahd_softc *ahd)
{
ahd_reset(ahd, /*reinit*/TRUE);
ahd_intr_enable(ahd, TRUE);
ahd_restart(ahd);
}
#endif
/************************** Busy Target Table *********************************/
/*
* Set SCBPTR to the SCB that contains the busy
* table entry for TCL. Return the offset into
* the SCB that contains the entry for TCL.
* saved_scbid is dereferenced and set to the
* scbid that should be restored once manipualtion
* of the TCL entry is complete.
*/
static inline u_int
ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl)
{
/*
* Index to the SCB that contains the busy entry.
*/
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
*saved_scbid = ahd_get_scbptr(ahd);
ahd_set_scbptr(ahd, TCL_LUN(tcl)
| ((TCL_TARGET_OFFSET(tcl) & 0xC) << 4));
/*
* And now calculate the SCB offset to the entry.
* Each entry is 2 bytes wide, hence the
* multiplication by 2.
*/
return (((TCL_TARGET_OFFSET(tcl) & 0x3) << 1) + SCB_DISCONNECTED_LISTS);
}
/*
* Return the untagged transaction id for a given target/channel lun.
*/
static u_int
ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
{
u_int scbid;
u_int scb_offset;
u_int saved_scbptr;
scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl);
scbid = ahd_inw_scbram(ahd, scb_offset);
ahd_set_scbptr(ahd, saved_scbptr);
return (scbid);
}
static void
ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid)
{
u_int scb_offset;
u_int saved_scbptr;
scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl);
ahd_outw(ahd, scb_offset, scbid);
ahd_set_scbptr(ahd, saved_scbptr);
}
/************************** SCB and SCB queue management **********************/
static int
ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target,
char channel, int lun, u_int tag, role_t role)
{
int targ = SCB_GET_TARGET(ahd, scb);
char chan = SCB_GET_CHANNEL(ahd, scb);
int slun = SCB_GET_LUN(scb);
int match;
match = ((chan == channel) || (channel == ALL_CHANNELS));
if (match != 0)
match = ((targ == target) || (target == CAM_TARGET_WILDCARD));
if (match != 0)
match = ((lun == slun) || (lun == CAM_LUN_WILDCARD));
if (match != 0) {
#ifdef AHD_TARGET_MODE
int group;
group = XPT_FC_GROUP(scb->io_ctx->ccb_h.func_code);
if (role == ROLE_INITIATOR) {
match = (group != XPT_FC_GROUP_TMODE)
&& ((tag == SCB_GET_TAG(scb))
|| (tag == SCB_LIST_NULL));
} else if (role == ROLE_TARGET) {
match = (group == XPT_FC_GROUP_TMODE)
&& ((tag == scb->io_ctx->csio.tag_id)
|| (tag == SCB_LIST_NULL));
}
#else /* !AHD_TARGET_MODE */
match = ((tag == SCB_GET_TAG(scb)) || (tag == SCB_LIST_NULL));
#endif /* AHD_TARGET_MODE */
}
return match;
}
static void
ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
{
int target;
char channel;
int lun;
target = SCB_GET_TARGET(ahd, scb);
lun = SCB_GET_LUN(scb);
channel = SCB_GET_CHANNEL(ahd, scb);
ahd_search_qinfifo(ahd, target, channel, lun,
/*tag*/SCB_LIST_NULL, ROLE_UNKNOWN,
CAM_REQUEUE_REQ, SEARCH_COMPLETE);
ahd_platform_freeze_devq(ahd, scb);
}
void
ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, struct scb *scb)
{
struct scb *prev_scb;
ahd_mode_state saved_modes;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
prev_scb = NULL;
if (ahd_qinfifo_count(ahd) != 0) {
u_int prev_tag;
u_int prev_pos;
prev_pos = AHD_QIN_WRAP(ahd->qinfifonext - 1);
prev_tag = ahd->qinfifo[prev_pos];
prev_scb = ahd_lookup_scb(ahd, prev_tag);
}
ahd_qinfifo_requeue(ahd, prev_scb, scb);
ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
ahd_restore_modes(ahd, saved_modes);
}
static void
ahd_qinfifo_requeue(struct ahd_softc *ahd, struct scb *prev_scb,
struct scb *scb)
{
if (prev_scb == NULL) {
uint32_t busaddr;
busaddr = ahd_le32toh(scb->hscb->hscb_busaddr);
ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr);
} else {
prev_scb->hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
ahd_sync_scb(ahd, prev_scb,
BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
}
ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);
ahd->qinfifonext++;
scb->hscb->next_hscb_busaddr = ahd->next_queued_hscb->hscb_busaddr;
ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
}
static int
ahd_qinfifo_count(struct ahd_softc *ahd)
{
u_int qinpos;
u_int wrap_qinpos;
u_int wrap_qinfifonext;
AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
qinpos = ahd_get_snscb_qoff(ahd);
wrap_qinpos = AHD_QIN_WRAP(qinpos);
wrap_qinfifonext = AHD_QIN_WRAP(ahd->qinfifonext);
if (wrap_qinfifonext >= wrap_qinpos)
return (wrap_qinfifonext - wrap_qinpos);
else
return (wrap_qinfifonext
+ ARRAY_SIZE(ahd->qinfifo) - wrap_qinpos);
}
static void
ahd_reset_cmds_pending(struct ahd_softc *ahd)
{
struct scb *scb;
ahd_mode_state saved_modes;
u_int pending_cmds;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
/*
* Don't count any commands as outstanding that the
* sequencer has already marked for completion.
*/
ahd_flush_qoutfifo(ahd);
pending_cmds = 0;
LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
pending_cmds++;
}
ahd_outw(ahd, CMDS_PENDING, pending_cmds - ahd_qinfifo_count(ahd));
ahd_restore_modes(ahd, saved_modes);
ahd->flags &= ~AHD_UPDATE_PEND_CMDS;
}
static void
ahd_done_with_status(struct ahd_softc *ahd, struct scb *scb, uint32_t status)
{
cam_status ostat;
cam_status cstat;
ostat = ahd_get_transaction_status(scb);
if (ostat == CAM_REQ_INPROG)
ahd_set_transaction_status(scb, status);
cstat = ahd_get_transaction_status(scb);
if (cstat != CAM_REQ_CMP)
ahd_freeze_scb(scb);
ahd_done(ahd, scb);
}
int
ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
int lun, u_int tag, role_t role, uint32_t status,
ahd_search_action action)
{
struct scb *scb;
struct scb *mk_msg_scb;
struct scb *prev_scb;
ahd_mode_state saved_modes;
u_int qinstart;
u_int qinpos;
u_int qintail;
u_int tid_next;
u_int tid_prev;
u_int scbid;
u_int seq_flags2;
u_int savedscbptr;
uint32_t busaddr;
int found;
int targets;
/* Must be in CCHAN mode */
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
/*
* Halt any pending SCB DMA. The sequencer will reinitiate
* this dma if the qinfifo is not empty once we unpause.
*/
if ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN|CCSCBDIR))
== (CCARREN|CCSCBEN|CCSCBDIR)) {
ahd_outb(ahd, CCSCBCTL,
ahd_inb(ahd, CCSCBCTL) & ~(CCARREN|CCSCBEN));
while ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN)) != 0)
;
}
/* Determine sequencer's position in the qinfifo. */
qintail = AHD_QIN_WRAP(ahd->qinfifonext);
qinstart = ahd_get_snscb_qoff(ahd);
qinpos = AHD_QIN_WRAP(qinstart);
found = 0;
prev_scb = NULL;
if (action == SEARCH_PRINT) {
printk("qinstart = %d qinfifonext = %d\nQINFIFO:",
qinstart, ahd->qinfifonext);
}
/*
* Start with an empty queue. Entries that are not chosen
* for removal will be re-added to the queue as we go.
*/
ahd->qinfifonext = qinstart;
busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr);
ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr);
while (qinpos != qintail) {
scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]);
if (scb == NULL) {
printk("qinpos = %d, SCB index = %d\n",
qinpos, ahd->qinfifo[qinpos]);
panic("Loop 1\n");
}
if (ahd_match_scb(ahd, scb, target, channel, lun, tag, role)) {
/*
* We found an scb that needs to be acted on.
*/
found++;
switch (action) {
case SEARCH_COMPLETE:
if ((scb->flags & SCB_ACTIVE) == 0)
printk("Inactive SCB in qinfifo\n");
ahd_done_with_status(ahd, scb, status);
/* FALLTHROUGH */
case SEARCH_REMOVE:
break;
case SEARCH_PRINT:
printk(" 0x%x", ahd->qinfifo[qinpos]);
/* FALLTHROUGH */
case SEARCH_COUNT:
ahd_qinfifo_requeue(ahd, prev_scb, scb);
prev_scb = scb;
break;
}
} else {
ahd_qinfifo_requeue(ahd, prev_scb, scb);
prev_scb = scb;
}
qinpos = AHD_QIN_WRAP(qinpos+1);
}
ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
if (action == SEARCH_PRINT)
printk("\nWAITING_TID_QUEUES:\n");
/*
* Search waiting for selection lists. We traverse the
* list of "their ids" waiting for selection and, if
* appropriate, traverse the SCBs of each "their id"
* looking for matches.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
seq_flags2 = ahd_inb(ahd, SEQ_FLAGS2);
if ((seq_flags2 & PENDING_MK_MESSAGE) != 0) {
scbid = ahd_inw(ahd, MK_MESSAGE_SCB);
mk_msg_scb = ahd_lookup_scb(ahd, scbid);
} else
mk_msg_scb = NULL;
savedscbptr = ahd_get_scbptr(ahd);
tid_next = ahd_inw(ahd, WAITING_TID_HEAD);
tid_prev = SCB_LIST_NULL;
targets = 0;
for (scbid = tid_next; !SCBID_IS_NULL(scbid); scbid = tid_next) {
u_int tid_head;
u_int tid_tail;
targets++;
if (targets > AHD_NUM_TARGETS)
panic("TID LIST LOOP");
if (scbid >= ahd->scb_data.numscbs) {
printk("%s: Waiting TID List inconsistency. "
"SCB index == 0x%x, yet numscbs == 0x%x.",
ahd_name(ahd), scbid, ahd->scb_data.numscbs);
ahd_dump_card_state(ahd);
panic("for safety");
}
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printk("%s: SCB = 0x%x Not Active!\n",
ahd_name(ahd), scbid);
panic("Waiting TID List traversal\n");
}
ahd_set_scbptr(ahd, scbid);
tid_next = ahd_inw_scbram(ahd, SCB_NEXT2);
if (ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD,
SCB_LIST_NULL, ROLE_UNKNOWN) == 0) {
tid_prev = scbid;
continue;
}
/*
* We found a list of scbs that needs to be searched.
*/
if (action == SEARCH_PRINT)
printk(" %d ( ", SCB_GET_TARGET(ahd, scb));
tid_head = scbid;
found += ahd_search_scb_list(ahd, target, channel,
lun, tag, role, status,
action, &tid_head, &tid_tail,
SCB_GET_TARGET(ahd, scb));
/*
* Check any MK_MESSAGE SCB that is still waiting to
* enter this target's waiting for selection queue.
*/
if (mk_msg_scb != NULL
&& ahd_match_scb(ahd, mk_msg_scb, target, channel,
lun, tag, role)) {
/*
* We found an scb that needs to be acted on.
*/
found++;
switch (action) {
case SEARCH_COMPLETE:
if ((mk_msg_scb->flags & SCB_ACTIVE) == 0)
printk("Inactive SCB pending MK_MSG\n");
ahd_done_with_status(ahd, mk_msg_scb, status);
/* FALLTHROUGH */
case SEARCH_REMOVE:
{
u_int tail_offset;
printk("Removing MK_MSG scb\n");
/*
* Reset our tail to the tail of the
* main per-target list.
*/
tail_offset = WAITING_SCB_TAILS
+ (2 * SCB_GET_TARGET(ahd, mk_msg_scb));
ahd_outw(ahd, tail_offset, tid_tail);
seq_flags2 &= ~PENDING_MK_MESSAGE;
ahd_outb(ahd, SEQ_FLAGS2, seq_flags2);
ahd_outw(ahd, CMDS_PENDING,
ahd_inw(ahd, CMDS_PENDING)-1);
mk_msg_scb = NULL;
break;
}
case SEARCH_PRINT:
printk(" 0x%x", SCB_GET_TAG(scb));
/* FALLTHROUGH */
case SEARCH_COUNT:
break;
}
}
if (mk_msg_scb != NULL
&& SCBID_IS_NULL(tid_head)
&& ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD,
SCB_LIST_NULL, ROLE_UNKNOWN)) {
/*
* When removing the last SCB for a target
* queue with a pending MK_MESSAGE scb, we
* must queue the MK_MESSAGE scb.
*/
printk("Queueing mk_msg_scb\n");
tid_head = ahd_inw(ahd, MK_MESSAGE_SCB);
seq_flags2 &= ~PENDING_MK_MESSAGE;
ahd_outb(ahd, SEQ_FLAGS2, seq_flags2);
mk_msg_scb = NULL;
}
if (tid_head != scbid)
ahd_stitch_tid_list(ahd, tid_prev, tid_head, tid_next);
if (!SCBID_IS_NULL(tid_head))
tid_prev = tid_head;
if (action == SEARCH_PRINT)
printk(")\n");
}
/* Restore saved state. */
ahd_set_scbptr(ahd, savedscbptr);
ahd_restore_modes(ahd, saved_modes);
return (found);
}
static int
ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
int lun, u_int tag, role_t role, uint32_t status,
ahd_search_action action, u_int *list_head,
u_int *list_tail, u_int tid)
{
struct scb *scb;
u_int scbid;
u_int next;
u_int prev;
int found;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
found = 0;
prev = SCB_LIST_NULL;
next = *list_head;
*list_tail = SCB_LIST_NULL;
for (scbid = next; !SCBID_IS_NULL(scbid); scbid = next) {
if (scbid >= ahd->scb_data.numscbs) {
printk("%s:SCB List inconsistency. "
"SCB == 0x%x, yet numscbs == 0x%x.",
ahd_name(ahd), scbid, ahd->scb_data.numscbs);
ahd_dump_card_state(ahd);
panic("for safety");
}
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printk("%s: SCB = %d Not Active!\n",
ahd_name(ahd), scbid);
panic("Waiting List traversal\n");
}
ahd_set_scbptr(ahd, scbid);
*list_tail = scbid;
next = ahd_inw_scbram(ahd, SCB_NEXT);
if (ahd_match_scb(ahd, scb, target, channel,
lun, SCB_LIST_NULL, role) == 0) {
prev = scbid;
continue;
}
found++;
switch (action) {
case SEARCH_COMPLETE:
if ((scb->flags & SCB_ACTIVE) == 0)
printk("Inactive SCB in Waiting List\n");
ahd_done_with_status(ahd, scb, status);
/* FALLTHROUGH */
case SEARCH_REMOVE:
ahd_rem_wscb(ahd, scbid, prev, next, tid);
*list_tail = prev;
if (SCBID_IS_NULL(prev))
*list_head = next;
break;
case SEARCH_PRINT:
printk("0x%x ", scbid);
case SEARCH_COUNT:
prev = scbid;
break;
}
if (found > AHD_SCB_MAX)
panic("SCB LIST LOOP");
}
if (action == SEARCH_COMPLETE
|| action == SEARCH_REMOVE)
ahd_outw(ahd, CMDS_PENDING, ahd_inw(ahd, CMDS_PENDING) - found);
return (found);
}
static void
ahd_stitch_tid_list(struct ahd_softc *ahd, u_int tid_prev,
u_int tid_cur, u_int tid_next)
{
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
if (SCBID_IS_NULL(tid_cur)) {
/* Bypass current TID list */
if (SCBID_IS_NULL(tid_prev)) {
ahd_outw(ahd, WAITING_TID_HEAD, tid_next);
} else {
ahd_set_scbptr(ahd, tid_prev);
ahd_outw(ahd, SCB_NEXT2, tid_next);
}
if (SCBID_IS_NULL(tid_next))
ahd_outw(ahd, WAITING_TID_TAIL, tid_prev);
} else {
/* Stitch through tid_cur */
if (SCBID_IS_NULL(tid_prev)) {
ahd_outw(ahd, WAITING_TID_HEAD, tid_cur);
} else {
ahd_set_scbptr(ahd, tid_prev);
ahd_outw(ahd, SCB_NEXT2, tid_cur);
}
ahd_set_scbptr(ahd, tid_cur);
ahd_outw(ahd, SCB_NEXT2, tid_next);
if (SCBID_IS_NULL(tid_next))
ahd_outw(ahd, WAITING_TID_TAIL, tid_cur);
}
}
/*
* Manipulate the waiting for selection list and return the
* scb that follows the one that we remove.
*/
static u_int
ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
u_int prev, u_int next, u_int tid)
{
u_int tail_offset;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
if (!SCBID_IS_NULL(prev)) {
ahd_set_scbptr(ahd, prev);
ahd_outw(ahd, SCB_NEXT, next);
}
/*
* SCBs that have MK_MESSAGE set in them may
* cause the tail pointer to be updated without
* setting the next pointer of the previous tail.
* Only clear the tail if the removed SCB was
* the tail.
*/
tail_offset = WAITING_SCB_TAILS + (2 * tid);
if (SCBID_IS_NULL(next)
&& ahd_inw(ahd, tail_offset) == scbid)
ahd_outw(ahd, tail_offset, prev);
ahd_add_scb_to_free_list(ahd, scbid);
return (next);
}
/*
* Add the SCB as selected by SCBPTR onto the on chip list of
* free hardware SCBs. This list is empty/unused if we are not
* performing SCB paging.
*/
static void
ahd_add_scb_to_free_list(struct ahd_softc *ahd, u_int scbid)
{
/* XXX Need some other mechanism to designate "free". */
/*
* Invalidate the tag so that our abort
* routines don't think it's active.
ahd_outb(ahd, SCB_TAG, SCB_LIST_NULL);
*/
}
/******************************** Error Handling ******************************/
/*
* Abort all SCBs that match the given description (target/channel/lun/tag),
* setting their status to the passed in status if the status has not already
* been modified from CAM_REQ_INPROG. This routine assumes that the sequencer
* is paused before it is called.
*/
static int
ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel,
int lun, u_int tag, role_t role, uint32_t status)
{
struct scb *scbp;
struct scb *scbp_next;
u_int i, j;
u_int maxtarget;
u_int minlun;
u_int maxlun;
int found;
ahd_mode_state saved_modes;
/* restore this when we're done */
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
found = ahd_search_qinfifo(ahd, target, channel, lun, SCB_LIST_NULL,
role, CAM_REQUEUE_REQ, SEARCH_COMPLETE);
/*
* Clean out the busy target table for any untagged commands.
*/
i = 0;
maxtarget = 16;
if (target != CAM_TARGET_WILDCARD) {
i = target;
if (channel == 'B')
i += 8;
maxtarget = i + 1;
}
if (lun == CAM_LUN_WILDCARD) {
minlun = 0;
maxlun = AHD_NUM_LUNS_NONPKT;
} else if (lun >= AHD_NUM_LUNS_NONPKT) {
minlun = maxlun = 0;
} else {
minlun = lun;
maxlun = lun + 1;
}
if (role != ROLE_TARGET) {
for (;i < maxtarget; i++) {
for (j = minlun;j < maxlun; j++) {
u_int scbid;
u_int tcl;
tcl = BUILD_TCL_RAW(i, 'A', j);
scbid = ahd_find_busy_tcl(ahd, tcl);
scbp = ahd_lookup_scb(ahd, scbid);
if (scbp == NULL
|| ahd_match_scb(ahd, scbp, target, channel,
lun, tag, role) == 0)
continue;
ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(i, 'A', j));
}
}
}
/*
* Don't abort commands that have already completed,
* but haven't quite made it up to the host yet.
*/
ahd_flush_qoutfifo(ahd);
/*
* Go through the pending CCB list and look for
* commands for this target that are still active.
* These are other tagged commands that were
* disconnected when the reset occurred.
*/
scbp_next = LIST_FIRST(&ahd->pending_scbs);
while (scbp_next != NULL) {
scbp = scbp_next;
scbp_next = LIST_NEXT(scbp, pending_links);
if (ahd_match_scb(ahd, scbp, target, channel, lun, tag, role)) {
cam_status ostat;
ostat = ahd_get_transaction_status(scbp);
if (ostat == CAM_REQ_INPROG)
ahd_set_transaction_status(scbp, status);
if (ahd_get_transaction_status(scbp) != CAM_REQ_CMP)
ahd_freeze_scb(scbp);
if ((scbp->flags & SCB_ACTIVE) == 0)
printk("Inactive SCB on pending list\n");
ahd_done(ahd, scbp);
found++;
}
}
ahd_restore_modes(ahd, saved_modes);
ahd_platform_abort_scbs(ahd, target, channel, lun, tag, role, status);
ahd->flags |= AHD_UPDATE_PEND_CMDS;
return found;
}
static void
ahd_reset_current_bus(struct ahd_softc *ahd)
{
uint8_t scsiseq;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) & ~ENSCSIRST);
scsiseq = ahd_inb(ahd, SCSISEQ0) & ~(ENSELO|ENARBO|SCSIRSTO);
ahd_outb(ahd, SCSISEQ0, scsiseq | SCSIRSTO);
ahd_flush_device_writes(ahd);
ahd_delay(AHD_BUSRESET_DELAY);
/* Turn off the bus reset */
ahd_outb(ahd, SCSISEQ0, scsiseq);
ahd_flush_device_writes(ahd);
ahd_delay(AHD_BUSRESET_DELAY);
if ((ahd->bugs & AHD_SCSIRST_BUG) != 0) {
/*
* 2A Razor #474
* Certain chip state is not cleared for
* SCSI bus resets that we initiate, so
* we must reset the chip.
*/
ahd_reset(ahd, /*reinit*/TRUE);
ahd_intr_enable(ahd, /*enable*/TRUE);
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
}
ahd_clear_intstat(ahd);
}
int
ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
{
struct ahd_devinfo caminfo;
u_int initiator;
u_int target;
u_int max_scsiid;
int found;
u_int fifo;
u_int next_fifo;
uint8_t scsiseq;
/*
* Check if the last bus reset is cleared
*/
if (ahd->flags & AHD_BUS_RESET_ACTIVE) {
printk("%s: bus reset still active\n",
ahd_name(ahd));
return 0;
}
ahd->flags |= AHD_BUS_RESET_ACTIVE;
ahd->pending_device = NULL;
ahd_compile_devinfo(&caminfo,
CAM_TARGET_WILDCARD,
CAM_TARGET_WILDCARD,
CAM_LUN_WILDCARD,
channel, ROLE_UNKNOWN);
ahd_pause(ahd);
/* Make sure the sequencer is in a safe location. */
ahd_clear_critical_section(ahd);
/*
* Run our command complete fifos to ensure that we perform
* completion processing on any commands that 'completed'
* before the reset occurred.
*/
ahd_run_qoutfifo(ahd);
#ifdef AHD_TARGET_MODE
if ((ahd->flags & AHD_TARGETROLE) != 0) {
ahd_run_tqinfifo(ahd, /*paused*/TRUE);
}
#endif
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
/*
* Disable selections so no automatic hardware
* functions will modify chip state.
*/
ahd_outb(ahd, SCSISEQ0, 0);
ahd_outb(ahd, SCSISEQ1, 0);
/*
* Safely shut down our DMA engines. Always start with
* the FIFO that is not currently active (if any are
* actively connected).
*/
next_fifo = fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO;
if (next_fifo > CURRFIFO_1)
/* If disconneced, arbitrarily start with FIFO1. */
next_fifo = fifo = 0;
do {
next_fifo ^= CURRFIFO_1;
ahd_set_modes(ahd, next_fifo, next_fifo);
ahd_outb(ahd, DFCNTRL,
ahd_inb(ahd, DFCNTRL) & ~(SCSIEN|HDMAEN));
while ((ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0)
ahd_delay(10);
/*
* Set CURRFIFO to the now inactive channel.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, DFFSTAT, next_fifo);
} while (next_fifo != fifo);
/*
* Reset the bus if we are initiating this reset
*/
ahd_clear_msg_state(ahd);
ahd_outb(ahd, SIMODE1,
ahd_inb(ahd, SIMODE1) & ~(ENBUSFREE|ENSCSIRST));
if (initiate_reset)
ahd_reset_current_bus(ahd);
ahd_clear_intstat(ahd);
/*
* Clean up all the state information for the
* pending transactions on this bus.
*/
found = ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, channel,
CAM_LUN_WILDCARD, SCB_LIST_NULL,
ROLE_UNKNOWN, CAM_SCSI_BUS_RESET);
/*
* Cleanup anything left in the FIFOs.
*/
ahd_clear_fifo(ahd, 0);
ahd_clear_fifo(ahd, 1);
/*
* Clear SCSI interrupt status
*/
ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
/*
* Reenable selections
*/
ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST);
scsiseq = ahd_inb(ahd, SCSISEQ_TEMPLATE);
ahd_outb(ahd, SCSISEQ1, scsiseq & (ENSELI|ENRSELI|ENAUTOATNP));
max_scsiid = (ahd->features & AHD_WIDE) ? 15 : 7;
#ifdef AHD_TARGET_MODE
/*
* Send an immediate notify ccb to all target more peripheral
* drivers affected by this action.
*/
for (target = 0; target <= max_scsiid; target++) {
struct ahd_tmode_tstate* tstate;
u_int lun;
tstate = ahd->enabled_targets[target];
if (tstate == NULL)
continue;
for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
struct ahd_tmode_lstate* lstate;
lstate = tstate->enabled_luns[lun];
if (lstate == NULL)
continue;
ahd_queue_lstate_event(ahd, lstate, CAM_TARGET_WILDCARD,
EVENT_TYPE_BUS_RESET, /*arg*/0);
ahd_send_lstate_events(ahd, lstate);
}
}
#endif
/*
* Revert to async/narrow transfers until we renegotiate.
*/
for (target = 0; target <= max_scsiid; target++) {
if (ahd->enabled_targets[target] == NULL)
continue;
for (initiator = 0; initiator <= max_scsiid; initiator++) {
struct ahd_devinfo devinfo;
ahd_compile_devinfo(&devinfo, target, initiator,
CAM_LUN_WILDCARD,
'A', ROLE_UNKNOWN);
ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR, /*paused*/TRUE);
ahd_set_syncrate(ahd, &devinfo, /*period*/0,
/*offset*/0, /*ppr_options*/0,
AHD_TRANS_CUR, /*paused*/TRUE);
}
}
/* Notify the XPT that a bus reset occurred */
ahd_send_async(ahd, caminfo.channel, CAM_TARGET_WILDCARD,
CAM_LUN_WILDCARD, AC_BUS_RESET);
ahd_restart(ahd);
return (found);
}
/**************************** Statistics Processing ***************************/
static void
ahd_stat_timer(struct timer_list *t)
{
struct ahd_softc *ahd = from_timer(ahd, t, stat_timer);
u_long s;
int enint_coal;
ahd_lock(ahd, &s);
enint_coal = ahd->hs_mailbox & ENINT_COALESCE;
if (ahd->cmdcmplt_total > ahd->int_coalescing_threshold)
enint_coal |= ENINT_COALESCE;
else if (ahd->cmdcmplt_total < ahd->int_coalescing_stop_threshold)
enint_coal &= ~ENINT_COALESCE;
if (enint_coal != (ahd->hs_mailbox & ENINT_COALESCE)) {
ahd_enable_coalescing(ahd, enint_coal);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_INT_COALESCING) != 0)
printk("%s: Interrupt coalescing "
"now %sabled. Cmds %d\n",
ahd_name(ahd),
(enint_coal & ENINT_COALESCE) ? "en" : "dis",
ahd->cmdcmplt_total);
#endif
}
ahd->cmdcmplt_bucket = (ahd->cmdcmplt_bucket+1) & (AHD_STAT_BUCKETS-1);
ahd->cmdcmplt_total -= ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket];
ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket] = 0;
ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US);
ahd_unlock(ahd, &s);
}
/****************************** Status Processing *****************************/
static void
ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
{
struct hardware_scb *hscb;
int paused;
/*
* The sequencer freezes its select-out queue
* anytime a SCSI status error occurs. We must
* handle the error and increment our qfreeze count
* to allow the sequencer to continue. We don't
* bother clearing critical sections here since all
* operations are on data structures that the sequencer
* is not touching once the queue is frozen.
*/
hscb = scb->hscb;
if (ahd_is_paused(ahd)) {
paused = 1;
} else {
paused = 0;
ahd_pause(ahd);
}
/* Freeze the queue until the client sees the error. */
ahd_freeze_devq(ahd, scb);
ahd_freeze_scb(scb);
ahd->qfreeze_cnt++;
ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt);
if (paused == 0)
ahd_unpause(ahd);
/* Don't want to clobber the original sense code */
if ((scb->flags & SCB_SENSE) != 0) {
/*
* Clear the SCB_SENSE Flag and perform
* a normal command completion.
*/
scb->flags &= ~SCB_SENSE;
ahd_set_transaction_status(scb, CAM_AUTOSENSE_FAIL);
ahd_done(ahd, scb);
return;
}
ahd_set_transaction_status(scb, CAM_SCSI_STATUS_ERROR);
ahd_set_scsi_status(scb, hscb->shared_data.istatus.scsi_status);
switch (hscb->shared_data.istatus.scsi_status) {
case STATUS_PKT_SENSE:
{
struct scsi_status_iu_header *siu;
ahd_sync_sense(ahd, scb, BUS_DMASYNC_POSTREAD);
siu = (struct scsi_status_iu_header *)scb->sense_data;
ahd_set_scsi_status(scb, siu->status);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_SENSE) != 0) {
ahd_print_path(ahd, scb);
printk("SCB 0x%x Received PKT Status of 0x%x\n",
SCB_GET_TAG(scb), siu->status);
printk("\tflags = 0x%x, sense len = 0x%x, "
"pktfail = 0x%x\n",
siu->flags, scsi_4btoul(siu->sense_length),
scsi_4btoul(siu->pkt_failures_length));
}
#endif
if ((siu->flags & SIU_RSPVALID) != 0) {
ahd_print_path(ahd, scb);
if (scsi_4btoul(siu->pkt_failures_length) < 4) {
printk("Unable to parse pkt_failures\n");
} else {
switch (SIU_PKTFAIL_CODE(siu)) {
case SIU_PFC_NONE:
printk("No packet failure found\n");
break;
case SIU_PFC_CIU_FIELDS_INVALID:
printk("Invalid Command IU Field\n");
break;
case SIU_PFC_TMF_NOT_SUPPORTED:
printk("TMF not supported\n");
break;
case SIU_PFC_TMF_FAILED:
printk("TMF failed\n");
break;
case SIU_PFC_INVALID_TYPE_CODE:
printk("Invalid L_Q Type code\n");
break;
case SIU_PFC_ILLEGAL_REQUEST:
printk("Illegal request\n");
default:
break;
}
}
if (siu->status == SCSI_STATUS_OK)
ahd_set_transaction_status(scb,
CAM_REQ_CMP_ERR);
}
if ((siu->flags & SIU_SNSVALID) != 0) {
scb->flags |= SCB_PKT_SENSE;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_SENSE) != 0)
printk("Sense data available\n");
#endif
}
ahd_done(ahd, scb);
break;
}
case SCSI_STATUS_CMD_TERMINATED:
case SCSI_STATUS_CHECK_COND:
{
struct ahd_devinfo devinfo;
struct ahd_dma_seg *sg;
struct scsi_sense *sc;
struct ahd_initiator_tinfo *targ_info;
struct ahd_tmode_tstate *tstate;
struct ahd_transinfo *tinfo;
#ifdef AHD_DEBUG
if (ahd_debug & AHD_SHOW_SENSE) {
ahd_print_path(ahd, scb);
printk("SCB %d: requests Check Status\n",
SCB_GET_TAG(scb));
}
#endif
if (ahd_perform_autosense(scb) == 0)
break;
ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb),
SCB_GET_TARGET(ahd, scb),
SCB_GET_LUN(scb),
SCB_GET_CHANNEL(ahd, scb),
ROLE_INITIATOR);
targ_info = ahd_fetch_transinfo(ahd,
devinfo.channel,
devinfo.our_scsiid,
devinfo.target,
&tstate);
tinfo = &targ_info->curr;
sg = scb->sg_list;
sc = (struct scsi_sense *)hscb->shared_data.idata.cdb;
/*
* Save off the residual if there is one.
*/
ahd_update_residual(ahd, scb);
#ifdef AHD_DEBUG
if (ahd_debug & AHD_SHOW_SENSE) {
ahd_print_path(ahd, scb);
printk("Sending Sense\n");
}
#endif
scb->sg_count = 0;
sg = ahd_sg_setup(ahd, scb, sg, ahd_get_sense_bufaddr(ahd, scb),
ahd_get_sense_bufsize(ahd, scb),
/*last*/TRUE);
sc->opcode = REQUEST_SENSE;
sc->byte2 = 0;
if (tinfo->protocol_version <= SCSI_REV_2
&& SCB_GET_LUN(scb) < 8)
sc->byte2 = SCB_GET_LUN(scb) << 5;
sc->unused[0] = 0;
sc->unused[1] = 0;
sc->length = ahd_get_sense_bufsize(ahd, scb);
sc->control = 0;
/*
* We can't allow the target to disconnect.
* This will be an untagged transaction and
* having the target disconnect will make this
* transaction indestinguishable from outstanding
* tagged transactions.
*/
hscb->control = 0;
/*
* This request sense could be because the
* the device lost power or in some other
* way has lost our transfer negotiations.
* Renegotiate if appropriate. Unit attention
* errors will be reported before any data
* phases occur.
*/
if (ahd_get_residual(scb) == ahd_get_transfer_length(scb)) {
ahd_update_neg_request(ahd, &devinfo,
tstate, targ_info,
AHD_NEG_IF_NON_ASYNC);
}
if (tstate->auto_negotiate & devinfo.target_mask) {
hscb->control |= MK_MESSAGE;
scb->flags &=
~(SCB_NEGOTIATE|SCB_ABORT|SCB_DEVICE_RESET);
scb->flags |= SCB_AUTO_NEGOTIATE;
}
hscb->cdb_len = sizeof(*sc);
ahd_setup_data_scb(ahd, scb);
scb->flags |= SCB_SENSE;
ahd_queue_scb(ahd, scb);
break;
}
case SCSI_STATUS_OK:
printk("%s: Interrupted for status of 0???\n",
ahd_name(ahd));
/* FALLTHROUGH */
default:
ahd_done(ahd, scb);
break;
}
}
static void
ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
{
if (scb->hscb->shared_data.istatus.scsi_status != 0) {
ahd_handle_scsi_status(ahd, scb);
} else {
ahd_calc_residual(ahd, scb);
ahd_done(ahd, scb);
}
}
/*
* Calculate the residual for a just completed SCB.
*/
static void
ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb)
{
struct hardware_scb *hscb;
struct initiator_status *spkt;
uint32_t sgptr;
uint32_t resid_sgptr;
uint32_t resid;
/*
* 5 cases.
* 1) No residual.
* SG_STATUS_VALID clear in sgptr.
* 2) Transferless command
* 3) Never performed any transfers.
* sgptr has SG_FULL_RESID set.
* 4) No residual but target did not
* save data pointers after the
* last transfer, so sgptr was
* never updated.
* 5) We have a partial residual.
* Use residual_sgptr to determine
* where we are.
*/
hscb = scb->hscb;
sgptr = ahd_le32toh(hscb->sgptr);
if ((sgptr & SG_STATUS_VALID) == 0)
/* Case 1 */
return;
sgptr &= ~SG_STATUS_VALID;
if ((sgptr & SG_LIST_NULL) != 0)
/* Case 2 */
return;
/*
* Residual fields are the same in both
* target and initiator status packets,
* so we can always use the initiator fields
* regardless of the role for this SCB.
*/
spkt = &hscb->shared_data.istatus;
resid_sgptr = ahd_le32toh(spkt->residual_sgptr);
if ((sgptr & SG_FULL_RESID) != 0) {
/* Case 3 */
resid = ahd_get_transfer_length(scb);
} else if ((resid_sgptr & SG_LIST_NULL) != 0) {
/* Case 4 */
return;
} else if ((resid_sgptr & SG_OVERRUN_RESID) != 0) {
ahd_print_path(ahd, scb);
printk("data overrun detected Tag == 0x%x.\n",
SCB_GET_TAG(scb));
ahd_freeze_devq(ahd, scb);
ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
ahd_freeze_scb(scb);
return;
} else if ((resid_sgptr & ~SG_PTR_MASK) != 0) {
panic("Bogus resid sgptr value 0x%x\n", resid_sgptr);
/* NOTREACHED */
} else {
struct ahd_dma_seg *sg;
/*
* Remainder of the SG where the transfer
* stopped.
*/
resid = ahd_le32toh(spkt->residual_datacnt) & AHD_SG_LEN_MASK;
sg = ahd_sg_bus_to_virt(ahd, scb, resid_sgptr & SG_PTR_MASK);
/* The residual sg_ptr always points to the next sg */
sg--;
/*
* Add up the contents of all residual
* SG segments that are after the SG where
* the transfer stopped.
*/
while ((ahd_le32toh(sg->len) & AHD_DMA_LAST_SEG) == 0) {
sg++;
resid += ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
}
}
if ((scb->flags & SCB_SENSE) == 0)
ahd_set_residual(scb, resid);
else
ahd_set_sense_residual(scb, resid);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0) {
ahd_print_path(ahd, scb);
printk("Handled %sResidual of %d bytes\n",
(scb->flags & SCB_SENSE) ? "Sense " : "", resid);
}
#endif
}
/******************************* Target Mode **********************************/
#ifdef AHD_TARGET_MODE
/*
* Add a target mode event to this lun's queue
*/
static void
ahd_queue_lstate_event(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate,
u_int initiator_id, u_int event_type, u_int event_arg)
{
struct ahd_tmode_event *event;
int pending;
xpt_freeze_devq(lstate->path, /*count*/1);
if (lstate->event_w_idx >= lstate->event_r_idx)
pending = lstate->event_w_idx - lstate->event_r_idx;
else
pending = AHD_TMODE_EVENT_BUFFER_SIZE + 1
- (lstate->event_r_idx - lstate->event_w_idx);
if (event_type == EVENT_TYPE_BUS_RESET
|| event_type == MSG_BUS_DEV_RESET) {
/*
* Any earlier events are irrelevant, so reset our buffer.
* This has the effect of allowing us to deal with reset
* floods (an external device holding down the reset line)
* without losing the event that is really interesting.
*/
lstate->event_r_idx = 0;
lstate->event_w_idx = 0;
xpt_release_devq(lstate->path, pending, /*runqueue*/FALSE);
}
if (pending == AHD_TMODE_EVENT_BUFFER_SIZE) {
xpt_print_path(lstate->path);
printk("immediate event %x:%x lost\n",
lstate->event_buffer[lstate->event_r_idx].event_type,
lstate->event_buffer[lstate->event_r_idx].event_arg);
lstate->event_r_idx++;
if (lstate->event_r_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
lstate->event_r_idx = 0;
xpt_release_devq(lstate->path, /*count*/1, /*runqueue*/FALSE);
}
event = &lstate->event_buffer[lstate->event_w_idx];
event->initiator_id = initiator_id;
event->event_type = event_type;
event->event_arg = event_arg;
lstate->event_w_idx++;
if (lstate->event_w_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
lstate->event_w_idx = 0;
}
/*
* Send any target mode events queued up waiting
* for immediate notify resources.
*/
void
ahd_send_lstate_events(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate)
{
struct ccb_hdr *ccbh;
struct ccb_immed_notify *inot;
while (lstate->event_r_idx != lstate->event_w_idx
&& (ccbh = SLIST_FIRST(&lstate->immed_notifies)) != NULL) {
struct ahd_tmode_event *event;
event = &lstate->event_buffer[lstate->event_r_idx];
SLIST_REMOVE_HEAD(&lstate->immed_notifies, sim_links.sle);
inot = (struct ccb_immed_notify *)ccbh;
switch (event->event_type) {
case EVENT_TYPE_BUS_RESET:
ccbh->status = CAM_SCSI_BUS_RESET|CAM_DEV_QFRZN;
break;
default:
ccbh->status = CAM_MESSAGE_RECV|CAM_DEV_QFRZN;
inot->message_args[0] = event->event_type;
inot->message_args[1] = event->event_arg;
break;
}
inot->initiator_id = event->initiator_id;
inot->sense_len = 0;
xpt_done((union ccb *)inot);
lstate->event_r_idx++;
if (lstate->event_r_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
lstate->event_r_idx = 0;
}
}
#endif
/******************** Sequencer Program Patching/Download *********************/
#ifdef AHD_DUMP_SEQ
void
ahd_dumpseq(struct ahd_softc* ahd)
{
int i;
int max_prog;
max_prog = 2048;
ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
ahd_outw(ahd, PRGMCNT, 0);
for (i = 0; i < max_prog; i++) {
uint8_t ins_bytes[4];
ahd_insb(ahd, SEQRAM, ins_bytes, 4);
printk("0x%08x\n", ins_bytes[0] << 24
| ins_bytes[1] << 16
| ins_bytes[2] << 8
| ins_bytes[3]);
}
}
#endif
static void
ahd_loadseq(struct ahd_softc *ahd)
{
struct cs cs_table[NUM_CRITICAL_SECTIONS];
u_int begin_set[NUM_CRITICAL_SECTIONS];
u_int end_set[NUM_CRITICAL_SECTIONS];
const struct patch *cur_patch;
u_int cs_count;
u_int cur_cs;
u_int i;
int downloaded;
u_int skip_addr;
u_int sg_prefetch_cnt;
u_int sg_prefetch_cnt_limit;
u_int sg_prefetch_align;
u_int sg_size;
u_int cacheline_mask;
uint8_t download_consts[DOWNLOAD_CONST_COUNT];
if (bootverbose)
printk("%s: Downloading Sequencer Program...",
ahd_name(ahd));
#if DOWNLOAD_CONST_COUNT != 8
#error "Download Const Mismatch"
#endif
/*
* Start out with 0 critical sections
* that apply to this firmware load.
*/
cs_count = 0;
cur_cs = 0;
memset(begin_set, 0, sizeof(begin_set));
memset(end_set, 0, sizeof(end_set));
/*
* Setup downloadable constant table.
*
* The computation for the S/G prefetch variables is
* a bit complicated. We would like to always fetch
* in terms of cachelined sized increments. However,
* if the cacheline is not an even multiple of the
* SG element size or is larger than our SG RAM, using
* just the cache size might leave us with only a portion
* of an SG element at the tail of a prefetch. If the
* cacheline is larger than our S/G prefetch buffer less
* the size of an SG element, we may round down to a cacheline
* that doesn't contain any or all of the S/G of interest
* within the bounds of our S/G ram. Provide variables to
* the sequencer that will allow it to handle these edge
* cases.
*/
/* Start by aligning to the nearest cacheline. */
sg_prefetch_align = ahd->pci_cachesize;
if (sg_prefetch_align == 0)
sg_prefetch_align = 8;
/* Round down to the nearest power of 2. */
while (powerof2(sg_prefetch_align) == 0)
sg_prefetch_align--;
cacheline_mask = sg_prefetch_align - 1;
/*
* If the cacheline boundary is greater than half our prefetch RAM
* we risk not being able to fetch even a single complete S/G
* segment if we align to that boundary.
*/
if (sg_prefetch_align > CCSGADDR_MAX/2)
sg_prefetch_align = CCSGADDR_MAX/2;
/* Start by fetching a single cacheline. */
sg_prefetch_cnt = sg_prefetch_align;
/*
* Increment the prefetch count by cachelines until
* at least one S/G element will fit.
*/
sg_size = sizeof(struct ahd_dma_seg);
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
sg_size = sizeof(struct ahd_dma64_seg);
while (sg_prefetch_cnt < sg_size)
sg_prefetch_cnt += sg_prefetch_align;
/*
* If the cacheline is not an even multiple of
* the S/G size, we may only get a partial S/G when
* we align. Add a cacheline if this is the case.
*/
if ((sg_prefetch_align % sg_size) != 0
&& (sg_prefetch_cnt < CCSGADDR_MAX))
sg_prefetch_cnt += sg_prefetch_align;
/*
* Lastly, compute a value that the sequencer can use
* to determine if the remainder of the CCSGRAM buffer
* has a full S/G element in it.
*/
sg_prefetch_cnt_limit = -(sg_prefetch_cnt - sg_size + 1);
download_consts[SG_PREFETCH_CNT] = sg_prefetch_cnt;
download_consts[SG_PREFETCH_CNT_LIMIT] = sg_prefetch_cnt_limit;
download_consts[SG_PREFETCH_ALIGN_MASK] = ~(sg_prefetch_align - 1);
download_consts[SG_PREFETCH_ADDR_MASK] = (sg_prefetch_align - 1);
download_consts[SG_SIZEOF] = sg_size;
download_consts[PKT_OVERRUN_BUFOFFSET] =
(ahd->overrun_buf - (uint8_t *)ahd->qoutfifo) / 256;
download_consts[SCB_TRANSFER_SIZE] = SCB_TRANSFER_SIZE_1BYTE_LUN;
download_consts[CACHELINE_MASK] = cacheline_mask;
cur_patch = patches;
downloaded = 0;
skip_addr = 0;
ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
ahd_outw(ahd, PRGMCNT, 0);
for (i = 0; i < sizeof(seqprog)/4; i++) {
if (ahd_check_patch(ahd, &cur_patch, i, &skip_addr) == 0) {
/*
* Don't download this instruction as it
* is in a patch that was removed.
*/
continue;
}
/*
* Move through the CS table until we find a CS
* that might apply to this instruction.
*/
for (; cur_cs < NUM_CRITICAL_SECTIONS; cur_cs++) {
if (critical_sections[cur_cs].end <= i) {
if (begin_set[cs_count] == TRUE
&& end_set[cs_count] == FALSE) {
cs_table[cs_count].end = downloaded;
end_set[cs_count] = TRUE;
cs_count++;
}
continue;
}
if (critical_sections[cur_cs].begin <= i
&& begin_set[cs_count] == FALSE) {
cs_table[cs_count].begin = downloaded;
begin_set[cs_count] = TRUE;
}
break;
}
ahd_download_instr(ahd, i, download_consts);
downloaded++;
}
ahd->num_critical_sections = cs_count;
if (cs_count != 0) {
cs_count *= sizeof(struct cs);
ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
if (ahd->critical_sections == NULL)
panic("ahd_loadseq: Could not malloc");
memcpy(ahd->critical_sections, cs_table, cs_count);
}
ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
if (bootverbose) {
printk(" %d instructions downloaded\n", downloaded);
printk("%s: Features 0x%x, Bugs 0x%x, Flags 0x%x\n",
ahd_name(ahd), ahd->features, ahd->bugs, ahd->flags);
}
}
static int
ahd_check_patch(struct ahd_softc *ahd, const struct patch **start_patch,
u_int start_instr, u_int *skip_addr)
{
const struct patch *cur_patch;
const struct patch *last_patch;
u_int num_patches;
num_patches = ARRAY_SIZE(patches);
last_patch = &patches[num_patches];
cur_patch = *start_patch;
while (cur_patch < last_patch && start_instr == cur_patch->begin) {
if (cur_patch->patch_func(ahd) == 0) {
/* Start rejecting code */
*skip_addr = start_instr + cur_patch->skip_instr;
cur_patch += cur_patch->skip_patch;
} else {
/* Accepted this patch. Advance to the next
* one and wait for our intruction pointer to
* hit this point.
*/
cur_patch++;
}
}
*start_patch = cur_patch;
if (start_instr < *skip_addr)
/* Still skipping */
return (0);
return (1);
}
static u_int
ahd_resolve_seqaddr(struct ahd_softc *ahd, u_int address)
{
const struct patch *cur_patch;
int address_offset;
u_int skip_addr;
u_int i;
address_offset = 0;
cur_patch = patches;
skip_addr = 0;
for (i = 0; i < address;) {
ahd_check_patch(ahd, &cur_patch, i, &skip_addr);
if (skip_addr > i) {
int end_addr;
end_addr = min(address, skip_addr);
address_offset += end_addr - i;
i = skip_addr;
} else {
i++;
}
}
return (address - address_offset);
}
static void
ahd_download_instr(struct ahd_softc *ahd, u_int instrptr, uint8_t *dconsts)
{
union ins_formats instr;
struct ins_format1 *fmt1_ins;
struct ins_format3 *fmt3_ins;
u_int opcode;
/*
* The firmware is always compiled into a little endian format.
*/
instr.integer = ahd_le32toh(*(uint32_t*)&seqprog[instrptr * 4]);
fmt1_ins = &instr.format1;
fmt3_ins = NULL;
/* Pull the opcode */
opcode = instr.format1.opcode;
switch (opcode) {
case AIC_OP_JMP:
case AIC_OP_JC:
case AIC_OP_JNC:
case AIC_OP_CALL:
case AIC_OP_JNE:
case AIC_OP_JNZ:
case AIC_OP_JE:
case AIC_OP_JZ:
{
fmt3_ins = &instr.format3;
fmt3_ins->address = ahd_resolve_seqaddr(ahd, fmt3_ins->address);
/* FALLTHROUGH */
}
case AIC_OP_OR:
case AIC_OP_AND:
case AIC_OP_XOR:
case AIC_OP_ADD:
case AIC_OP_ADC:
case AIC_OP_BMOV:
if (fmt1_ins->parity != 0) {
fmt1_ins->immediate = dconsts[fmt1_ins->immediate];
}
fmt1_ins->parity = 0;
/* FALLTHROUGH */
case AIC_OP_ROL:
{
int i, count;
/* Calculate odd parity for the instruction */
for (i = 0, count = 0; i < 31; i++) {
uint32_t mask;
mask = 0x01 << i;
if ((instr.integer & mask) != 0)
count++;
}
if ((count & 0x01) == 0)
instr.format1.parity = 1;
/* The sequencer is a little endian cpu */
instr.integer = ahd_htole32(instr.integer);
ahd_outsb(ahd, SEQRAM, instr.bytes, 4);
break;
}
default:
panic("Unknown opcode encountered in seq program");
break;
}
}
static int
ahd_probe_stack_size(struct ahd_softc *ahd)
{
int last_probe;
last_probe = 0;
while (1) {
int i;
/*
* We avoid using 0 as a pattern to avoid
* confusion if the stack implementation
* "back-fills" with zeros when "poping'
* entries.
*/
for (i = 1; i <= last_probe+1; i++) {
ahd_outb(ahd, STACK, i & 0xFF);
ahd_outb(ahd, STACK, (i >> 8) & 0xFF);
}
/* Verify */
for (i = last_probe+1; i > 0; i--) {
u_int stack_entry;
stack_entry = ahd_inb(ahd, STACK)
|(ahd_inb(ahd, STACK) << 8);
if (stack_entry != i)
goto sized;
}
last_probe++;
}
sized:
return (last_probe);
}
int
ahd_print_register(const ahd_reg_parse_entry_t *table, u_int num_entries,
const char *name, u_int address, u_int value,
u_int *cur_column, u_int wrap_point)
{
int printed;
u_int printed_mask;
if (cur_column != NULL && *cur_column >= wrap_point) {
printk("\n");
*cur_column = 0;
}
printed = printk("%s[0x%x]", name, value);
if (table == NULL) {
printed += printk(" ");
*cur_column += printed;
return (printed);
}
printed_mask = 0;
while (printed_mask != 0xFF) {
int entry;
for (entry = 0; entry < num_entries; entry++) {
if (((value & table[entry].mask)
!= table[entry].value)
|| ((printed_mask & table[entry].mask)
== table[entry].mask))
continue;
printed += printk("%s%s",
printed_mask == 0 ? ":(" : "|",
table[entry].name);
printed_mask |= table[entry].mask;
break;
}
if (entry >= num_entries)
break;
}
if (printed_mask != 0)
printed += printk(") ");
else
printed += printk(" ");
if (cur_column != NULL)
*cur_column += printed;
return (printed);
}
void
ahd_dump_card_state(struct ahd_softc *ahd)
{
struct scb *scb;
ahd_mode_state saved_modes;
u_int dffstat;
int paused;
u_int scb_index;
u_int saved_scb_index;
u_int cur_col;
int i;
if (ahd_is_paused(ahd)) {
paused = 1;
} else {
paused = 0;
ahd_pause(ahd);
}
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
printk(">>>>>>>>>>>>>>>>>> Dump Card State Begins <<<<<<<<<<<<<<<<<\n"
"%s: Dumping Card State at program address 0x%x Mode 0x%x\n",
ahd_name(ahd),
ahd_inw(ahd, CURADDR),
ahd_build_mode_state(ahd, ahd->saved_src_mode,
ahd->saved_dst_mode));
if (paused)
printk("Card was paused\n");
if (ahd_check_cmdcmpltqueues(ahd))
printk("Completions are pending\n");
/*
* Mode independent registers.
*/
cur_col = 0;
ahd_intstat_print(ahd_inb(ahd, INTSTAT), &cur_col, 50);
ahd_seloid_print(ahd_inb(ahd, SELOID), &cur_col, 50);
ahd_selid_print(ahd_inb(ahd, SELID), &cur_col, 50);
ahd_hs_mailbox_print(ahd_inb(ahd, LOCAL_HS_MAILBOX), &cur_col, 50);
ahd_intctl_print(ahd_inb(ahd, INTCTL), &cur_col, 50);
ahd_seqintstat_print(ahd_inb(ahd, SEQINTSTAT), &cur_col, 50);
ahd_saved_mode_print(ahd_inb(ahd, SAVED_MODE), &cur_col, 50);
ahd_dffstat_print(ahd_inb(ahd, DFFSTAT), &cur_col, 50);
ahd_scsisigi_print(ahd_inb(ahd, SCSISIGI), &cur_col, 50);
ahd_scsiphase_print(ahd_inb(ahd, SCSIPHASE), &cur_col, 50);
ahd_scsibus_print(ahd_inb(ahd, SCSIBUS), &cur_col, 50);
ahd_lastphase_print(ahd_inb(ahd, LASTPHASE), &cur_col, 50);
ahd_scsiseq0_print(ahd_inb(ahd, SCSISEQ0), &cur_col, 50);
ahd_scsiseq1_print(ahd_inb(ahd, SCSISEQ1), &cur_col, 50);
ahd_seqctl0_print(ahd_inb(ahd, SEQCTL0), &cur_col, 50);
ahd_seqintctl_print(ahd_inb(ahd, SEQINTCTL), &cur_col, 50);
ahd_seq_flags_print(ahd_inb(ahd, SEQ_FLAGS), &cur_col, 50);
ahd_seq_flags2_print(ahd_inb(ahd, SEQ_FLAGS2), &cur_col, 50);
ahd_qfreeze_count_print(ahd_inw(ahd, QFREEZE_COUNT), &cur_col, 50);
ahd_kernel_qfreeze_count_print(ahd_inw(ahd, KERNEL_QFREEZE_COUNT),
&cur_col, 50);
ahd_mk_message_scb_print(ahd_inw(ahd, MK_MESSAGE_SCB), &cur_col, 50);
ahd_mk_message_scsiid_print(ahd_inb(ahd, MK_MESSAGE_SCSIID),
&cur_col, 50);
ahd_sstat0_print(ahd_inb(ahd, SSTAT0), &cur_col, 50);
ahd_sstat1_print(ahd_inb(ahd, SSTAT1), &cur_col, 50);
ahd_sstat2_print(ahd_inb(ahd, SSTAT2), &cur_col, 50);
ahd_sstat3_print(ahd_inb(ahd, SSTAT3), &cur_col, 50);
ahd_perrdiag_print(ahd_inb(ahd, PERRDIAG), &cur_col, 50);
ahd_simode1_print(ahd_inb(ahd, SIMODE1), &cur_col, 50);
ahd_lqistat0_print(ahd_inb(ahd, LQISTAT0), &cur_col, 50);
ahd_lqistat1_print(ahd_inb(ahd, LQISTAT1), &cur_col, 50);
ahd_lqistat2_print(ahd_inb(ahd, LQISTAT2), &cur_col, 50);
ahd_lqostat0_print(ahd_inb(ahd, LQOSTAT0), &cur_col, 50);
ahd_lqostat1_print(ahd_inb(ahd, LQOSTAT1), &cur_col, 50);
ahd_lqostat2_print(ahd_inb(ahd, LQOSTAT2), &cur_col, 50);
printk("\n");
printk("\nSCB Count = %d CMDS_PENDING = %d LASTSCB 0x%x "
"CURRSCB 0x%x NEXTSCB 0x%x\n",
ahd->scb_data.numscbs, ahd_inw(ahd, CMDS_PENDING),
ahd_inw(ahd, LASTSCB), ahd_inw(ahd, CURRSCB),
ahd_inw(ahd, NEXTSCB));
cur_col = 0;
/* QINFIFO */
ahd_search_qinfifo(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS,
CAM_LUN_WILDCARD, SCB_LIST_NULL,
ROLE_UNKNOWN, /*status*/0, SEARCH_PRINT);
saved_scb_index = ahd_get_scbptr(ahd);
printk("Pending list:");
i = 0;
LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
if (i++ > AHD_SCB_MAX)
break;
cur_col = printk("\n%3d FIFO_USE[0x%x] ", SCB_GET_TAG(scb),
ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT));
ahd_set_scbptr(ahd, SCB_GET_TAG(scb));
ahd_scb_control_print(ahd_inb_scbram(ahd, SCB_CONTROL),
&cur_col, 60);
ahd_scb_scsiid_print(ahd_inb_scbram(ahd, SCB_SCSIID),
&cur_col, 60);
}
printk("\nTotal %d\n", i);
printk("Kernel Free SCB list: ");
i = 0;
TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
struct scb *list_scb;
list_scb = scb;
do {
printk("%d ", SCB_GET_TAG(list_scb));
list_scb = LIST_NEXT(list_scb, collision_links);
} while (list_scb && i++ < AHD_SCB_MAX);
}
LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) {
if (i++ > AHD_SCB_MAX)
break;
printk("%d ", SCB_GET_TAG(scb));
}
printk("\n");
printk("Sequencer Complete DMA-inprog list: ");
scb_index = ahd_inw(ahd, COMPLETE_SCB_DMAINPROG_HEAD);
i = 0;
while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
ahd_set_scbptr(ahd, scb_index);
printk("%d ", scb_index);
scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
}
printk("\n");
printk("Sequencer Complete list: ");
scb_index = ahd_inw(ahd, COMPLETE_SCB_HEAD);
i = 0;
while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
ahd_set_scbptr(ahd, scb_index);
printk("%d ", scb_index);
scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
}
printk("\n");
printk("Sequencer DMA-Up and Complete list: ");
scb_index = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
i = 0;
while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
ahd_set_scbptr(ahd, scb_index);
printk("%d ", scb_index);
scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
}
printk("\n");
printk("Sequencer On QFreeze and Complete list: ");
scb_index = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD);
i = 0;
while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
ahd_set_scbptr(ahd, scb_index);
printk("%d ", scb_index);
scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
}
printk("\n");
ahd_set_scbptr(ahd, saved_scb_index);
dffstat = ahd_inb(ahd, DFFSTAT);
for (i = 0; i < 2; i++) {
#ifdef AHD_DEBUG
struct scb *fifo_scb;
#endif
u_int fifo_scbptr;
ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
fifo_scbptr = ahd_get_scbptr(ahd);
printk("\n\n%s: FIFO%d %s, LONGJMP == 0x%x, SCB 0x%x\n",
ahd_name(ahd), i,
(dffstat & (FIFO0FREE << i)) ? "Free" : "Active",
ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr);
cur_col = 0;
ahd_seqimode_print(ahd_inb(ahd, SEQIMODE), &cur_col, 50);
ahd_seqintsrc_print(ahd_inb(ahd, SEQINTSRC), &cur_col, 50);
ahd_dfcntrl_print(ahd_inb(ahd, DFCNTRL), &cur_col, 50);
ahd_dfstatus_print(ahd_inb(ahd, DFSTATUS), &cur_col, 50);
ahd_sg_cache_shadow_print(ahd_inb(ahd, SG_CACHE_SHADOW),
&cur_col, 50);
ahd_sg_state_print(ahd_inb(ahd, SG_STATE), &cur_col, 50);
ahd_dffsxfrctl_print(ahd_inb(ahd, DFFSXFRCTL), &cur_col, 50);
ahd_soffcnt_print(ahd_inb(ahd, SOFFCNT), &cur_col, 50);
ahd_mdffstat_print(ahd_inb(ahd, MDFFSTAT), &cur_col, 50);
if (cur_col > 50) {
printk("\n");
cur_col = 0;
}
cur_col += printk("SHADDR = 0x%x%x, SHCNT = 0x%x ",
ahd_inl(ahd, SHADDR+4),
ahd_inl(ahd, SHADDR),
(ahd_inb(ahd, SHCNT)
| (ahd_inb(ahd, SHCNT + 1) << 8)
| (ahd_inb(ahd, SHCNT + 2) << 16)));
if (cur_col > 50) {
printk("\n");
cur_col = 0;
}
cur_col += printk("HADDR = 0x%x%x, HCNT = 0x%x ",
ahd_inl(ahd, HADDR+4),
ahd_inl(ahd, HADDR),
(ahd_inb(ahd, HCNT)
| (ahd_inb(ahd, HCNT + 1) << 8)
| (ahd_inb(ahd, HCNT + 2) << 16)));
ahd_ccsgctl_print(ahd_inb(ahd, CCSGCTL), &cur_col, 50);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_SG) != 0) {
fifo_scb = ahd_lookup_scb(ahd, fifo_scbptr);
if (fifo_scb != NULL)
ahd_dump_sglist(fifo_scb);
}
#endif
}
printk("\nLQIN: ");
for (i = 0; i < 20; i++)
printk("0x%x ", ahd_inb(ahd, LQIN + i));
printk("\n");
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
printk("%s: LQISTATE = 0x%x, LQOSTATE = 0x%x, OPTIONMODE = 0x%x\n",
ahd_name(ahd), ahd_inb(ahd, LQISTATE), ahd_inb(ahd, LQOSTATE),
ahd_inb(ahd, OPTIONMODE));
printk("%s: OS_SPACE_CNT = 0x%x MAXCMDCNT = 0x%x\n",
ahd_name(ahd), ahd_inb(ahd, OS_SPACE_CNT),
ahd_inb(ahd, MAXCMDCNT));
printk("%s: SAVED_SCSIID = 0x%x SAVED_LUN = 0x%x\n",
ahd_name(ahd), ahd_inb(ahd, SAVED_SCSIID),
ahd_inb(ahd, SAVED_LUN));
ahd_simode0_print(ahd_inb(ahd, SIMODE0), &cur_col, 50);
printk("\n");
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
cur_col = 0;
ahd_ccscbctl_print(ahd_inb(ahd, CCSCBCTL), &cur_col, 50);
printk("\n");
ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
printk("%s: REG0 == 0x%x, SINDEX = 0x%x, DINDEX = 0x%x\n",
ahd_name(ahd), ahd_inw(ahd, REG0), ahd_inw(ahd, SINDEX),
ahd_inw(ahd, DINDEX));
printk("%s: SCBPTR == 0x%x, SCB_NEXT == 0x%x, SCB_NEXT2 == 0x%x\n",
ahd_name(ahd), ahd_get_scbptr(ahd),
ahd_inw_scbram(ahd, SCB_NEXT),
ahd_inw_scbram(ahd, SCB_NEXT2));
printk("CDB %x %x %x %x %x %x\n",
ahd_inb_scbram(ahd, SCB_CDB_STORE),
ahd_inb_scbram(ahd, SCB_CDB_STORE+1),
ahd_inb_scbram(ahd, SCB_CDB_STORE+2),
ahd_inb_scbram(ahd, SCB_CDB_STORE+3),
ahd_inb_scbram(ahd, SCB_CDB_STORE+4),
ahd_inb_scbram(ahd, SCB_CDB_STORE+5));
printk("STACK:");
for (i = 0; i < ahd->stack_size; i++) {
ahd->saved_stack[i] =
ahd_inb(ahd, STACK)|(ahd_inb(ahd, STACK) << 8);
printk(" 0x%x", ahd->saved_stack[i]);
}
for (i = ahd->stack_size-1; i >= 0; i--) {
ahd_outb(ahd, STACK, ahd->saved_stack[i] & 0xFF);
ahd_outb(ahd, STACK, (ahd->saved_stack[i] >> 8) & 0xFF);
}
printk("\n<<<<<<<<<<<<<<<<< Dump Card State Ends >>>>>>>>>>>>>>>>>>\n");
ahd_restore_modes(ahd, saved_modes);
if (paused == 0)
ahd_unpause(ahd);
}
#if 0
void
ahd_dump_scbs(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
u_int saved_scb_index;
int i;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
saved_scb_index = ahd_get_scbptr(ahd);
for (i = 0; i < AHD_SCB_MAX; i++) {
ahd_set_scbptr(ahd, i);
printk("%3d", i);
printk("(CTRL 0x%x ID 0x%x N 0x%x N2 0x%x SG 0x%x, RSG 0x%x)\n",
ahd_inb_scbram(ahd, SCB_CONTROL),
ahd_inb_scbram(ahd, SCB_SCSIID),
ahd_inw_scbram(ahd, SCB_NEXT),
ahd_inw_scbram(ahd, SCB_NEXT2),
ahd_inl_scbram(ahd, SCB_SGPTR),
ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR));
}
printk("\n");
ahd_set_scbptr(ahd, saved_scb_index);
ahd_restore_modes(ahd, saved_modes);
}
#endif /* 0 */
/**************************** Flexport Logic **********************************/
/*
* Read count 16bit words from 16bit word address start_addr from the
* SEEPROM attached to the controller, into buf, using the controller's
* SEEPROM reading state machine. Optionally treat the data as a byte
* stream in terms of byte order.
*/
int
ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf,
u_int start_addr, u_int count, int bytestream)
{
u_int cur_addr;
u_int end_addr;
int error;
/*
* If we never make it through the loop even once,
* we were passed invalid arguments.
*/
error = EINVAL;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
end_addr = start_addr + count;
for (cur_addr = start_addr; cur_addr < end_addr; cur_addr++) {
ahd_outb(ahd, SEEADR, cur_addr);
ahd_outb(ahd, SEECTL, SEEOP_READ | SEESTART);
error = ahd_wait_seeprom(ahd);
if (error)
break;
if (bytestream != 0) {
uint8_t *bytestream_ptr;
bytestream_ptr = (uint8_t *)buf;
*bytestream_ptr++ = ahd_inb(ahd, SEEDAT);
*bytestream_ptr = ahd_inb(ahd, SEEDAT+1);
} else {
/*
* ahd_inw() already handles machine byte order.
*/
*buf = ahd_inw(ahd, SEEDAT);
}
buf++;
}
return (error);
}
/*
* Write count 16bit words from buf, into SEEPROM attache to the
* controller starting at 16bit word address start_addr, using the
* controller's SEEPROM writing state machine.
*/
int
ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
u_int start_addr, u_int count)
{
u_int cur_addr;
u_int end_addr;
int error;
int retval;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
error = ENOENT;
/* Place the chip into write-enable mode */
ahd_outb(ahd, SEEADR, SEEOP_EWEN_ADDR);
ahd_outb(ahd, SEECTL, SEEOP_EWEN | SEESTART);
error = ahd_wait_seeprom(ahd);
if (error)
return (error);
/*
* Write the data. If we don't get through the loop at
* least once, the arguments were invalid.
*/
retval = EINVAL;
end_addr = start_addr + count;
for (cur_addr = start_addr; cur_addr < end_addr; cur_addr++) {
ahd_outw(ahd, SEEDAT, *buf++);
ahd_outb(ahd, SEEADR, cur_addr);
ahd_outb(ahd, SEECTL, SEEOP_WRITE | SEESTART);
retval = ahd_wait_seeprom(ahd);
if (retval)
break;
}
/*
* Disable writes.
*/
ahd_outb(ahd, SEEADR, SEEOP_EWDS_ADDR);
ahd_outb(ahd, SEECTL, SEEOP_EWDS | SEESTART);
error = ahd_wait_seeprom(ahd);
if (error)
return (error);
return (retval);
}
/*
* Wait ~100us for the serial eeprom to satisfy our request.
*/
static int
ahd_wait_seeprom(struct ahd_softc *ahd)
{
int cnt;
cnt = 5000;
while ((ahd_inb(ahd, SEESTAT) & (SEEARBACK|SEEBUSY)) != 0 && --cnt)
ahd_delay(5);
if (cnt == 0)
return (ETIMEDOUT);
return (0);
}
/*
* Validate the two checksums in the per_channel
* vital product data struct.
*/
static int
ahd_verify_vpd_cksum(struct vpd_config *vpd)
{
int i;
int maxaddr;
uint32_t checksum;
uint8_t *vpdarray;
vpdarray = (uint8_t *)vpd;
maxaddr = offsetof(struct vpd_config, vpd_checksum);
checksum = 0;
for (i = offsetof(struct vpd_config, resource_type); i < maxaddr; i++)
checksum = checksum + vpdarray[i];
if (checksum == 0
|| (-checksum & 0xFF) != vpd->vpd_checksum)
return (0);
checksum = 0;
maxaddr = offsetof(struct vpd_config, checksum);
for (i = offsetof(struct vpd_config, default_target_flags);
i < maxaddr; i++)
checksum = checksum + vpdarray[i];
if (checksum == 0
|| (-checksum & 0xFF) != vpd->checksum)
return (0);
return (1);
}
int
ahd_verify_cksum(struct seeprom_config *sc)
{
int i;
int maxaddr;
uint32_t checksum;
uint16_t *scarray;
maxaddr = (sizeof(*sc)/2) - 1;
checksum = 0;
scarray = (uint16_t *)sc;
for (i = 0; i < maxaddr; i++)
checksum = checksum + scarray[i];
if (checksum == 0
|| (checksum & 0xFFFF) != sc->checksum) {
return (0);
} else {
return (1);
}
}
int
ahd_acquire_seeprom(struct ahd_softc *ahd)
{
/*
* We should be able to determine the SEEPROM type
* from the flexport logic, but unfortunately not
* all implementations have this logic and there is
* no programatic method for determining if the logic
* is present.
*/
return (1);
#if 0
uint8_t seetype;
int error;
error = ahd_read_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, &seetype);
if (error != 0
|| ((seetype & FLX_ROMSTAT_SEECFG) == FLX_ROMSTAT_SEE_NONE))
return (0);
return (1);
#endif
}
void
ahd_release_seeprom(struct ahd_softc *ahd)
{
/* Currently a no-op */
}
/*
* Wait at most 2 seconds for flexport arbitration to succeed.
*/
static int
ahd_wait_flexport(struct ahd_softc *ahd)
{
int cnt;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
cnt = 1000000 * 2 / 5;
while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
ahd_delay(5);
if (cnt == 0)
return (ETIMEDOUT);
return (0);
}
int
ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value)
{
int error;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
if (addr > 7)
panic("ahd_write_flexport: address out of range");
ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3));
error = ahd_wait_flexport(ahd);
if (error != 0)
return (error);
ahd_outb(ahd, BRDDAT, value);
ahd_flush_device_writes(ahd);
ahd_outb(ahd, BRDCTL, BRDSTB|BRDEN|(addr << 3));
ahd_flush_device_writes(ahd);
ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3));
ahd_flush_device_writes(ahd);
ahd_outb(ahd, BRDCTL, 0);
ahd_flush_device_writes(ahd);
return (0);
}
int
ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value)
{
int error;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
if (addr > 7)
panic("ahd_read_flexport: address out of range");
ahd_outb(ahd, BRDCTL, BRDRW|BRDEN|(addr << 3));
error = ahd_wait_flexport(ahd);
if (error != 0)
return (error);
*value = ahd_inb(ahd, BRDDAT);
ahd_outb(ahd, BRDCTL, 0);
ahd_flush_device_writes(ahd);
return (0);
}
/************************* Target Mode ****************************************/
#ifdef AHD_TARGET_MODE
cam_status
ahd_find_tmode_devs(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb,
struct ahd_tmode_tstate **tstate,
struct ahd_tmode_lstate **lstate,
int notfound_failure)
{
if ((ahd->features & AHD_TARGETMODE) == 0)
return (CAM_REQ_INVALID);
/*
* Handle the 'black hole' device that sucks up
* requests to unattached luns on enabled targets.
*/
if (ccb->ccb_h.target_id == CAM_TARGET_WILDCARD
&& ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) {
*tstate = NULL;
*lstate = ahd->black_hole;
} else {
u_int max_id;
max_id = (ahd->features & AHD_WIDE) ? 16 : 8;
if (ccb->ccb_h.target_id >= max_id)
return (CAM_TID_INVALID);
if (ccb->ccb_h.target_lun >= AHD_NUM_LUNS)
return (CAM_LUN_INVALID);
*tstate = ahd->enabled_targets[ccb->ccb_h.target_id];
*lstate = NULL;
if (*tstate != NULL)
*lstate =
(*tstate)->enabled_luns[ccb->ccb_h.target_lun];
}
if (notfound_failure != 0 && *lstate == NULL)
return (CAM_PATH_INVALID);
return (CAM_REQ_CMP);
}
void
ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb)
{
#if NOT_YET
struct ahd_tmode_tstate *tstate;
struct ahd_tmode_lstate *lstate;
struct ccb_en_lun *cel;
cam_status status;
u_int target;
u_int lun;
u_int target_mask;
u_long s;
char channel;
status = ahd_find_tmode_devs(ahd, sim, ccb, &tstate, &lstate,
/*notfound_failure*/FALSE);
if (status != CAM_REQ_CMP) {
ccb->ccb_h.status = status;
return;
}
if ((ahd->features & AHD_MULTIROLE) != 0) {
u_int our_id;
our_id = ahd->our_id;
if (ccb->ccb_h.target_id != our_id) {
if ((ahd->features & AHD_MULTI_TID) != 0
&& (ahd->flags & AHD_INITIATORROLE) != 0) {
/*
* Only allow additional targets if
* the initiator role is disabled.
* The hardware cannot handle a re-select-in
* on the initiator id during a re-select-out
* on a different target id.
*/
status = CAM_TID_INVALID;
} else if ((ahd->flags & AHD_INITIATORROLE) != 0
|| ahd->enabled_luns > 0) {
/*
* Only allow our target id to change
* if the initiator role is not configured
* and there are no enabled luns which
* are attached to the currently registered
* scsi id.
*/
status = CAM_TID_INVALID;
}
}
}
if (status != CAM_REQ_CMP) {
ccb->ccb_h.status = status;
return;
}
/*
* We now have an id that is valid.
* If we aren't in target mode, switch modes.
*/
if ((ahd->flags & AHD_TARGETROLE) == 0
&& ccb->ccb_h.target_id != CAM_TARGET_WILDCARD) {
u_long s;
printk("Configuring Target Mode\n");
ahd_lock(ahd, &s);
if (LIST_FIRST(&ahd->pending_scbs) != NULL) {
ccb->ccb_h.status = CAM_BUSY;
ahd_unlock(ahd, &s);
return;
}
ahd->flags |= AHD_TARGETROLE;
if ((ahd->features & AHD_MULTIROLE) == 0)
ahd->flags &= ~AHD_INITIATORROLE;
ahd_pause(ahd);
ahd_loadseq(ahd);
ahd_restart(ahd);
ahd_unlock(ahd, &s);
}
cel = &ccb->cel;
target = ccb->ccb_h.target_id;
lun = ccb->ccb_h.target_lun;
channel = SIM_CHANNEL(ahd, sim);
target_mask = 0x01 << target;
if (channel == 'B')
target_mask <<= 8;
if (cel->enable != 0) {
u_int scsiseq1;
/* Are we already enabled?? */
if (lstate != NULL) {
xpt_print_path(ccb->ccb_h.path);
printk("Lun already enabled\n");
ccb->ccb_h.status = CAM_LUN_ALRDY_ENA;
return;
}
if (cel->grp6_len != 0
|| cel->grp7_len != 0) {
/*
* Don't (yet?) support vendor
* specific commands.
*/
ccb->ccb_h.status = CAM_REQ_INVALID;
printk("Non-zero Group Codes\n");
return;
}
/*
* Seems to be okay.
* Setup our data structures.
*/
if (target != CAM_TARGET_WILDCARD && tstate == NULL) {
tstate = ahd_alloc_tstate(ahd, target, channel);
if (tstate == NULL) {
xpt_print_path(ccb->ccb_h.path);
printk("Couldn't allocate tstate\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
}
lstate = kzalloc(sizeof(*lstate), GFP_ATOMIC);
if (lstate == NULL) {
xpt_print_path(ccb->ccb_h.path);
printk("Couldn't allocate lstate\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
status = xpt_create_path(&lstate->path, /*periph*/NULL,
xpt_path_path_id(ccb->ccb_h.path),
xpt_path_target_id(ccb->ccb_h.path),
xpt_path_lun_id(ccb->ccb_h.path));
if (status != CAM_REQ_CMP) {
kfree(lstate);
xpt_print_path(ccb->ccb_h.path);
printk("Couldn't allocate path\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
SLIST_INIT(&lstate->accept_tios);
SLIST_INIT(&lstate->immed_notifies);
ahd_lock(ahd, &s);
ahd_pause(ahd);
if (target != CAM_TARGET_WILDCARD) {
tstate->enabled_luns[lun] = lstate;
ahd->enabled_luns++;
if ((ahd->features & AHD_MULTI_TID) != 0) {
u_int targid_mask;
targid_mask = ahd_inw(ahd, TARGID);
targid_mask |= target_mask;
ahd_outw(ahd, TARGID, targid_mask);
ahd_update_scsiid(ahd, targid_mask);
} else {
u_int our_id;
char channel;
channel = SIM_CHANNEL(ahd, sim);
our_id = SIM_SCSI_ID(ahd, sim);
/*
* This can only happen if selections
* are not enabled
*/
if (target != our_id) {
u_int sblkctl;
char cur_channel;
int swap;
sblkctl = ahd_inb(ahd, SBLKCTL);
cur_channel = (sblkctl & SELBUSB)
? 'B' : 'A';
if ((ahd->features & AHD_TWIN) == 0)
cur_channel = 'A';
swap = cur_channel != channel;
ahd->our_id = target;
if (swap)
ahd_outb(ahd, SBLKCTL,
sblkctl ^ SELBUSB);
ahd_outb(ahd, SCSIID, target);
if (swap)
ahd_outb(ahd, SBLKCTL, sblkctl);
}
}
} else
ahd->black_hole = lstate;
/* Allow select-in operations */
if (ahd->black_hole != NULL && ahd->enabled_luns > 0) {
scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE);
scsiseq1 |= ENSELI;
ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1);
scsiseq1 = ahd_inb(ahd, SCSISEQ1);
scsiseq1 |= ENSELI;
ahd_outb(ahd, SCSISEQ1, scsiseq1);
}
ahd_unpause(ahd);
ahd_unlock(ahd, &s);
ccb->ccb_h.status = CAM_REQ_CMP;
xpt_print_path(ccb->ccb_h.path);
printk("Lun now enabled for target mode\n");
} else {
struct scb *scb;
int i, empty;
if (lstate == NULL) {
ccb->ccb_h.status = CAM_LUN_INVALID;
return;
}
ahd_lock(ahd, &s);
ccb->ccb_h.status = CAM_REQ_CMP;
LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
struct ccb_hdr *ccbh;
ccbh = &scb->io_ctx->ccb_h;
if (ccbh->func_code == XPT_CONT_TARGET_IO
&& !xpt_path_comp(ccbh->path, ccb->ccb_h.path)){
printk("CTIO pending\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
ahd_unlock(ahd, &s);
return;
}
}
if (SLIST_FIRST(&lstate->accept_tios) != NULL) {
printk("ATIOs pending\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
}
if (SLIST_FIRST(&lstate->immed_notifies) != NULL) {
printk("INOTs pending\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
}
if (ccb->ccb_h.status != CAM_REQ_CMP) {
ahd_unlock(ahd, &s);
return;
}
xpt_print_path(ccb->ccb_h.path);
printk("Target mode disabled\n");
xpt_free_path(lstate->path);
kfree(lstate);
ahd_pause(ahd);
/* Can we clean up the target too? */
if (target != CAM_TARGET_WILDCARD) {
tstate->enabled_luns[lun] = NULL;
ahd->enabled_luns--;
for (empty = 1, i = 0; i < 8; i++)
if (tstate->enabled_luns[i] != NULL) {
empty = 0;
break;
}
if (empty) {
ahd_free_tstate(ahd, target, channel,
/*force*/FALSE);
if (ahd->features & AHD_MULTI_TID) {
u_int targid_mask;
targid_mask = ahd_inw(ahd, TARGID);
targid_mask &= ~target_mask;
ahd_outw(ahd, TARGID, targid_mask);
ahd_update_scsiid(ahd, targid_mask);
}
}
} else {
ahd->black_hole = NULL;
/*
* We can't allow selections without
* our black hole device.
*/
empty = TRUE;
}
if (ahd->enabled_luns == 0) {
/* Disallow select-in */
u_int scsiseq1;
scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE);
scsiseq1 &= ~ENSELI;
ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1);
scsiseq1 = ahd_inb(ahd, SCSISEQ1);
scsiseq1 &= ~ENSELI;
ahd_outb(ahd, SCSISEQ1, scsiseq1);
if ((ahd->features & AHD_MULTIROLE) == 0) {
printk("Configuring Initiator Mode\n");
ahd->flags &= ~AHD_TARGETROLE;
ahd->flags |= AHD_INITIATORROLE;
ahd_pause(ahd);
ahd_loadseq(ahd);
ahd_restart(ahd);
/*
* Unpaused. The extra unpause
* that follows is harmless.
*/
}
}
ahd_unpause(ahd);
ahd_unlock(ahd, &s);
}
#endif
}
static void
ahd_update_scsiid(struct ahd_softc *ahd, u_int targid_mask)
{
#if NOT_YET
u_int scsiid_mask;
u_int scsiid;
if ((ahd->features & AHD_MULTI_TID) == 0)
panic("ahd_update_scsiid called on non-multitid unit\n");
/*
* Since we will rely on the TARGID mask
* for selection enables, ensure that OID
* in SCSIID is not set to some other ID
* that we don't want to allow selections on.
*/
if ((ahd->features & AHD_ULTRA2) != 0)
scsiid = ahd_inb(ahd, SCSIID_ULTRA2);
else
scsiid = ahd_inb(ahd, SCSIID);
scsiid_mask = 0x1 << (scsiid & OID);
if ((targid_mask & scsiid_mask) == 0) {
u_int our_id;
/* ffs counts from 1 */
our_id = ffs(targid_mask);
if (our_id == 0)
our_id = ahd->our_id;
else
our_id--;
scsiid &= TID;
scsiid |= our_id;
}
if ((ahd->features & AHD_ULTRA2) != 0)
ahd_outb(ahd, SCSIID_ULTRA2, scsiid);
else
ahd_outb(ahd, SCSIID, scsiid);
#endif
}
static void
ahd_run_tqinfifo(struct ahd_softc *ahd, int paused)
{
struct target_cmd *cmd;
ahd_sync_tqinfifo(ahd, BUS_DMASYNC_POSTREAD);
while ((cmd = &ahd->targetcmds[ahd->tqinfifonext])->cmd_valid != 0) {
/*
* Only advance through the queue if we
* have the resources to process the command.
*/
if (ahd_handle_target_cmd(ahd, cmd) != 0)
break;
cmd->cmd_valid = 0;
ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
ahd->shared_data_map.dmamap,
ahd_targetcmd_offset(ahd, ahd->tqinfifonext),
sizeof(struct target_cmd),
BUS_DMASYNC_PREREAD);
ahd->tqinfifonext++;
/*
* Lazily update our position in the target mode incoming
* command queue as seen by the sequencer.
*/
if ((ahd->tqinfifonext & (HOST_TQINPOS - 1)) == 1) {
u_int hs_mailbox;
hs_mailbox = ahd_inb(ahd, HS_MAILBOX);
hs_mailbox &= ~HOST_TQINPOS;
hs_mailbox |= ahd->tqinfifonext & HOST_TQINPOS;
ahd_outb(ahd, HS_MAILBOX, hs_mailbox);
}
}
}
static int
ahd_handle_target_cmd(struct ahd_softc *ahd, struct target_cmd *cmd)
{
struct ahd_tmode_tstate *tstate;
struct ahd_tmode_lstate *lstate;
struct ccb_accept_tio *atio;
uint8_t *byte;
int initiator;
int target;
int lun;
initiator = SCSIID_TARGET(ahd, cmd->scsiid);
target = SCSIID_OUR_ID(cmd->scsiid);
lun = (cmd->identify & MSG_IDENTIFY_LUNMASK);
byte = cmd->bytes;
tstate = ahd->enabled_targets[target];
lstate = NULL;
if (tstate != NULL)
lstate = tstate->enabled_luns[lun];
/*
* Commands for disabled luns go to the black hole driver.
*/
if (lstate == NULL)
lstate = ahd->black_hole;
atio = (struct ccb_accept_tio*)SLIST_FIRST(&lstate->accept_tios);
if (atio == NULL) {
ahd->flags |= AHD_TQINFIFO_BLOCKED;
/*
* Wait for more ATIOs from the peripheral driver for this lun.
*/
return (1);
} else
ahd->flags &= ~AHD_TQINFIFO_BLOCKED;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_TQIN) != 0)
printk("Incoming command from %d for %d:%d%s\n",
initiator, target, lun,
lstate == ahd->black_hole ? "(Black Holed)" : "");
#endif
SLIST_REMOVE_HEAD(&lstate->accept_tios, sim_links.sle);
if (lstate == ahd->black_hole) {
/* Fill in the wildcards */
atio->ccb_h.target_id = target;
atio->ccb_h.target_lun = lun;
}
/*
* Package it up and send it off to
* whomever has this lun enabled.
*/
atio->sense_len = 0;
atio->init_id = initiator;
if (byte[0] != 0xFF) {
/* Tag was included */
atio->tag_action = *byte++;
atio->tag_id = *byte++;
atio->ccb_h.flags = CAM_TAG_ACTION_VALID;
} else {
atio->ccb_h.flags = 0;
}
byte++;
/* Okay. Now determine the cdb size based on the command code */
switch (*byte >> CMD_GROUP_CODE_SHIFT) {
case 0:
atio->cdb_len = 6;
break;
case 1:
case 2:
atio->cdb_len = 10;
break;
case 4:
atio->cdb_len = 16;
break;
case 5:
atio->cdb_len = 12;
break;
case 3:
default:
/* Only copy the opcode. */
atio->cdb_len = 1;
printk("Reserved or VU command code type encountered\n");
break;
}
memcpy(atio->cdb_io.cdb_bytes, byte, atio->cdb_len);
atio->ccb_h.status |= CAM_CDB_RECVD;
if ((cmd->identify & MSG_IDENTIFY_DISCFLAG) == 0) {
/*
* We weren't allowed to disconnect.
* We're hanging on the bus until a
* continue target I/O comes in response
* to this accept tio.
*/
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_TQIN) != 0)
printk("Received Immediate Command %d:%d:%d - %p\n",
initiator, target, lun, ahd->pending_device);
#endif
ahd->pending_device = lstate;
ahd_freeze_ccb((union ccb *)atio);
atio->ccb_h.flags |= CAM_DIS_DISCONNECT;
}
xpt_done((union ccb*)atio);
return (0);
}
#endif
| 27.688771 | 81 | 0.674117 | [
"3d"
] |
9eea7230c5c8ce2a7412af5743c2f48c89d30de2 | 2,058 | h | C | src/analysermodel_p.h | nickerso/libcellml | 9fe5ecabc3e63c49d5ee8539ed2c8ce572a9712a | [
"Apache-2.0"
] | 1 | 2021-02-15T01:09:04.000Z | 2021-02-15T01:09:04.000Z | src/analysermodel_p.h | nickerso/libcellml | 9fe5ecabc3e63c49d5ee8539ed2c8ce572a9712a | [
"Apache-2.0"
] | 8 | 2019-09-01T23:37:50.000Z | 2021-05-27T21:20:34.000Z | src/analysermodel_p.h | nickerso/libcellml | 9fe5ecabc3e63c49d5ee8539ed2c8ce572a9712a | [
"Apache-2.0"
] | 1 | 2022-02-04T06:11:40.000Z | 2022-02-04T06:11:40.000Z | /*
Copyright libCellML Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#pragma once
#include "libcellml/analysermodel.h"
namespace libcellml {
/**
* @brief The AnalyserModel::AnalyserModelImpl struct.
*
* The private implementation for the AnalyserModel class.
*/
struct AnalyserModel::AnalyserModelImpl
{
AnalyserModel::Type mType = Type::UNKNOWN;
bool mHasExternalVariables = false;
AnalyserVariablePtr mVoi = nullptr;
std::vector<AnalyserVariablePtr> mStates;
std::vector<AnalyserVariablePtr> mVariables;
std::vector<AnalyserEquationPtr> mEquations;
bool mNeedEqFunction = false;
bool mNeedNeqFunction = false;
bool mNeedLtFunction = false;
bool mNeedLeqFunction = false;
bool mNeedGtFunction = false;
bool mNeedGeqFunction = false;
bool mNeedAndFunction = false;
bool mNeedOrFunction = false;
bool mNeedXorFunction = false;
bool mNeedNotFunction = false;
bool mNeedMinFunction = false;
bool mNeedMaxFunction = false;
bool mNeedSecFunction = false;
bool mNeedCscFunction = false;
bool mNeedCotFunction = false;
bool mNeedSechFunction = false;
bool mNeedCschFunction = false;
bool mNeedCothFunction = false;
bool mNeedAsecFunction = false;
bool mNeedAcscFunction = false;
bool mNeedAcotFunction = false;
bool mNeedAsechFunction = false;
bool mNeedAcschFunction = false;
bool mNeedAcothFunction = false;
std::map<uintptr_t, bool> mCachedEquivalentVariables;
static AnalyserModelPtr create();
};
} // namespace libcellml
| 28.583333 | 72 | 0.74587 | [
"vector"
] |
9eeb08231fa15cc7002fa7ab02c6f6320c781402 | 4,281 | h | C | stk_wrapper/stk/BandedWG.h | romsom/HISE | 73e0e299493ce9236e6fafa7938d3477fcc36a4a | [
"Intel"
] | 233 | 2018-07-02T16:49:36.000Z | 2022-02-27T21:45:39.000Z | stk_wrapper/stk/BandedWG.h | romsom/HISE | 73e0e299493ce9236e6fafa7938d3477fcc36a4a | [
"Intel"
] | 24 | 2018-07-09T11:32:15.000Z | 2022-01-07T01:45:43.000Z | stk_wrapper/stk/BandedWG.h | romsom/HISE | 73e0e299493ce9236e6fafa7938d3477fcc36a4a | [
"Intel"
] | 24 | 2018-07-14T21:55:30.000Z | 2021-05-04T04:20:34.000Z | #ifndef STK_BANDEDWG_H
#define STK_BANDEDWG_H
#include "Instrmnt.h"
#include "DelayL.h"
#include "BowTable.h"
#include "ADSR.h"
#include "BiQuad.h"
namespace stk {
/***************************************************/
/*! \class BandedWG
\brief Banded waveguide modeling class.
This class uses banded waveguide techniques to
model a variety of sounds, including bowed
bars, glasses, and bowls. For more
information, see Essl, G. and Cook, P. "Banded
Waveguides: Towards Physical Modelling of Bar
Percussion Instruments", Proceedings of the
1999 International Computer Music Conference.
Control Change Numbers:
- Bow Pressure = 2
- Bow Motion = 4
- Strike Position = 8 (not implemented)
- Vibrato Frequency = 11
- Gain = 1
- Bow Velocity = 128
- Set Striking = 64
- Instrument Presets = 16
- Uniform Bar = 0
- Tuned Bar = 1
- Glass Harmonica = 2
- Tibetan Bowl = 3
by Georg Essl, 1999 - 2004.
Modified for STK 4.0 by Gary Scavone.
*/
/***************************************************/
const int MAX_BANDED_MODES = 20;
class BandedWG : public Instrmnt
{
public:
//! Class constructor.
BandedWG( void );
//! Class destructor.
~BandedWG( void );
//! Reset and clear all internal state.
void clear( void );
//! Set strike position (0.0 - 1.0).
void setStrikePosition( StkFloat position );
//! Select a preset.
void setPreset( int preset );
//! Set instrument parameters for a particular frequency.
void setFrequency( StkFloat frequency );
//! Apply bow velocity/pressure to instrument with given amplitude and rate of increase.
void startBowing( StkFloat amplitude, StkFloat rate );
//! Decrease bow velocity/breath pressure with given rate of decrease.
void stopBowing( StkFloat rate );
//! Pluck the instrument with given amplitude.
void pluck( StkFloat amp );
//! Start a note with the given frequency and amplitude.
void noteOn( StkFloat frequency, StkFloat amplitude );
//! Stop a note with the given amplitude (speed of decay).
void noteOff( StkFloat amplitude );
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange( int number, StkFloat value );
//! Compute and return one output sample.
StkFloat tick( unsigned int channel = 0 );
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument must be less than the number of
channels in the StkFrames argument (the first channel is specified
by 0). However, range checking is only performed if _STK_DEBUG_
is defined during compilation, in which case an out-of-range value
will trigger an StkError exception.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
protected:
bool doPluck_;
bool trackVelocity_;
int nModes_;
int presetModes_;
BowTable bowTable_;
ADSR adsr_;
BiQuad bandpass_[MAX_BANDED_MODES];
DelayL delay_[MAX_BANDED_MODES];
StkFloat maxVelocity_;
StkFloat modes_[MAX_BANDED_MODES];
StkFloat frequency_;
StkFloat baseGain_;
StkFloat gains_[MAX_BANDED_MODES];
StkFloat basegains_[MAX_BANDED_MODES];
StkFloat excitation_[MAX_BANDED_MODES];
StkFloat integrationConstant_;
StkFloat velocityInput_;
StkFloat bowVelocity_;
StkFloat bowTarget_;
StkFloat bowPosition_;
StkFloat strikeAmp_;
int strikePosition_;
};
inline StkFrames& BandedWG :: tick( StkFrames& frames, unsigned int channel )
{
unsigned int nChannels = lastFrame_.channels();
#if defined(_STK_DEBUG_)
if ( channel > frames.channels() - nChannels ) {
oStream_ << "BandedWG::tick(): channel and StkFrames arguments are incompatible!";
handleError( StkError::FUNCTION_ARGUMENT );
}
#endif
StkFloat *samples = &frames[channel];
unsigned int j, hop = frames.channels() - nChannels;
if ( nChannels == 1 ) {
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
*samples++ = tick();
}
else {
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
*samples++ = tick();
for ( j=1; j<nChannels; j++ )
*samples++ = lastFrame_[j];
}
}
return frames;
}
} // stk namespace
#endif
| 27.798701 | 90 | 0.668302 | [
"object",
"model"
] |
9eed30adffd7f048177fff99cfab166145888e52 | 6,281 | h | C | Source/Render/RendererPipeline.h | PolyAH/RealTimeGI | 372638568ff22a4dea9c1ff448cec42e3e25aaf2 | [
"MIT"
] | 6 | 2021-10-31T14:43:04.000Z | 2022-03-12T12:56:27.000Z | Source/Render/RendererPipeline.h | PolyAH/RealTimeGI | 372638568ff22a4dea9c1ff448cec42e3e25aaf2 | [
"MIT"
] | null | null | null | Source/Render/RendererPipeline.h | PolyAH/RealTimeGI | 372638568ff22a4dea9c1ff448cec42e3e25aaf2 | [
"MIT"
] | null | null | null | // Copyright (c) 2021 Ammar Herzallah
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#include "Core/Core.h"
#include "RenderData/RenderTypes.h"
#include "RenderData/Shaders/RenderShaderBlocks.h"
#include "glm/vec2.hpp"
#include "glm/vec4.hpp"
#include <tuple>
class RenderShader;
class RenderScene;
class RenderUniform;
class RenderStageLightProbes;
class VKIDevice;
class VKISwapChain;
class VKIImage;
class VKIFramebuffer;
class VKIRenderPass;
class VKIImageView;
class VKISampler;
class VKICommandBuffer;
class VKIDescriptorSet;
// Uniforms used by the renderer pipeline.
struct RendererPipelineUniform
{
// Common Uniform.
UniquePtr<RenderUniform> common;
};
//
enum class ERenderSceneStage : uint32_t
{
Normal,
LightProbe,
};
// RendererPipeline:
// - Handle the entire render pipeline.
// - only one instance is created by the Renderer.
//
class RendererPipeline
{
// Friend...
friend class Renderer;
// Private Construct.
RendererPipeline();
public:
// Destruct.
~RendererPipeline();
// Initialize The Pipeline.
void Initialize();
// Destroy The Pipeline.
void Destroy();
// Resize the pipeline targets.
void Resize(const glm::ivec2& size);
// Return G-Buffer Render Pass.
inline VKIRenderPass* GetGBufferPass() const { return mGBufferPass.get(); }
// Return The Shadow Passe.
inline VKIRenderPass* GetDirShadowPass() const { return mDirShadowPass.get(); }
inline VKIRenderPass* GetOmniShadowPass() const { return mOmniShadowPass.get(); }
// Return the size of the
inline glm::ivec2 GetSize() const { return mSize; };
// Begin Rendering.
void BeginRender(uint32_t frame, RenderScene* rscene, const glm::vec4& viewport);
// End Rendering.
void EndRender();
// Render The Scene through the entire pipeline.
void Render(VKICommandBuffer* cmdBuffer);
// Should we wait for update before rendering next frame.
inline bool IsWaitForUpdate() const { return mWaitForUpdate; }
// Perfrom a swapchain render step where we copy the final render to the swapchain image.
void FinalToSwapchain(VKICommandBuffer* cmdBuffer, uint32_t imgIndex);
// Retrun the uniforms.
inline const RendererPipelineUniform& GetUniforms() const { return mUniforms; }
// Returm LightProbes renderer stage.
inline RenderStageLightProbes* GetStageLightProbes() const { return mStageLightProbes.get(); }
// Returm the lighting passe.
inline VKIRenderPass* GetLightingPass() const { return mLightingPass.get(); }
inline RenderShader* GetSunLightingShader() const { return mLightingShader.get(); }
// Add GBuffer targets binding to a descriptor set.
void AddGBufferToDescSet(VKIDescriptorSet* descSet);
private:
// Setup/Create the renderer pipeline uniforms.
void SetupUniforms();
// Setup HDR & LDR targets used for rendering.
void SetupTargets();
// Setup GBuffer Targets & Render Pass.
void SetupGBufferPass();
// Setup the lighting pass.
void SetupLightingPass();
// Setup Post Processing.
void SetupPostProcessPass();
// Setup BlitSwapchain.
void SetupBlitSwapchain();
// Setup the shadow passes.
void SetupShadowPasses();
// Rende Scene Shadow Maps.
void UpdateShadows(VKICommandBuffer* cmdBuffer);
// Update Scene Light Probes.
void UpdateLightProbes(VKICommandBuffer* cmdBuffer);
// Update Scene Irradiance Volumes.
void UpdateIrradianceVolumes(VKICommandBuffer* cmdBuffer);
// The stage for rendering the scene, the scene is rendered into the
void RenderSceneStage(VKICommandBuffer* cmdBuffer, ERenderSceneStage stage);
private:
// The vulkan device.
VKIDevice* mDevice;
// The vulkan swapchain.
VKISwapChain* mSwapchain;
// The Pipeline render targets size.
glm::vec2 mSize;
// The Pipeline viewport.
glm::vec4 mViewport;
glm::vec4 mIntViewport;
// Flag to check if we are currently rendering.
bool mIsRendering;
// The index of the concurrent frame we are currently rendering.
uint32_t mFrame;
// The uniforms used & update by the renderer pipeline.
RendererPipelineUniform mUniforms;
// The scene we are currently rendering.
RenderScene* mScene;
// Common Block Data.
GUniform::CommonBlock mCommonBlock;
// GBuffer Targets.
StageRenderTarget mAlbedoTarget;
StageRenderTarget mBRDFTarget;
StageRenderTarget mNormalsTarget;
StageRenderTarget mDepthTarget;
// HDR Target.
StageRenderTarget mHDRTarget[2];
// LDR Target.
StageRenderTarget mLDRTarget[2];
// GBuffer Render Pass.
UniquePtr<VKIRenderPass> mGBufferPass;
// GBuffer Framebuffer.
UniquePtr<VKIFramebuffer> mGBufferFB;
// Lighting Stage Pass.
UniquePtr<VKIRenderPass> mLightingPass;
UniquePtr<VKIFramebuffer> mLightingFB;
UniquePtr<RenderShader> mLightingShader;
// Post-Procecssing.
UniquePtr<VKIRenderPass> mPostProPass;
UniquePtr<VKIFramebuffer> mPostProFB;
UniquePtr<RenderShader> mPostProShader;
// Blit final render to swapchain.
UniquePtr<RenderShader> mBlitSwapchain;
// Shadow.
UniquePtr<VKIRenderPass> mDirShadowPass;
UniquePtr<VKIRenderPass> mOmniShadowPass;
// Render Stage for updating light probes.
UniquePtr<RenderStageLightProbes> mStageLightProbes;
// If last frame has updated data and we should wait for it
// to be finished before rendering next frame
bool mWaitForUpdate;
};
| 24.728346 | 95 | 0.761662 | [
"render"
] |
9eee5bf3db27a2da698519c258e62a2b00a52571 | 8,723 | c | C | linux-5.2/arch/openrisc/mm/fault.c | TakuKitamura/expirefile-syscall | 2b91994a7fe984e146d090fc7d80fa1a698025aa | [
"MIT"
] | 1 | 2022-01-30T20:01:25.000Z | 2022-01-30T20:01:25.000Z | linux-5.2/arch/openrisc/mm/fault.c | TakuKitamura/expirefile-syscall | 2b91994a7fe984e146d090fc7d80fa1a698025aa | [
"MIT"
] | null | null | null | linux-5.2/arch/openrisc/mm/fault.c | TakuKitamura/expirefile-syscall | 2b91994a7fe984e146d090fc7d80fa1a698025aa | [
"MIT"
] | 1 | 2019-10-11T07:35:58.000Z | 2019-10-11T07:35:58.000Z | // SPDX-License-Identifier: GPL-2.0-or-later
/*
* OpenRISC fault.c
*
* Linux architectural port borrowing liberally from similar works of
* others. All original copyrights apply as per the original source
* declaration.
*
* Modifications for the OpenRISC architecture:
* Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
* Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
*/
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/extable.h>
#include <linux/sched/signal.h>
#include <linux/uaccess.h>
#include <asm/siginfo.h>
#include <asm/signal.h>
#define NUM_TLB_ENTRIES 64
#define TLB_OFFSET(add) (((add) >> PAGE_SHIFT) & (NUM_TLB_ENTRIES-1))
unsigned long pte_misses; /* updated by do_page_fault() */
unsigned long pte_errors; /* updated by do_page_fault() */
/* __PHX__ :: - check the vmalloc_fault in do_page_fault()
* - also look into include/asm-or32/mmu_context.h
*/
volatile pgd_t *current_pgd[NR_CPUS];
extern void die(char *, struct pt_regs *, long);
/*
* This routine handles page faults. It determines the address,
* and the problem, and then passes it off to one of the appropriate
* routines.
*
* If this routine detects a bad access, it returns 1, otherwise it
* returns 0.
*/
asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
unsigned long vector, int write_acc)
{
struct task_struct *tsk;
struct mm_struct *mm;
struct vm_area_struct *vma;
int si_code;
vm_fault_t fault;
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
tsk = current;
/*
* We fault-in kernel-space virtual memory on-demand. The
* 'reference' page table is init_mm.pgd.
*
* NOTE! We MUST NOT take any locks for this case. We may
* be in an interrupt or a critical region, and should
* only copy the information from the master page table,
* nothing more.
*
* NOTE2: This is done so that, when updating the vmalloc
* mappings we don't have to walk all processes pgdirs and
* add the high mappings all at once. Instead we do it as they
* are used. However vmalloc'ed page entries have the PAGE_GLOBAL
* bit set so sometimes the TLB can use a lingering entry.
*
* This verifies that the fault happens in kernel space
* and that the fault was not a protection error.
*/
if (address >= VMALLOC_START &&
(vector != 0x300 && vector != 0x400) &&
!user_mode(regs))
goto vmalloc_fault;
/* If exceptions were enabled, we can reenable them here */
if (user_mode(regs)) {
/* Exception was in userspace: reenable interrupts */
local_irq_enable();
flags |= FAULT_FLAG_USER;
} else {
/* If exception was in a syscall, then IRQ's may have
* been enabled or disabled. If they were enabled,
* reenable them.
*/
if (regs->sr && (SPR_SR_IEE | SPR_SR_TEE))
local_irq_enable();
}
mm = tsk->mm;
si_code = SEGV_MAPERR;
/*
* If we're in an interrupt or have no user
* context, we must not take the fault..
*/
if (in_interrupt() || !mm)
goto no_context;
retry:
down_read(&mm->mmap_sem);
vma = find_vma(mm, address);
if (!vma)
goto bad_area;
if (vma->vm_start <= address)
goto good_area;
if (!(vma->vm_flags & VM_GROWSDOWN))
goto bad_area;
if (user_mode(regs)) {
/*
* accessing the stack below usp is always a bug.
* we get page-aligned addresses so we can only check
* if we're within a page from usp, but that might be
* enough to catch brutal errors at least.
*/
if (address + PAGE_SIZE < regs->sp)
goto bad_area;
}
if (expand_stack(vma, address))
goto bad_area;
/*
* Ok, we have a good vm_area for this memory access, so
* we can handle it..
*/
good_area:
si_code = SEGV_ACCERR;
/* first do some preliminary protection checks */
if (write_acc) {
if (!(vma->vm_flags & VM_WRITE))
goto bad_area;
flags |= FAULT_FLAG_WRITE;
} else {
/* not present */
if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
goto bad_area;
}
/* are we trying to execute nonexecutable area */
if ((vector == 0x400) && !(vma->vm_page_prot.pgprot & _PAGE_EXEC))
goto bad_area;
/*
* If for any reason at all we couldn't handle the fault,
* make sure we exit gracefully rather than endlessly redo
* the fault.
*/
fault = handle_mm_fault(vma, address, flags);
if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
return;
if (unlikely(fault & VM_FAULT_ERROR)) {
if (fault & VM_FAULT_OOM)
goto out_of_memory;
else if (fault & VM_FAULT_SIGSEGV)
goto bad_area;
else if (fault & VM_FAULT_SIGBUS)
goto do_sigbus;
BUG();
}
if (flags & FAULT_FLAG_ALLOW_RETRY) {
/*RGD modeled on Cris */
if (fault & VM_FAULT_MAJOR)
tsk->maj_flt++;
else
tsk->min_flt++;
if (fault & VM_FAULT_RETRY) {
flags &= ~FAULT_FLAG_ALLOW_RETRY;
flags |= FAULT_FLAG_TRIED;
/* No need to up_read(&mm->mmap_sem) as we would
* have already released it in __lock_page_or_retry
* in mm/filemap.c.
*/
goto retry;
}
}
up_read(&mm->mmap_sem);
return;
/*
* Something tried to access memory that isn't in our memory map..
* Fix it, but check if it's kernel or user first..
*/
bad_area:
up_read(&mm->mmap_sem);
bad_area_nosemaphore:
/* User mode accesses just cause a SIGSEGV */
if (user_mode(regs)) {
force_sig_fault(SIGSEGV, si_code, (void __user *)address, tsk);
return;
}
no_context:
/* Are we prepared to handle this kernel fault?
*
* (The kernel has valid exception-points in the source
* when it acesses user-memory. When it fails in one
* of those points, we find it in a table and do a jump
* to some fixup code that loads an appropriate error
* code)
*/
{
const struct exception_table_entry *entry;
__asm__ __volatile__("l.nop 42");
if ((entry = search_exception_tables(regs->pc)) != NULL) {
/* Adjust the instruction pointer in the stackframe */
regs->pc = entry->fixup;
return;
}
}
/*
* Oops. The kernel tried to access some bad page. We'll have to
* terminate things with extreme prejudice.
*/
if ((unsigned long)(address) < PAGE_SIZE)
printk(KERN_ALERT
"Unable to handle kernel NULL pointer dereference");
else
printk(KERN_ALERT "Unable to handle kernel access");
printk(" at virtual address 0x%08lx\n", address);
die("Oops", regs, write_acc);
do_exit(SIGKILL);
/*
* We ran out of memory, or some other thing happened to us that made
* us unable to handle the page fault gracefully.
*/
out_of_memory:
__asm__ __volatile__("l.nop 42");
__asm__ __volatile__("l.nop 1");
up_read(&mm->mmap_sem);
if (!user_mode(regs))
goto no_context;
pagefault_out_of_memory();
return;
do_sigbus:
up_read(&mm->mmap_sem);
/*
* Send a sigbus, regardless of whether we were in kernel
* or user mode.
*/
force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address, tsk);
/* Kernel mode? Handle exceptions or die */
if (!user_mode(regs))
goto no_context;
return;
vmalloc_fault:
{
/*
* Synchronize this task's top level page-table
* with the 'reference' page table.
*
* Use current_pgd instead of tsk->active_mm->pgd
* since the latter might be unavailable if this
* code is executed in a misfortunately run irq
* (like inside schedule() between switch_mm and
* switch_to...).
*/
int offset = pgd_index(address);
pgd_t *pgd, *pgd_k;
pud_t *pud, *pud_k;
pmd_t *pmd, *pmd_k;
pte_t *pte_k;
/*
phx_warn("do_page_fault(): vmalloc_fault will not work, "
"since current_pgd assign a proper value somewhere\n"
"anyhow we don't need this at the moment\n");
phx_mmu("vmalloc_fault");
*/
pgd = (pgd_t *)current_pgd[smp_processor_id()] + offset;
pgd_k = init_mm.pgd + offset;
/* Since we're two-level, we don't need to do both
* set_pgd and set_pmd (they do the same thing). If
* we go three-level at some point, do the right thing
* with pgd_present and set_pgd here.
*
* Also, since the vmalloc area is global, we don't
* need to copy individual PTE's, it is enough to
* copy the pgd pointer into the pte page of the
* root task. If that is there, we'll find our pte if
* it exists.
*/
pud = pud_offset(pgd, address);
pud_k = pud_offset(pgd_k, address);
if (!pud_present(*pud_k))
goto no_context;
pmd = pmd_offset(pud, address);
pmd_k = pmd_offset(pud_k, address);
if (!pmd_present(*pmd_k))
goto bad_area_nosemaphore;
set_pmd(pmd, *pmd_k);
/* Make sure the actual PTE exists as well to
* catch kernel vmalloc-area accesses to non-mapped
* addresses. If we don't do this, this will just
* silently loop forever.
*/
pte_k = pte_offset_kernel(pmd_k, address);
if (!pte_present(*pte_k))
goto no_context;
return;
}
}
| 24.851852 | 74 | 0.683137 | [
"vector"
] |
9ef0442ad1326f0fb60d8e11694aaf850058a7b3 | 7,369 | c | C | Optimization/LevmarAndroid/jni/Thirdparty/clapack/TESTING/EIG/dget36.c | faipaz/Algorithms | 738991d5e4372ef6ba8e489ea867d92ea406b729 | [
"MIT"
] | 48 | 2015-01-28T00:09:49.000Z | 2021-12-09T11:38:59.000Z | Optimization/LevmarAndroid/jni/Thirdparty/clapack/TESTING/EIG/dget36.c | faipaz/Algorithms | 738991d5e4372ef6ba8e489ea867d92ea406b729 | [
"MIT"
] | 8 | 2017-05-30T16:58:39.000Z | 2022-02-22T16:51:34.000Z | ExternalCode/lapack/TESTING/EIG/dget36.c | daniel-anavaino/tinkercell | 7896a7f809a0373ab3c848d25e3691d10a648437 | [
"BSD-3-Clause"
] | 12 | 2015-01-21T12:54:46.000Z | 2022-01-20T03:44:26.000Z | /* dget36.f -- translated by f2c (version 20061008).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
#include "f2c.h"
#include "blaswrap.h"
/* Table of constant values */
static integer c__3 = 3;
static integer c__1 = 1;
static integer c__5 = 5;
static integer c__10 = 10;
static doublereal c_b21 = 0.;
static doublereal c_b22 = 1.;
static integer c__200 = 200;
/* Subroutine */ int dget36_(doublereal *rmax, integer *lmax, integer *ninfo,
integer *knt, integer *nin)
{
/* System generated locals */
integer i__1, i__2;
/* Builtin functions */
integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
e_rsle(void);
double d_sign(doublereal *, doublereal *);
/* Local variables */
integer i__, j, n;
doublereal q[100] /* was [10][10] */, t1[100] /* was [10][10] */,
t2[100] /* was [10][10] */;
integer loc;
doublereal eps, res, tmp[100] /* was [10][10] */;
integer ifst, ilst;
doublereal work[200];
integer info1, info2, ifst1, ifst2, ilst1, ilst2;
extern /* Subroutine */ int dhst01_(integer *, integer *, integer *,
doublereal *, integer *, doublereal *, integer *, doublereal *,
integer *, doublereal *, integer *, doublereal *);
extern doublereal dlamch_(char *);
extern /* Subroutine */ int dlacpy_(char *, integer *, integer *,
doublereal *, integer *, doublereal *, integer *),
dlaset_(char *, integer *, integer *, doublereal *, doublereal *,
doublereal *, integer *), dtrexc_(char *, integer *,
doublereal *, integer *, doublereal *, integer *, integer *,
integer *, doublereal *, integer *);
integer ifstsv;
doublereal result[2];
integer ilstsv;
/* Fortran I/O blocks */
static cilist io___2 = { 0, 0, 0, 0, 0 };
static cilist io___7 = { 0, 0, 0, 0, 0 };
/* -- LAPACK test routine (version 3.1) -- */
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
/* November 2006 */
/* .. Scalar Arguments .. */
/* .. */
/* .. Array Arguments .. */
/* .. */
/* Purpose */
/* ======= */
/* DGET36 tests DTREXC, a routine for moving blocks (either 1 by 1 or */
/* 2 by 2) on the diagonal of a matrix in real Schur form. Thus, DLAEXC */
/* computes an orthogonal matrix Q such that */
/* Q' * T1 * Q = T2 */
/* and where one of the diagonal blocks of T1 (the one at row IFST) has */
/* been moved to position ILST. */
/* The test code verifies that the residual Q'*T1*Q-T2 is small, that T2 */
/* is in Schur form, and that the final position of the IFST block is */
/* ILST (within +-1). */
/* The test matrices are read from a file with logical unit number NIN. */
/* Arguments */
/* ========== */
/* RMAX (output) DOUBLE PRECISION */
/* Value of the largest test ratio. */
/* LMAX (output) INTEGER */
/* Example number where largest test ratio achieved. */
/* NINFO (output) INTEGER array, dimension (3) */
/* NINFO(J) is the number of examples where INFO=J. */
/* KNT (output) INTEGER */
/* Total number of examples tested. */
/* NIN (input) INTEGER */
/* Input logical unit number. */
/* ===================================================================== */
/* .. Parameters .. */
/* .. */
/* .. Local Scalars .. */
/* .. */
/* .. Local Arrays .. */
/* .. */
/* .. External Functions .. */
/* .. */
/* .. External Subroutines .. */
/* .. */
/* .. Intrinsic Functions .. */
/* .. */
/* .. Executable Statements .. */
/* Parameter adjustments */
--ninfo;
/* Function Body */
eps = dlamch_("P");
*rmax = 0.;
*lmax = 0;
*knt = 0;
ninfo[1] = 0;
ninfo[2] = 0;
ninfo[3] = 0;
/* Read input data until N=0 */
L10:
io___2.ciunit = *nin;
s_rsle(&io___2);
do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
do_lio(&c__3, &c__1, (char *)&ifst, (ftnlen)sizeof(integer));
do_lio(&c__3, &c__1, (char *)&ilst, (ftnlen)sizeof(integer));
e_rsle();
if (n == 0) {
return 0;
}
++(*knt);
i__1 = n;
for (i__ = 1; i__ <= i__1; ++i__) {
io___7.ciunit = *nin;
s_rsle(&io___7);
i__2 = n;
for (j = 1; j <= i__2; ++j) {
do_lio(&c__5, &c__1, (char *)&tmp[i__ + j * 10 - 11], (ftnlen)
sizeof(doublereal));
}
e_rsle();
/* L20: */
}
dlacpy_("F", &n, &n, tmp, &c__10, t1, &c__10);
dlacpy_("F", &n, &n, tmp, &c__10, t2, &c__10);
ifstsv = ifst;
ilstsv = ilst;
ifst1 = ifst;
ilst1 = ilst;
ifst2 = ifst;
ilst2 = ilst;
res = 0.;
/* Test without accumulating Q */
dlaset_("Full", &n, &n, &c_b21, &c_b22, q, &c__10);
dtrexc_("N", &n, t1, &c__10, q, &c__10, &ifst1, &ilst1, work, &info1);
i__1 = n;
for (i__ = 1; i__ <= i__1; ++i__) {
i__2 = n;
for (j = 1; j <= i__2; ++j) {
if (i__ == j && q[i__ + j * 10 - 11] != 1.) {
res += 1. / eps;
}
if (i__ != j && q[i__ + j * 10 - 11] != 0.) {
res += 1. / eps;
}
/* L30: */
}
/* L40: */
}
/* Test with accumulating Q */
dlaset_("Full", &n, &n, &c_b21, &c_b22, q, &c__10);
dtrexc_("V", &n, t2, &c__10, q, &c__10, &ifst2, &ilst2, work, &info2);
/* Compare T1 with T2 */
i__1 = n;
for (i__ = 1; i__ <= i__1; ++i__) {
i__2 = n;
for (j = 1; j <= i__2; ++j) {
if (t1[i__ + j * 10 - 11] != t2[i__ + j * 10 - 11]) {
res += 1. / eps;
}
/* L50: */
}
/* L60: */
}
if (ifst1 != ifst2) {
res += 1. / eps;
}
if (ilst1 != ilst2) {
res += 1. / eps;
}
if (info1 != info2) {
res += 1. / eps;
}
/* Test for successful reordering of T2 */
if (info2 != 0) {
++ninfo[info2];
} else {
if ((i__1 = ifst2 - ifstsv, abs(i__1)) > 1) {
res += 1. / eps;
}
if ((i__1 = ilst2 - ilstsv, abs(i__1)) > 1) {
res += 1. / eps;
}
}
/* Test for small residual, and orthogonality of Q */
dhst01_(&n, &c__1, &n, tmp, &c__10, t2, &c__10, q, &c__10, work, &c__200,
result);
res = res + result[0] + result[1];
/* Test for T2 being in Schur form */
loc = 1;
L70:
if (t2[loc + 1 + loc * 10 - 11] != 0.) {
/* 2 by 2 block */
if (t2[loc + (loc + 1) * 10 - 11] == 0. || t2[loc + loc * 10 - 11] !=
t2[loc + 1 + (loc + 1) * 10 - 11] || d_sign(&c_b22, &t2[loc +
(loc + 1) * 10 - 11]) == d_sign(&c_b22, &t2[loc + 1 + loc *
10 - 11])) {
res += 1. / eps;
}
i__1 = n;
for (i__ = loc + 2; i__ <= i__1; ++i__) {
if (t2[i__ + loc * 10 - 11] != 0.) {
res += 1. / res;
}
if (t2[i__ + (loc + 1) * 10 - 11] != 0.) {
res += 1. / res;
}
/* L80: */
}
loc += 2;
} else {
/* 1 by 1 block */
i__1 = n;
for (i__ = loc + 1; i__ <= i__1; ++i__) {
if (t2[i__ + loc * 10 - 11] != 0.) {
res += 1. / res;
}
/* L90: */
}
++loc;
}
if (loc < n) {
goto L70;
}
if (res > *rmax) {
*rmax = res;
*lmax = *knt;
}
goto L10;
/* End of DGET36 */
} /* dget36_ */
| 25.410345 | 78 | 0.514588 | [
"object"
] |
9ef117f82f56c222437e0191018ebbd5aafb84eb | 1,979 | h | C | third_party/WebKit/Source/core/events/PromiseRejectionEvent.h | maidiHaitai/haitaibrowser | a232a56bcfb177913a14210e7733e0ea83a6b18d | [
"BSD-3-Clause"
] | 1 | 2020-09-15T08:43:34.000Z | 2020-09-15T08:43:34.000Z | third_party/WebKit/Source/core/events/PromiseRejectionEvent.h | maidiHaitai/haitaibrowser | a232a56bcfb177913a14210e7733e0ea83a6b18d | [
"BSD-3-Clause"
] | null | null | null | third_party/WebKit/Source/core/events/PromiseRejectionEvent.h | maidiHaitai/haitaibrowser | a232a56bcfb177913a14210e7733e0ea83a6b18d | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PromiseRejectionEvent_h
#define PromiseRejectionEvent_h
#include "bindings/core/v8/DOMWrapperWorld.h"
#include "bindings/core/v8/ScopedPersistent.h"
#include "bindings/core/v8/ScriptPromise.h"
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/ScriptValue.h"
#include "core/CoreExport.h"
#include "core/events/Event.h"
#include "core/events/PromiseRejectionEventInit.h"
namespace blink {
class CORE_EXPORT PromiseRejectionEvent final : public Event {
DEFINE_WRAPPERTYPEINFO();
public:
static PromiseRejectionEvent* create()
{
return new PromiseRejectionEvent;
}
static PromiseRejectionEvent* create(ScriptState* state, const AtomicString& type, const PromiseRejectionEventInit& initializer)
{
return new PromiseRejectionEvent(state, type, initializer);
}
ScriptValue reason(ScriptState*) const;
ScriptPromise promise(ScriptState*) const;
void setWrapperReference(v8::Isolate*, const v8::Persistent<v8::Object>&);
const AtomicString& interfaceName() const override;
// PromiseRejectionEvents are similar to ErrorEvents in that they can't be
// observed across different worlds.
bool canBeDispatchedInWorld(const DOMWrapperWorld&) const override;
DECLARE_VIRTUAL_TRACE();
private:
PromiseRejectionEvent();
PromiseRejectionEvent(ScriptState*, const AtomicString&, const PromiseRejectionEventInit&);
~PromiseRejectionEvent() override;
static void didCollectPromise(const v8::WeakCallbackInfo<PromiseRejectionEvent>&);
static void didCollectReason(const v8::WeakCallbackInfo<PromiseRejectionEvent>&);
RefPtr<ScriptState> m_scriptState;
ScopedPersistent<v8::Value> m_promise;
ScopedPersistent<v8::Value> m_reason;
};
} // namespace blink
#endif // PromiseRejectionEvent_h
| 32.983333 | 132 | 0.766549 | [
"object"
] |
9ef1f1961c56f5578be2a072ad62ee54109fea3e | 3,185 | h | C | src/MQ.h | nnstreamer/aitt | 00b7331ca17fe1943fedf4387d5d47fdfa8496c3 | [
"Apache-2.0"
] | 9 | 2022-01-18T02:34:09.000Z | 2022-03-24T10:32:38.000Z | src/MQ.h | nnstreamer/aitt | 00b7331ca17fe1943fedf4387d5d47fdfa8496c3 | [
"Apache-2.0"
] | null | null | null | src/MQ.h | nnstreamer/aitt | 00b7331ca17fe1943fedf4387d5d47fdfa8496c3 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2021-2022 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <mosquitto.h>
#include <functional>
#include <map>
#include <mutex>
#include <string>
#include <utility>
#include <vector>
#include "MSG.h"
#define MQTT_LOCALHOST "127.0.0.1"
#define MQTT_PORT 1883
#define EMPTY_WILL ""
namespace aitt {
class MQ {
public:
enum QoS : int {
AT_MOST_ONCE = 0, // Fire and forget
AT_LEAST_ONCE = 1, // Receiver is able to receive multiple times
EXACTLY_ONCE = 2, // Receiver only receives exactly once
};
using SubscribeCallback =
std::function<void(MSG *, const std::string &topic, const void *, const int, void *)>;
explicit MQ(const std::string &id, bool clear_session = false);
virtual ~MQ(void);
static bool CompareTopic(const std::string &left, const std::string &right);
void Connect(const std::string &host = MQTT_LOCALHOST, int port = MQTT_PORT,
const std::string &willtopic = EMPTY_WILL, const void *willmsg = nullptr,
size_t szmsg = 0, MQ::QoS qos = QoS::AT_MOST_ONCE, bool retain = false);
void Disconnect(void);
void Publish(const std::string &topic, const void *data, const size_t datalen,
MQ::QoS qos = QoS::AT_MOST_ONCE, bool retain = false);
void PublishWithReply(const std::string &topic, const void *data, const size_t datalen,
MQ::QoS qos, bool retain, const std::string &reply_topic, const std::string &correlation);
void SendReply(MSG *msg, const void *data, const size_t datalen, MQ::QoS qos, bool retain);
void *Subscribe(const std::string &topic, const SubscribeCallback &cb, void *cbdata = nullptr,
MQ::QoS qos = QoS::AT_MOST_ONCE);
void *Unsubscribe(void *handle);
private:
struct SubscribeData {
SubscribeData(const std::string topic, const SubscribeCallback &cb, void *cbdata);
virtual ~SubscribeData(void) = default;
std::string topic;
SubscribeCallback cb;
void *cbdata;
};
static void MessageCallback(mosquitto *, void *, const mosquitto_message *,
const mosquitto_property *);
void InvokeCallback(const mosquitto_message *msg, const mosquitto_property *props);
static const std::string REPLY_SEQUENCE_NUM_KEY;
static const std::string REPLY_IS_END_SEQUENCE_KEY;
mosquitto *handle;
const int keep_alive;
std::vector<SubscribeData *> subscribers;
std::vector<SubscribeData *>::iterator subscriber_iterator;
bool subscriber_iterator_updated;
std::recursive_mutex subscribers_lock;
};
} // namespace aitt
| 36.193182 | 100 | 0.696075 | [
"vector"
] |
9ef4de4c4243a90517e75693165dc21e9074e7ca | 4,798 | h | C | src/triangle.h | Simponic/Simple3DEngine | 2dbca92adb5cc902411b716bbdba395375ad51f5 | [
"MIT"
] | 2 | 2020-08-05T17:53:06.000Z | 2020-08-07T03:09:37.000Z | src/triangle.h | Simponic/Simple3DEngine | 2dbca92adb5cc902411b716bbdba395375ad51f5 | [
"MIT"
] | null | null | null | src/triangle.h | Simponic/Simple3DEngine | 2dbca92adb5cc902411b716bbdba395375ad51f5 | [
"MIT"
] | 1 | 2021-11-23T21:31:04.000Z | 2021-11-23T21:31:04.000Z | #include "fixed.h"
#include "defs.h"
#include "vertex.h"
#include "plane.h"
#include "color.h"
#include <math.h>
#ifndef TRIANGLE_H
#define TRIANGLE_H
typedef struct TRIANGLE {
int v0;
int v1;
int v2;
COLOR color;
} TRIANGLE;
static inline TRIANGLE createTriangle(int v0, int v1, int v2, COLOR color) {
// Create a triangle from data
TRIANGLE temp;
temp.v0 = v0;
temp.v1 = v1;
temp.v2 = v2;
temp.color = color;
return temp;
}
static inline VERTEX computeNormal(VERTEX *vertices, TRIANGLE *triangle) {
// Use cross product to compute a normal vector to a triangle
VERTEX normal, v1, v2;
// Compute vectors for cross product
v1.x = (vertices + triangle->v1)->x - (vertices + triangle->v0)->x;
v1.y = (vertices + triangle->v1)->y - (vertices + triangle->v0)->y;
v1.z = (vertices + triangle->v1)->z - (vertices + triangle->v0)->z;
v2.x = (vertices + triangle->v2)->x - (vertices + triangle->v0)->x;
v2.y = (vertices + triangle->v2)->y - (vertices + triangle->v0)->y;
v2.z = (vertices + triangle->v2)->z - (vertices + triangle->v0)->z;
// Compute cross product
normal.x = fixed_multiply(v1.y, v2.z) - fixed_multiply(v1.z, v2.y);
normal.y = fixed_multiply(v1.z, v2.x) - fixed_multiply(v1.x, v2.z);
normal.z = fixed_multiply(v1.x, v2.y) - fixed_multiply(v1.y, v2.x);
return normal;
}
static inline void drawTriangle(POINT *v1, POINT *v2, POINT *v3, COLOR *clr, SDL_Renderer *renderer) {
// Draw a triangle to screen from data
int x1, x2, x3, y1, y2, y3;
SDL_SetRenderDrawColor(renderer, clr->red, clr->green, clr->blue, 255);
x1 = (v1->x >> FIX_SHIFT) + WINDOW_WIDTH / 2;
x2 = (v2->x >> FIX_SHIFT) + WINDOW_WIDTH / 2;
x3 = (v3->x >> FIX_SHIFT) + WINDOW_WIDTH / 2;
y1 = WINDOW_HEIGHT / 2 - (v1->y >> FIX_SHIFT) - 1;
y2 = WINDOW_HEIGHT / 2 - (v2->y >> FIX_SHIFT) - 1;
y3 = WINDOW_HEIGHT / 2 - (v3->y >> FIX_SHIFT) - 1;
SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
SDL_RenderDrawLine(renderer, x1, y1, x3, y3);
SDL_RenderDrawLine(renderer, x2, y2, x3, y3);
}
static inline void fillBottomFlatTriangle(POINT *v1, POINT *v2, POINT *v3, COLOR *clr, SDL_Renderer *renderer) {
// Ported from sunshine2k.de
SDL_SetRenderDrawColor(renderer, clr->red, clr->green, clr->blue, 255);
FIXED iSlope1 = fixed_divide(v2->x - v1->x, v2->y - v1->y);
FIXED iSlope2 = fixed_divide(v3->x - v1->x, v3->y - v1->y);
FIXED curx1 = v1->x;
FIXED curx2 = curx1;
int scanline;
for (int scanlineY = ((v1->y + (1 << FIX_SHIFT)) >> FIX_SHIFT); scanlineY <= (v2->y >> FIX_SHIFT); scanlineY++) {
scanline = WINDOW_HEIGHT / 2 - scanlineY - 1;
SDL_RenderDrawLine(renderer, ((curx1 >> FIX_SHIFT) + WINDOW_WIDTH / 2),
scanline, ((curx2 >> FIX_SHIFT) + WINDOW_WIDTH / 2), scanline
);
curx1 += iSlope1;
curx2 += iSlope2;
}
}
static inline void fillTopFlatTriangle(POINT *v1, POINT *v2, POINT *v3, COLOR *clr, SDL_Renderer *renderer) {
// Ported from sunshine2k.de
SDL_SetRenderDrawColor(renderer, clr->red, clr->green, clr->blue, 255);
FIXED iSlope1 = fixed_divide(v3->x - v1->x, v3->y - v1->y);
FIXED iSlope2 = fixed_divide(v3->x - v2->x, v3->y - v2->y);
FIXED curx1 = v3->x;
FIXED curx2 = curx1;
int scanline;
for (int scanlineY = ((v3->y - (1 << FIX_SHIFT)) >> FIX_SHIFT); scanlineY > (v1->y >> FIX_SHIFT); scanlineY--) {
scanline = WINDOW_HEIGHT / 2 - scanlineY - 1;
SDL_RenderDrawLine(renderer, ((curx1 >> FIX_SHIFT) + WINDOW_WIDTH / 2),
scanline, ((curx2 >> FIX_SHIFT) + WINDOW_WIDTH / 2), scanline
);
curx1 -= iSlope1;
curx2 -= iSlope2;
}
}
static inline void drawFilledTriangle(POINT *v1, POINT *v2, POINT *v3, COLOR *clr, SDL_Renderer *renderer) {
// Draw a filled triangle at points
// Sort the vertex points
POINT p1, p2, p3;
p1 = *v1;
p2 = *v2;
p3 = *v3;
if (p1.y > p2.y) {
swapPoint(&p1, &p2);
}
if (p1.y > p3.y) {
swapPoint(&p1, &p3);
}
if (p2.y > p3.y) {
swapPoint(&p2, &p3);
}
// Check if bottom of triangle is flat
if (p2.y == p3.y) {
fillBottomFlatTriangle(&p1, &p2, &p3, clr, renderer);
}
// Check if top of triangle is flat
else if (p1.y == p2.y) {
fillTopFlatTriangle(&p1, &p2, &p3, clr, renderer);
}
else {
// General case where neither top or bottom is flat
POINT p4 = createPoint(
p1.x + fixed_multiply(fixed_divide(p2.y - p1.y, p3.y - p1.y), (p3.x - p1.x))
,p2.y
);
fillBottomFlatTriangle(&p1, &p2, &p4, clr, renderer);
fillTopFlatTriangle(&p2, &p4, &p3, clr, renderer);
}
}
#endif // TRIANGLE_H
| 34.271429 | 117 | 0.598583 | [
"vector"
] |
9ef89a0b7cc777c97610e96c4a0e49e0d0e3a9db | 4,885 | h | C | src/nnet3/nnet-chain-diagnostics.h | tornado12345/kaldi | 498b25db122ec68a96aee154b9d829030adfae4c | [
"Apache-2.0"
] | null | null | null | src/nnet3/nnet-chain-diagnostics.h | tornado12345/kaldi | 498b25db122ec68a96aee154b9d829030adfae4c | [
"Apache-2.0"
] | null | null | null | src/nnet3/nnet-chain-diagnostics.h | tornado12345/kaldi | 498b25db122ec68a96aee154b9d829030adfae4c | [
"Apache-2.0"
] | null | null | null | // nnet3/nnet-chain-diagnostics.h
// Copyright 2015 Johns Hopkins University (author: Daniel Povey)
// See ../../COPYING for clarification regarding multiple authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
// WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
// MERCHANTABLITY OR NON-INFRINGEMENT.
// See the Apache 2 License for the specific language governing permissions and
// limitations under the License.
#ifndef KALDI_NNET3_NNET_CHAIN_DIAGNOSTICS_H_
#define KALDI_NNET3_NNET_CHAIN_DIAGNOSTICS_H_
#include "nnet3/nnet-example.h"
#include "nnet3/nnet-computation.h"
#include "nnet3/nnet-compute.h"
#include "nnet3/nnet-optimize.h"
#include "nnet3/nnet-chain-example.h"
#include "nnet3/nnet-diagnostics.h"
#include "chain/chain-training.h"
#include "chain/chain-den-graph.h"
namespace kaldi {
namespace nnet3 {
struct ChainObjectiveInfo {
double tot_weight;
double tot_like;
double tot_l2_term;
double tot_lwf_term;
ChainObjectiveInfo(): tot_weight(0.0),
tot_like(0.0),
tot_l2_term(0.0),
tot_lwf_term(0.0) { }
};
/** This class is for computing objective-function values in a nnet3+chain
setup, for diagnostics. It also supports computing model derivatives.
Note: if the --xent-regularization option is nonzero, the cross-entropy
objective will be computed, and displayed when you call PrintTotalStats(),
but it will not contribute to model derivatives (there is no code to compute
the regularized objective function, and anyway it's not clear that we really
need this regularization in the combination phase).
*/
class NnetChainComputeProb {
public:
// does not store a reference to 'config' but does store one to 'nnet'.
NnetChainComputeProb(const NnetComputeProbOptions &nnet_config,
const chain::ChainTrainingOptions &chain_config,
const fst::StdVectorFst &den_fst,
const Nnet &nnet);
// This version of the constructor may only be called if
// nnet_config.store_component_stats == true and nnet_config.compute_deriv ==
// false; it means it will store the component stats in 'nnet'. In this case
// you should call ZeroComponentStats(nnet) first if you want the stats to be
// zeroed first.
NnetChainComputeProb(const NnetComputeProbOptions &nnet_config,
const chain::ChainTrainingOptions &chain_config,
const fst::StdVectorFst &den_fst,
Nnet *nnet);
// Reset the likelihood stats, and the derivative stats (if computed).
void Reset();
// compute objective on one minibatch.
void Compute(const NnetChainExample &chain_eg);
// Prints out the final stats, and return true if there was a nonzero count.
bool PrintTotalStats() const;
// returns the objective-function info for this output name (e.g. "output"),
// or NULL if there is no such info.
const ChainObjectiveInfo *GetObjective(const std::string &output_name) const;
// This function returns the total objective over all output nodes recorded here, and
// outputs to 'tot_weight' the total weight (typically the number of frames)
// corresponding to it.
double GetTotalObjective(double *tot_weight) const;
// if config.compute_deriv == true, returns a reference to the
// computed derivative. Otherwise crashes.
const Nnet &GetDeriv() const;
~NnetChainComputeProb();
private:
void ProcessOutputs(const NnetChainExample &chain_eg,
NnetComputer *computer);
NnetComputeProbOptions nnet_config_;
chain::ChainTrainingOptions chain_config_;
chain::DenominatorGraph den_graph_;
const Nnet &nnet_;
CachingOptimizingCompiler compiler_;
bool deriv_nnet_owned_;
Nnet *deriv_nnet_;
int32 num_minibatches_processed_; // this is only for diagnostics
unordered_map<std::string, ChainObjectiveInfo, StringHasher> objf_info_;
};
/// This function zeros the stored component-level stats in the nnet using
/// ZeroComponentStats(), then recomputes them with the supplied egs. It
/// affects batch-norm, for instance. See also the version of RecomputeStats
/// declared in nnet-utils.h.
void RecomputeStats(const std::vector<NnetChainExample> &egs,
const chain::ChainTrainingOptions &chain_config,
const fst::StdVectorFst &den_fst,
Nnet *nnet);
} // namespace nnet3
} // namespace kaldi
#endif // KALDI_NNET3_NNET_CHAIN_DIAGNOSTICS_H_
| 37.576923 | 87 | 0.71914 | [
"vector",
"model"
] |
9ef956ed75e70ce60cfc7360038efd66b2c39c65 | 8,088 | h | C | Source/Urho3D/Scene/SceneEvents.h | evolarium/Urho3D | f1cb469a34c13c56e9d6a9a75c38539cf2de8bd2 | [
"BSD-2-Clause",
"Apache-2.0"
] | 1 | 2016-09-19T16:08:51.000Z | 2016-09-19T16:08:51.000Z | Source/Urho3D/Scene/SceneEvents.h | fireword/Urho3D | 180936cebdf6bdcbb6eb74a0959f5616e208ca5d | [
"BSD-2-Clause",
"Apache-2.0"
] | null | null | null | Source/Urho3D/Scene/SceneEvents.h | fireword/Urho3D | 180936cebdf6bdcbb6eb74a0959f5616e208ca5d | [
"BSD-2-Clause",
"Apache-2.0"
] | null | null | null | //
// Copyright (c) 2008-2016 the Urho3D project.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#pragma once
#include "../Core/Object.h"
namespace Urho3D
{
/// Variable timestep scene update.
URHO3D_EVENT(E_SCENEUPDATE, SceneUpdate)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_TIMESTEP, TimeStep); // float
}
/// Scene subsystem update.
URHO3D_EVENT(E_SCENESUBSYSTEMUPDATE, SceneSubsystemUpdate)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_TIMESTEP, TimeStep); // float
}
/// Scene transform smoothing update.
URHO3D_EVENT(E_UPDATESMOOTHING, UpdateSmoothing)
{
URHO3D_PARAM(P_CONSTANT, Constant); // float
URHO3D_PARAM(P_SQUAREDSNAPTHRESHOLD, SquaredSnapThreshold); // float
}
/// Scene drawable update finished. Custom animation (eg. IK) can be done at this point.
URHO3D_EVENT(E_SCENEDRAWABLEUPDATEFINISHED, SceneDrawableUpdateFinished)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_TIMESTEP, TimeStep); // float
}
/// SmoothedTransform target position changed.
URHO3D_EVENT(E_TARGETPOSITION, TargetPositionChanged)
{
}
/// SmoothedTransform target position changed.
URHO3D_EVENT(E_TARGETROTATION, TargetRotationChanged)
{
}
/// Scene attribute animation update.
URHO3D_EVENT(E_ATTRIBUTEANIMATIONUPDATE, AttributeAnimationUpdate)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_TIMESTEP, TimeStep); // float
}
/// Attribute animation added to object animation.
URHO3D_EVENT(E_ATTRIBUTEANIMATIONADDED, AttributeAnimationAdded)
{
URHO3D_PARAM(P_OBJECTANIMATION, ObjectAnimation); // Object animation pointer
URHO3D_PARAM(P_ATTRIBUTEANIMATIONNAME, AttributeAnimationName); // String
}
/// Attribute animation removed from object animation.
URHO3D_EVENT(E_ATTRIBUTEANIMATIONREMOVED, AttributeAnimationRemoved)
{
URHO3D_PARAM(P_OBJECTANIMATION, ObjectAnimation); // Object animation pointer
URHO3D_PARAM(P_ATTRIBUTEANIMATIONNAME, AttributeAnimationName); // String
}
/// Variable timestep scene post-update.
URHO3D_EVENT(E_SCENEPOSTUPDATE, ScenePostUpdate)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_TIMESTEP, TimeStep); // float
}
/// Asynchronous scene loading progress.
URHO3D_EVENT(E_ASYNCLOADPROGRESS, AsyncLoadProgress)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_PROGRESS, Progress); // float
URHO3D_PARAM(P_LOADEDNODES, LoadedNodes); // int
URHO3D_PARAM(P_TOTALNODES, TotalNodes); // int
URHO3D_PARAM(P_LOADEDRESOURCES, LoadedResources); // int
URHO3D_PARAM(P_TOTALRESOURCES, TotalResources); // int
};
/// Asynchronous scene loading finished.
URHO3D_EVENT(E_ASYNCLOADFINISHED, AsyncLoadFinished)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
};
/// A child node has been added to a parent node.
URHO3D_EVENT(E_NODEADDED, NodeAdded)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_PARENT, Parent); // Node pointer
URHO3D_PARAM(P_NODE, Node); // Node pointer
}
/// A child node is about to be removed from a parent node.
URHO3D_EVENT(E_NODEREMOVED, NodeRemoved)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_PARENT, Parent); // Node pointer
URHO3D_PARAM(P_NODE, Node); // Node pointer
}
/// A component has been created to a node.
URHO3D_EVENT(E_COMPONENTADDED, ComponentAdded)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_NODE, Node); // Node pointer
URHO3D_PARAM(P_COMPONENT, Component); // Component pointer
}
/// A component is about to be removed from a node.
URHO3D_EVENT(E_COMPONENTREMOVED, ComponentRemoved)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_NODE, Node); // Node pointer
URHO3D_PARAM(P_COMPONENT, Component); // Component pointer
}
/// A node's name has changed.
URHO3D_EVENT(E_NODENAMECHANGED, NodeNameChanged)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_NODE, Node); // Node pointer
}
/// A node's enabled state has changed.
URHO3D_EVENT(E_NODEENABLEDCHANGED, NodeEnabledChanged)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_NODE, Node); // Node pointer
}
/// A node's tag has been added.
URHO3D_EVENT(E_NODETAGADDED, NodeTagAdded)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_NODE, Node); // Node pointer
URHO3D_PARAM(P_TAG, Tag); // String tag
}
/// A node's tag has been removed.
URHO3D_EVENT(E_NODETAGREMOVED, NodeTagRemoved)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_NODE, Node); // Node pointer
URHO3D_PARAM(P_TAG, Tag); // String tag
}
/// A component's enabled state has changed.
URHO3D_EVENT(E_COMPONENTENABLEDCHANGED, ComponentEnabledChanged)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_NODE, Node); // Node pointer
URHO3D_PARAM(P_COMPONENT, Component); // Component pointer
}
/// A serializable's temporary state has changed.
URHO3D_EVENT(E_TEMPORARYCHANGED, TemporaryChanged)
{
URHO3D_PARAM(P_SERIALIZABLE, Serializable); // Serializable pointer
}
/// A node (and its children and components) has been cloned.
URHO3D_EVENT(E_NODECLONED, NodeCloned)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_NODE, Node); // Node pointer
URHO3D_PARAM(P_CLONENODE, CloneNode); // Node pointer
}
/// A component has been cloned.
URHO3D_EVENT(E_COMPONENTCLONED, ComponentCloned)
{
URHO3D_PARAM(P_SCENE, Scene); // Scene pointer
URHO3D_PARAM(P_COMPONENT, Component); // Component pointer
URHO3D_PARAM(P_CLONECOMPONENT, CloneComponent); // Component pointer
}
/// A network attribute update from the server has been intercepted.
URHO3D_EVENT(E_INTERCEPTNETWORKUPDATE, InterceptNetworkUpdate)
{
URHO3D_PARAM(P_SERIALIZABLE, Serializable); // Serializable pointer
URHO3D_PARAM(P_TIMESTAMP, TimeStamp); // unsigned (0-255)
URHO3D_PARAM(P_INDEX, Index); // unsigned
URHO3D_PARAM(P_NAME, Name); // String
URHO3D_PARAM(P_VALUE, Value); // Variant
}
}
| 37.444444 | 96 | 0.660485 | [
"object",
"transform"
] |
9efdf9e82b2c639fa8d4de3aa97cee48f407c572 | 2,694 | h | C | src/src/Share/ShareLib/LinuxPublic/ACE_wrappers/Kokyu/Dispatch_Deferrer.h | 549654033/RDHelp | 0f5f9c7d098635c7216713d7137c845c0d999226 | [
"MIT"
] | 2 | 2020-05-20T05:16:34.000Z | 2020-05-20T05:19:19.000Z | src/src/Share/ShareLib/LinuxPublic/ACE_wrappers/Kokyu/Dispatch_Deferrer.h | jimxie2012/RDHelp | 0f5f9c7d098635c7216713d7137c845c0d999226 | [
"MIT"
] | null | null | null | src/src/Share/ShareLib/LinuxPublic/ACE_wrappers/Kokyu/Dispatch_Deferrer.h | jimxie2012/RDHelp | 0f5f9c7d098635c7216713d7137c845c0d999226 | [
"MIT"
] | 4 | 2020-05-20T01:50:16.000Z | 2021-08-29T13:48:25.000Z | /* -*- C++ -*- */
/**
* @file Dispatch_Deferrer.h
*
* $Id: Dispatch_Deferrer.h 80826 2008-03-04 14:51:23Z wotte $
*
* @author Bryan Thrall (thrall@cse.wustl.edu)
*
*/
#ifndef DISPATCH_DEFERRER_H
#define DISPATCH_DEFERRER_H
#include /**/ "ace/pre.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "kokyu_export.h"
#include "Kokyu_defs.h"
#include "ace/Event_Handler.h"
#include "ace/Thread_Mutex.h"
#include "ace/Synch_T.h"
#include "ace/Message_Block.h"
#include "ace/Message_Queue.h"
#include "ace/Reactor.h"
#include "ace/Map.h"
namespace Kokyu
{
class Dispatch_Task; //forward decl
class Dispatch_Queue_Item; //forward decl
/**
* @class Dispatch_Deferrer
*
* @brief Part of the Release Guard protocol. When a Dispatch_Command
* needs to be dispatched later rather than when dispatch_i() is
* called on the Default_Dispatcher_Impl, it is passed to this
* object. When the appropriate time to dispatch the Dispatch_Command
* comes (last release time + period), this object calls enqueue() on
* the Dispatcher_Task.
*/
class Dispatch_Deferrer : public ACE_Event_Handler
{
public:
Dispatch_Deferrer();
//Default constructor
~Dispatch_Deferrer();
//Destructor
int init(const Dispatch_Deferrer_Attributes& attr);
int dispatch (Dispatch_Queue_Item *qitem);
virtual int handle_timeout (const ACE_Time_Value ¤t_time,
const void *act = 0);
//TODO: what if need higher resolution timers?
private:
ACE_Deadline_Message_Strategy msg_strat_;
///Stores the Dispatch_Commands in earliest-release-time order,
///until they are dispatched. I decided to use an
///ACE_Dynamic_Message_Queue because it supports deadline
///ordering. This decision is also good because we can simply store
///the Dispatch_Queue_Item given to us by the
///Default_Dispatcher_Impl rather than allocate some structure to
///hold the Dispatch_Command and QoSDescriptor.
ACE_Dynamic_Message_Queue<ACE_SYNCH> rgq_;
//Stores timer_ids from the Reactor (longs) using the
//Dispatch_Queue_Item the timer is for as the key. Used to
//cancel timers if they expire and are enqueued before the
//callback happens.
typedef ACE_Map_Manager<Dispatch_Queue_Item*,long,ACE_Thread_Mutex> Timer_Map;
Timer_Map timers_;
///Manages timers for the Dispatch_Commands
ACE_Reactor react_;
Dispatcher_Task* task_;
};
} //namespace Kokyu
#if defined (__ACE_INLINE__)
#include "Dispatch_Deferrer.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif //DISPATCH_DEFERRER_H
| 28.0625 | 81 | 0.716036 | [
"object"
] |
9ae3e93a9d86dd839a1827b3b9c86d1fdec98633 | 1,540 | h | C | src/architecture/PortedDevice.h | hkustliqi/SuperSim | 7cff887d485b784c99b37b78a7adaedb4fde8da6 | [
"Apache-2.0"
] | null | null | null | src/architecture/PortedDevice.h | hkustliqi/SuperSim | 7cff887d485b784c99b37b78a7adaedb4fde8da6 | [
"Apache-2.0"
] | null | null | null | src/architecture/PortedDevice.h | hkustliqi/SuperSim | 7cff887d485b784c99b37b78a7adaedb4fde8da6 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2016 Hewlett Packard Enterprise Development LP
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ARCHITECTURE_PORTEDDEVICE_H_
#define ARCHITECTURE_PORTEDDEVICE_H_
#include <prim/prim.h>
#include <vector>
#include "network/Channel.h"
class PortedDevice {
public:
PortedDevice(u32 _id, const std::vector<u32>& _address, u32 _numPorts,
u32 _numVcs);
virtual ~PortedDevice();
u32 id() const;
const std::vector<u32>& address() const;
u32 numPorts() const;
u32 numVcs() const;
u32 vcIndex(u32 _port, u32 _vc) const;
void vcIndexInv(u32 _index, u32* _port, u32* _vc) const;
virtual void setInputChannel(u32 _port, Channel* _channel) = 0;
virtual Channel* getInputChannel(u32 _port) const = 0;
virtual void setOutputChannel(u32 port, Channel* _channel) = 0;
virtual Channel* getOutputChannel(u32 _port) const = 0;
protected:
const u32 id_;
const std::vector<u32> address_;
const u32 numPorts_;
const u32 numVcs_;
};
#endif // ARCHITECTURE_PORTEDDEVICE_H_
| 29.056604 | 75 | 0.733117 | [
"vector"
] |
9ae48b4c50b3497a51e5cb485301965e5b490b8f | 497 | c | C | kungfu/condition/burning.c | afeizh/mud | 3a605483a38dd215e477d340c3f12387b9372fbe | [
"MIT"
] | 69 | 2018-03-08T18:24:44.000Z | 2022-02-24T13:43:53.000Z | kungfu/condition/burning.c | afeizh/mud | 3a605483a38dd215e477d340c3f12387b9372fbe | [
"MIT"
] | 3 | 2019-04-24T12:21:19.000Z | 2021-03-28T23:34:58.000Z | kungfu/condition/burning.c | afeizh/mud | 3a605483a38dd215e477d340c3f12387b9372fbe | [
"MIT"
] | 33 | 2017-12-23T05:06:58.000Z | 2021-08-16T02:42:59.000Z | // burning.c
inherit F_CLEAN_UP;
int update_condition(object me, int duration)
{
int count;
if (me->cost_craze(100) < 100)
{
if (! me->query_temp("burning_up"))
return 0;
tell_object(me, "你的心情渐渐的平息了。\n");
count = me->query_temp("burning_up");
me->add_temp("apply/attack", -count);
me->delete_temp("burning_up");
return 0;
}
return 1;
}
| 21.608696 | 53 | 0.474849 | [
"object"
] |
9ae985372b3a45b45157994f97972590c513a731 | 830 | h | C | Alchemy/Classes/Object/Alchemy/Flame.h | kkh029/Alchemy | ed3d96452508b6cf5680392028bef409dd8d78f1 | [
"Apache-2.0"
] | null | null | null | Alchemy/Classes/Object/Alchemy/Flame.h | kkh029/Alchemy | ed3d96452508b6cf5680392028bef409dd8d78f1 | [
"Apache-2.0"
] | 1 | 2017-02-10T03:54:29.000Z | 2017-02-10T03:54:29.000Z | Alchemy/Classes/Object/Alchemy/Flame.h | kkh029/Alchemy | ed3d96452508b6cf5680392028bef409dd8d78f1 | [
"Apache-2.0"
] | null | null | null | //
// Flame.h
// Alchemy
//
// Created by Kyounghwan on 2014. 3. 1..
//
//
#ifndef __Alchemy__Flame__
#define __Alchemy__Flame__
#include "Common.h"
#include "../Alchemy.h"
#include "../Monster.h"
class Flame : public Alchemy
{
public:
Flame(unsigned char index);
Flame(string name);
~Flame();
static Alchemy* create(PEObject* obj);
bool PE_update(unsigned int flag);
void PE_initAnimation(void);
private:
int m_bulletFireTime;
int isAttack;
Size m_winSize;
Vec2 field_index;
std::vector<Sprite*> m_bullets;
Sprite* FireBullet();
SpriteBatchNode* batch_bullet;
SpriteBatchNode* batch_fire;
void OnEndOfBullet(Ref* object);
void OnEndOfFire(Ref* object);
int bullet_time_count;
int bullet_time_last;
};
#endif /* defined(__Alchemy__Flame__) */
| 18.444444 | 42 | 0.675904 | [
"object",
"vector"
] |
9aebb6cbc65fd37aa2b06267c3ebede8ecc2c210 | 1,367 | h | C | ns-allinone-3.27/ns-3.27/src/aodv/doc/aodv.h | zack-braun/4607_NS | 43c8fb772e5552fb44bd7cd34173e73e3fb66537 | [
"MIT"
] | 93 | 2019-04-21T08:22:26.000Z | 2022-03-30T04:26:29.000Z | ns-allinone-3.27/ns-3.27/src/aodv/doc/aodv.h | zack-braun/4607_NS | 43c8fb772e5552fb44bd7cd34173e73e3fb66537 | [
"MIT"
] | 12 | 2019-04-19T16:39:58.000Z | 2021-06-22T13:18:32.000Z | ns-allinone-3.27/ns-3.27/src/aodv/doc/aodv.h | zack-braun/4607_NS | 43c8fb772e5552fb44bd7cd34173e73e3fb66537 | [
"MIT"
] | 21 | 2019-05-27T19:36:12.000Z | 2021-07-26T02:37:41.000Z | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2009 IITP RAS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Based on
* NS-2 AODV model developed by the CMU/MONARCH group and optimized and
* tuned by Samir Das and Mahesh Marina, University of Cincinnati;
*
* AODV-UU implementation by Erik Nordström of Uppsala University
* http://core.it.uu.se/core/index.php/AODV-UU
*
* Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
* Pavel Boyko <boyko@iitp.ru>
*/
#ifndef AODV_H
#define AODV_H
/**
* \defgroup aodv AODV Routing
*
* This section documents the API of the ns-3 AODV module. For a generic functional description, please refer to the ns-3 manual.
*/
#endif /* AODV_H */
| 35.051282 | 129 | 0.70812 | [
"model"
] |
9aec7e78d3d1c0287e4cdde461c658e44dee36b1 | 3,078 | h | C | src/camera/lib/stream_utils/stream_constraints.h | EnderNightLord-ChromeBook/zircon-rpi | b09b1eb3aa7a127c65568229fe10edd251869283 | [
"BSD-2-Clause"
] | 14 | 2020-10-25T05:48:36.000Z | 2021-09-20T02:46:20.000Z | src/camera/lib/stream_utils/stream_constraints.h | DamieFC/fuchsia | f78a4a1326f4a4bb5834500918756173c01bab4f | [
"BSD-2-Clause"
] | 1 | 2022-01-14T23:38:40.000Z | 2022-01-14T23:38:40.000Z | src/camera/lib/stream_utils/stream_constraints.h | DamieFC/fuchsia | f78a4a1326f4a4bb5834500918756173c01bab4f | [
"BSD-2-Clause"
] | 4 | 2020-12-28T17:04:45.000Z | 2022-03-12T03:20:44.000Z | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_CAMERA_LIB_STREAM_UTILS_STREAM_CONSTRAINTS_H_
#define SRC_CAMERA_LIB_STREAM_UTILS_STREAM_CONSTRAINTS_H_
#include <fuchsia/camera2/cpp/fidl.h>
#include <fuchsia/camera2/hal/cpp/fidl.h>
#include <fuchsia/sysmem/cpp/fidl.h>
#include <vector>
namespace camera {
// StreamConstraints provides an easier way to specify constraints,
// using the limited set of data that is relevant to camera streams.
// Usage: To fill out a vector of camera configs:
// std::vector<fuchsia::camera2::hal::Config> configs(<number of configs>);
//
// For each stream config, specify the stream type, and add image formats:
// StreamConstraints stream(fuchsia::camera2::CameraStreamType::MONITORING);
// stream.AddImageFormat(640, 512, fuchsia::sysmem::PixelFormatType::NV12);
// stream.AddImageFormat(896, 1600, fuchsia::sysmem::PixelFormatType::NV12);
// configs[0].stream_configs.push_back(stream.ConvertToStreamConfig());
//
// NOTE: The default settings for stream configs is below
// |bytes_per_row_divisor_| = 128;
// |buffer_count_for_camping_| = 3;
// |frames_per_second_| = 30;
// If you need to use different settings, please use the setter functions
// to update, before you call |StreamConstraints|
struct StreamConstraints {
public:
StreamConstraints(){};
StreamConstraints(fuchsia::camera2::CameraStreamType type) : stream_type_(type) {}
void AddImageFormat(uint32_t width, uint32_t height, fuchsia::sysmem::PixelFormatType format,
uint32_t original_width = 0, uint32_t original_height = 0);
void set_contiguous(bool flag) { contiguous_ = flag; }
void set_bytes_per_row_divisor(uint32_t bytes_per_row_divisor) {
bytes_per_row_divisor_ = bytes_per_row_divisor;
}
void set_buffer_count_for_camping(uint32_t buffer_count_for_camping) {
buffer_count_for_camping_ = buffer_count_for_camping;
}
static fuchsia::sysmem::ImageFormat_2 MakeImageFormat(uint32_t width, uint32_t height,
fuchsia::sysmem::PixelFormatType format,
uint32_t original_width = 0,
uint32_t original_height = 0);
void set_frames_per_second(uint32_t frames_per_second) { frames_per_second_ = frames_per_second; }
fuchsia::sysmem::BufferCollectionConstraints MakeBufferCollectionConstraints() const;
// Converts the data in this struct into a StreamConfig.
fuchsia::camera2::hal::StreamConfig ConvertToStreamConfig();
private:
uint32_t bytes_per_row_divisor_ = 128;
uint32_t buffer_count_for_camping_ = 3;
uint32_t frames_per_second_ = 30;
bool contiguous_ = false;
bool cpu_access_ = true;
std::vector<fuchsia::sysmem::ImageFormat_2> formats_;
fuchsia::camera2::CameraStreamType stream_type_ = {};
};
} // namespace camera
#endif // SRC_CAMERA_LIB_STREAM_UTILS_STREAM_CONSTRAINTS_H_
| 41.04 | 100 | 0.732943 | [
"vector"
] |
9aeecf20ec37b1084585acb9c1bc467abdd4745d | 26,932 | h | C | StrictModules/exceptions.h | isabella232/cinder-1 | 428669a9a925287f192ab361226e5a8ca3fb74d9 | [
"CNRI-Python-GPL-Compatible"
] | 1,886 | 2021-05-03T23:58:43.000Z | 2022-03-31T19:15:58.000Z | StrictModules/exceptions.h | isabella232/cinder-1 | 428669a9a925287f192ab361226e5a8ca3fb74d9 | [
"CNRI-Python-GPL-Compatible"
] | 70 | 2021-05-04T23:25:35.000Z | 2022-03-31T18:42:08.000Z | StrictModules/exceptions.h | isabella232/cinder-1 | 428669a9a925287f192ab361226e5a8ca3fb74d9 | [
"CNRI-Python-GPL-Compatible"
] | 52 | 2021-05-04T21:26:03.000Z | 2022-03-08T18:02:56.000Z | // Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com)
#pragma once
#include <fmt/format.h>
#include <array>
#include <exception>
#include <iterator>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
namespace strictmod {
// We will inject the wiki base url from callsite
const std::string kWikiBase = "";
/**
* Base of all strict module related exceptions
* lineno, col: line number and col number in source code
* filename: file in which exception occured
* scopeName: scope (e.g. function name or <module>) in which exception occured
* msg: message of exception
* cause: which exception caused the current exception
*/
class StrictModuleException : public std::exception {
public:
StrictModuleException(
int lineno,
int col,
std::string filename,
std::string scopeName,
std::string msg,
std::shared_ptr<const StrictModuleException> cause = nullptr);
virtual ~StrictModuleException() {}
/* getters */
std::string getMsg() const;
const std::shared_ptr<const StrictModuleException> getCause() const;
int getLineno() const;
int getCol() const;
void setlineInfo(int lineno, int col);
const std::string& getFilename() const;
const std::string& getScopeName() const;
void setFilename(std::string filename);
void setScopeName(std::string scopeName);
/* concise string form of the exception, used in tests */
std::string testString() const;
/* more readable string form of the exception, shown to users */
std::string displayString(bool useLocation = false) const;
void setCause(std::shared_ptr<StrictModuleException> cause) {
cause_ = std::move(cause);
}
/* dynamically dispatched throw
* All subclasses need to implement this
*/
[[noreturn]] virtual void raise();
/* deepcopy the exception object. */
virtual std::unique_ptr<StrictModuleException> clone() const;
/* what to output as a std::exception */
virtual const char* what() const noexcept override;
protected:
int lineno_;
int col_;
/* The file containing the line of code that causes the error
*/
std::string filename_;
std::string scopeName_;
mutable std::string msg_;
/* use of shared_ptr here because unique_ptr cannot
* be copy constructed, and we need to throw here
*/
std::shared_ptr<const StrictModuleException> cause_;
virtual std::string testStringHelper() const;
virtual std::string displayStringHelper() const;
};
/** exception for unsupported language features
* encountered during the analysis.
* There should be nothing throwing this
* by the end of the migration
*/
class StrictModuleNotImplementedException : public StrictModuleException {
public:
StrictModuleNotImplementedException(
int lineno,
int col,
std::string filename,
std::string scopeName,
std::unique_ptr<const StrictModuleException> cause = nullptr);
[[noreturn]] virtual void raise() override;
private:
virtual std::string testStringHelper() const override;
virtual std::string displayStringHelper() const override;
};
/** iteration exceeds limit. */
class StrictModuleTooManyIterationsException : public StrictModuleException {
public:
StrictModuleTooManyIterationsException(
int lineno,
int col,
std::string filename,
std::string scopeName);
[[noreturn]] virtual void raise() override;
private:
virtual std::string testStringHelper() const override;
virtual std::string displayStringHelper() const override;
};
/** Use this for user space exceptions, i.e. exceptions
* that the analyzed Python program may raise
*/
template <typename T>
class StrictModuleUserException : public StrictModuleException {
public:
StrictModuleUserException(
int lineno,
int col,
std::string filename,
std::string scopeName,
std::shared_ptr<T> wrapped,
std::shared_ptr<const StrictModuleException> cause = nullptr);
const std::shared_ptr<const T> getWrapped() const;
const std::shared_ptr<T> getWrapped();
[[noreturn]] virtual void raise() override;
virtual std::unique_ptr<StrictModuleException> clone() const override;
virtual const char* what() const noexcept override;
private:
std::shared_ptr<T> wrapped_;
virtual std::string testStringHelper() const override;
virtual std::string displayStringHelper() const override;
};
class StrictModuleUnhandledException : public StrictModuleException {
public:
StrictModuleUnhandledException(
int lineno,
int col,
std::string filename,
std::string scopeName,
std::string exceptionName,
std::vector<std::string> exceptionArgs,
std::shared_ptr<const StrictModuleException> cause = nullptr);
[[noreturn]] virtual void raise() override;
virtual std::unique_ptr<StrictModuleException> clone() const override;
virtual const char* what() const noexcept override;
private:
std::string exceptionName_;
std::vector<std::string> exceptionArgs_;
virtual std::string testStringHelper() const override;
virtual std::string displayStringHelper() const override;
};
/**
* Use this template to specify which fields in a structued
* exception will be formatted into the final
* error message.
* Be careful that the order of member supplied should be the order
* they appear in the format string, and should be the order in the
* constructor
*/
template <typename T, typename E, std::string T::*... mp>
class StructuredStrictModuleException : public T, public StrictModuleException {
public:
template <typename... Args>
StructuredStrictModuleException(
int lineno,
int col,
std::string filename,
std::string scopeName,
Args... args);
template <typename... Args>
StructuredStrictModuleException(
int lineno,
int col,
std::string filename,
std::string scopeName,
std::shared_ptr<const StrictModuleException> cause,
Args... args);
virtual std::unique_ptr<StrictModuleException> clone() const override;
virtual const char* what() const noexcept override;
private:
std::string formatError() const;
virtual std::string testStringHelper() const override;
virtual std::string displayStringHelper() const override;
};
//--------------------------Structured exceptions---------------------------
// UnknownValueBinaryOpException
struct UnknownValueBinaryOpExceptionHelper {
UnknownValueBinaryOpExceptionHelper(
std::string name,
std::string op,
std::string other);
std::string unknownName;
std::string op;
std::string otherName;
static constexpr const char* excName = "UnknownValueBinaryOpException";
static constexpr const char* fmt =
"Module-level binary operation on non-strict value '{} {} {}' is "
"prohibited.";
static constexpr const char* wiki = "unknown_value_binary_op";
};
class UnknownValueBinaryOpException
: public StructuredStrictModuleException<
UnknownValueBinaryOpExceptionHelper,
UnknownValueBinaryOpException,
&UnknownValueBinaryOpExceptionHelper::unknownName,
&UnknownValueBinaryOpExceptionHelper::op,
&UnknownValueBinaryOpExceptionHelper::otherName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// UnknownValueUnaryOpException
struct UnknownValueUnaryOpExceptionHelper {
UnknownValueUnaryOpExceptionHelper(std::string op, std::string name);
std::string op;
std::string unknownName;
static constexpr const char* excName = "UnknownValueUnaryOpException";
static constexpr const char* fmt =
"Module-level unary operation on non-strict value '{} {}' is "
"prohibited.";
static constexpr const char* wiki = "unknown_value_binary_op";
};
class UnknownValueUnaryOpException
: public StructuredStrictModuleException<
UnknownValueUnaryOpExceptionHelper,
UnknownValueUnaryOpException,
&UnknownValueUnaryOpExceptionHelper::op,
&UnknownValueUnaryOpExceptionHelper::unknownName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// UnknownValueAttributeException
struct UnknownValueAttributeExceptionHelper {
UnknownValueAttributeExceptionHelper(std::string name, std::string attribute);
std::string unknownName;
std::string attribute;
static constexpr const char* excName = "UnknownValueAttributeException";
static constexpr const char* fmt =
"Module-level attribute access on non-strict value '{}.{}' is "
"prohibited.";
static constexpr const char* wiki = "unknown_value_attribute";
};
class UnknownValueAttributeException
: public StructuredStrictModuleException<
UnknownValueAttributeExceptionHelper,
UnknownValueAttributeException,
&UnknownValueAttributeExceptionHelper::unknownName,
&UnknownValueAttributeExceptionHelper::attribute> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// UnknownValueIndexException
struct UnknownValueIndexExceptionHelper {
UnknownValueIndexExceptionHelper(std::string name, std::string index);
std::string unknownName;
std::string index;
static constexpr const char* excName = "UnknownValueIndexException";
static constexpr const char* fmt =
"Module-level index into non-strict value '{}[{}]' is "
"prohibited.";
static constexpr const char* wiki = "unknown_value_index";
};
class UnknownValueIndexException
: public StructuredStrictModuleException<
UnknownValueIndexExceptionHelper,
UnknownValueIndexException,
&UnknownValueIndexExceptionHelper::unknownName,
&UnknownValueIndexExceptionHelper::index> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// UnknownValueCallException
struct UnknownValueCallExceptionHelper {
UnknownValueCallExceptionHelper(std::string name);
std::string unknownName;
static constexpr const char* excName = "UnknownValueCallException";
static constexpr const char* fmt =
"Module-level call of non-strict value '{}()' is prohibited.";
static constexpr const char* wiki = "unknown_call";
};
class UnknownValueCallException
: public StructuredStrictModuleException<
UnknownValueCallExceptionHelper,
UnknownValueCallException,
&UnknownValueCallExceptionHelper::unknownName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// UnknownValueBoolException
struct UnknownValueBoolExceptionHelper {
UnknownValueBoolExceptionHelper(std::string name);
std::string unknownName;
static constexpr const char* excName = "UnknownValueBoolException";
static constexpr const char* fmt =
"Module-level conversion to bool on non-strict value '{}' is prohibited.";
static constexpr const char* wiki = "unknown_value_bool_op";
};
class UnknownValueBoolException
: public StructuredStrictModuleException<
UnknownValueBoolExceptionHelper,
UnknownValueBoolException,
&UnknownValueBoolExceptionHelper::unknownName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// UnknownValueNotIterableException
struct UnknownValueNotIterableExceptionHelper {
UnknownValueNotIterableExceptionHelper(std::string name);
std::string unknownName;
static constexpr const char* excName = "UnknownValueNotIterableException";
static constexpr const char* fmt =
"Attempt to iterate over non-iterable object: '{}";
static constexpr const char* wiki = "unknown_value_attribute";
};
class UnknownValueNotIterableException
: public StructuredStrictModuleException<
UnknownValueNotIterableExceptionHelper,
UnknownValueNotIterableException,
&UnknownValueNotIterableExceptionHelper::unknownName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// ImmutableException
struct ImmutableExceptionHelper {
ImmutableExceptionHelper(
std::string attrName,
std::string kind,
std::string name);
std::string attrName;
std::string immutableKind; // module, type or object
std::string objName;
static constexpr const char* excName = "ImmutableException";
static constexpr const char* fmt =
"can't set attribute {} of immutable {} '{}'";
static constexpr const char* wiki = "";
};
class ImmutableException : public StructuredStrictModuleException<
ImmutableExceptionHelper,
ImmutableException,
&ImmutableExceptionHelper::attrName,
&ImmutableExceptionHelper::immutableKind,
&ImmutableExceptionHelper::objName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// ModifyImportValueException
struct ModifyImportValueExceptionHelper {
ModifyImportValueExceptionHelper(
std::string name,
std::string ownerName,
std::string callerName);
std::string objName;
std::string ownerName;
std::string callerName;
static constexpr const char* excName = "ModifyImportValueException";
static constexpr const char* fmt =
"{} from module {} is modified by {}; this is prohibited.";
static constexpr const char* wiki = "modify_imported_value";
};
class ModifyImportValueException
: public StructuredStrictModuleException<
ModifyImportValueExceptionHelper,
ModifyImportValueException,
&ModifyImportValueExceptionHelper::objName,
&ModifyImportValueExceptionHelper::ownerName,
&ModifyImportValueExceptionHelper::callerName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// CoroutineFunctionNotSupportedException
class CoroutineFunctionNotSupportedExceptionHelper {
public:
CoroutineFunctionNotSupportedExceptionHelper(std::string funcName);
std::string funcName;
static constexpr const char* excName =
"CoroutineFunctionNotSupportedException";
static constexpr const char* fmt =
"coroutines function {} with yield expressions are not supported.";
static constexpr const char* wiki = "";
};
class CoroutineFunctionNotSupportedException
: public StructuredStrictModuleException<
CoroutineFunctionNotSupportedExceptionHelper,
CoroutineFunctionNotSupportedException,
&CoroutineFunctionNotSupportedExceptionHelper::funcName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// UnsafeCallException
struct UnsafeCallExceptionHelper {
UnsafeCallExceptionHelper(std::string name);
std::string callableName;
static constexpr const char* excName = "UnsafeCallException";
static constexpr const char* fmt =
"Call '{}()' may have side effects and is prohibited at module level.";
static constexpr const char* wiki = "unsafe_call";
};
class UnsafeCallException : public StructuredStrictModuleException<
UnsafeCallExceptionHelper,
UnsafeCallException,
&UnsafeCallExceptionHelper::callableName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// UnsupportedException
struct UnsupportedExceptionHelper {
UnsupportedExceptionHelper(std::string name, std::string typeName);
std::string opName;
std::string typeName;
static constexpr const char* excName = "UnsupportedException";
static constexpr const char* fmt =
"Operation '{}' on type '{}' is unsupported";
static constexpr const char* wiki = "";
};
class UnsupportedException : public StructuredStrictModuleException<
UnsupportedExceptionHelper,
UnsupportedException,
&UnsupportedExceptionHelper::opName,
&UnsupportedExceptionHelper::typeName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// UnsafeBaseClassException
struct UnsafeBaseClassExceptionHelper {
UnsafeBaseClassExceptionHelper(std::string name);
std::string unknownName;
static constexpr const char* excName = "UnsafeBaseClassException";
static constexpr const char* fmt = "'{}' is not a valid base class";
static constexpr const char* wiki = "";
};
class UnsafeBaseClassException
: public StructuredStrictModuleException<
UnsafeBaseClassExceptionHelper,
UnsafeBaseClassException,
&UnsafeBaseClassExceptionHelper::unknownName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// FailedToUnpackException
struct FailedToUnpackExceptionHelper {
FailedToUnpackExceptionHelper(std::string size);
std::string packSize;
static constexpr const char* excName = "FailedToUnpackException";
static constexpr const char* fmt = "failed to unpack rhs into {} variables";
static constexpr const char* wiki = "";
};
class FailedToUnpackException : public StructuredStrictModuleException<
FailedToUnpackExceptionHelper,
FailedToUnpackException,
&FailedToUnpackExceptionHelper::packSize> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// StarImportDisallowedException
struct StarImportDisallowedExceptionHelper {
StarImportDisallowedExceptionHelper(std::string mod);
std::string fromMod;
static constexpr const char* excName = "StarImportDisallowedException";
static constexpr const char* fmt = "cannot import * from {}";
static constexpr const char* wiki = "";
};
class StarImportDisallowedException
: public StructuredStrictModuleException<
StarImportDisallowedExceptionHelper,
StarImportDisallowedException,
&StarImportDisallowedExceptionHelper::fromMod> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// ImportDisallowedException
struct ImportDisallowedExceptionHelper {
ImportDisallowedExceptionHelper(std::string context);
std::string context;
static constexpr const char* excName = "ImportDisallowedException";
static constexpr const char* fmt = "import statements in {} is disallowed";
static constexpr const char* wiki = "";
};
class ImportDisallowedException
: public StructuredStrictModuleException<
ImportDisallowedExceptionHelper,
ImportDisallowedException,
&ImportDisallowedExceptionHelper::context> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// BadStrictFlagException
struct BadStrictFlagExceptionHelper {
BadStrictFlagExceptionHelper(std::string err);
std::string err;
static constexpr const char* excName = "BadStrictFlagException";
static constexpr const char* fmt = "bad strict flag: {}";
static constexpr const char* wiki = "";
};
class BadStrictFlagException : public StructuredStrictModuleException<
BadStrictFlagExceptionHelper,
BadStrictFlagException,
&BadStrictFlagExceptionHelper::err> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// ConflictingSourceException
class ConflictingSourceExceptionHelper {
public:
ConflictingSourceExceptionHelper(
std::string modName,
std::string firstName,
std::string secondName);
std::string modName;
std::string firstName;
std::string secondName;
static constexpr const char* excName = "ConflictingSourceException";
static constexpr const char* fmt =
"Got conflicting source files for module {}, first seen: {}, second "
"seen: {}";
static constexpr const char* wiki = "";
};
class ConflictingSourceException
: public StructuredStrictModuleException<
ConflictingSourceExceptionHelper,
ConflictingSourceException,
&ConflictingSourceExceptionHelper::modName,
&ConflictingSourceExceptionHelper::firstName,
&ConflictingSourceExceptionHelper::secondName> {
public:
using StructuredStrictModuleException::StructuredStrictModuleException;
[[noreturn]] virtual void raise() override;
};
// ------------------Out of line implementations---------------
// StrictModuleException
inline std::string StrictModuleException::getMsg() const {
return msg_;
}
inline const std::shared_ptr<const StrictModuleException>
StrictModuleException::getCause() const {
return std::shared_ptr<const StrictModuleException>(cause_);
}
inline int StrictModuleException::getLineno() const {
return lineno_;
}
inline int StrictModuleException::getCol() const {
return col_;
}
inline void StrictModuleException::setlineInfo(int lineno, int col) {
lineno_ = lineno;
col_ = col;
}
inline const std::string& StrictModuleException::getFilename() const {
return filename_;
}
inline const std::string& StrictModuleException::getScopeName() const {
return scopeName_;
}
inline void StrictModuleException::setFilename(std::string filename) {
filename_ = std::move(filename);
}
inline void StrictModuleException::setScopeName(std::string scopeName) {
scopeName_ = std::move(scopeName);
}
inline std::string StrictModuleException::testString() const {
if (cause_ != nullptr) {
return fmt::format(
"{} {} {} {}", lineno_, col_, testStringHelper(), cause_->testString());
}
return fmt::format("{} {} {}", lineno_, col_, testStringHelper());
}
inline std::string StrictModuleException::displayString(
bool useLocation) const {
std::string res;
if (cause_ != nullptr) {
res = fmt::format(
"{}\nCaused by: {}",
displayStringHelper(),
cause_->displayString(true)); // cause always has lineinfo
} else {
res = displayStringHelper();
}
if (useLocation) {
return fmt::format("[{} {}:{}] {}", filename_, lineno_, col_, res);
} else {
return res;
}
}
// StrictModuleUserException
template <typename T>
StrictModuleUserException<T>::StrictModuleUserException(
int lineno,
int col,
std::string filename,
std::string scopeName,
std::shared_ptr<T> wrapped,
std::shared_ptr<const StrictModuleException> cause)
: StrictModuleException(
lineno,
col,
std::move(filename),
std::move(scopeName),
"",
std::move(cause)),
wrapped_(std::move(wrapped)) {}
template <typename T>
const std::shared_ptr<const T> StrictModuleUserException<T>::getWrapped()
const {
return std::shared_ptr<const T>(wrapped_);
}
template <typename T>
const std::shared_ptr<T> StrictModuleUserException<T>::getWrapped() {
return wrapped_;
}
template <typename T>
[[noreturn]] void StrictModuleUserException<T>::raise() {
throw *this;
}
template <typename T>
std::unique_ptr<StrictModuleException> StrictModuleUserException<T>::clone()
const {
return std::make_unique<StrictModuleUserException<T>>(
lineno_, col_, filename_, scopeName_, wrapped_, cause_);
}
template <typename T>
const char* StrictModuleUserException<T>::what() const noexcept {
msg_ = testString();
return msg_.c_str();
}
template <typename T>
std::string StrictModuleUserException<T>::testStringHelper() const {
return "StrictModuleUserException " + wrapped_->getTypeRef().getDisplayName();
}
template <typename T>
std::string StrictModuleUserException<T>::displayStringHelper() const {
return fmt::format("UserException({})", wrapped_->getDisplayName());
}
// StrictModuleStructuredException
template <typename T, typename E, std::string T::*... mp>
template <typename... Args>
StructuredStrictModuleException<T, E, mp...>::StructuredStrictModuleException(
int lineno,
int col,
std::string filename,
std::string scopeName,
Args... args)
: T(std::move(args)...),
StrictModuleException(
lineno,
col,
std::move(filename),
std::move(scopeName),
formatError()) {}
template <typename T, typename E, std::string T::*... mp>
template <typename... Args>
StructuredStrictModuleException<T, E, mp...>::StructuredStrictModuleException(
int lineno,
int col,
std::string filename,
std::string scopeName,
std::shared_ptr<const StrictModuleException> cause,
Args... args)
: T(std::move(args)...),
StrictModuleException(
lineno,
col,
std::move(filename),
std::move(scopeName),
formatError(),
cause) {}
template <typename T, typename E, std::string T::*... mp>
std::unique_ptr<StrictModuleException>
StructuredStrictModuleException<T, E, mp...>::clone() const {
return std::make_unique<E>(
lineno_,
col_,
filename_,
scopeName_,
cause_,
(static_cast<const T*>(this)->*mp)...);
}
template <typename T, typename E, std::string T::*... mp>
const char* StructuredStrictModuleException<T, E, mp...>::what() const
noexcept {
msg_ = formatError();
return msg_.c_str();
}
template <typename T, typename E, std::string T::*... mp>
std::string StructuredStrictModuleException<T, E, mp...>::formatError() const {
std::ostringstream stream;
stream << fmt::format(T::fmt, static_cast<const T*>(this)->*mp...);
stream << "\nSee " << kWikiBase << T::wiki;
return stream.str();
}
template <typename T, typename E, std::string T::*... mp>
std::string StructuredStrictModuleException<T, E, mp...>::testStringHelper()
const {
constexpr int size = sizeof...(mp);
std::array<std::string, size> strings = {
(static_cast<const T*>(this)->*mp)...};
return fmt::format(
"{} {}", static_cast<const T*>(this)->excName, fmt::join(strings, " "));
}
template <typename T, typename E, std::string T::*... mp>
std::string StructuredStrictModuleException<T, E, mp...>::displayStringHelper()
const {
return fmt::format(T::fmt, static_cast<const T*>(this)->*mp...);
}
} // namespace strictmod
| 32.138425 | 80 | 0.717028 | [
"object",
"vector"
] |
9af0680fcacd80444f2f6185d78d6ba7bbc1786c | 256,509 | c | C | src/grib_hash_keys.c | francois-baptiste/eccodes | 2d159402f344df31de631751652f92888a630cd4 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | src/grib_hash_keys.c | francois-baptiste/eccodes | 2d159402f344df31de631751652f92888a630cd4 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | src/grib_hash_keys.c | francois-baptiste/eccodes | 2d159402f344df31de631751652f92888a630cd4 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 2020-06-23T10:18:39.000Z | 2020-06-23T10:18:39.000Z | /* C code produced by gperf version 3.0.4 */
/* Command-line: gperf -I -t -G -H hash_keys -N grib_keys_hash_get -m 3 keys */
/* Computed positions: -k'1-16,19-20,23,25,27,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
#endif
#line 1 "keys"
#include "grib_api_internal.h"
#line 4 "keys"
struct grib_keys_hash { char* name; int id;};
#include <string.h>
#define TOTAL_KEYWORDS 2137
#define MIN_WORD_LENGTH 1
#define MAX_WORD_LENGTH 74
#define MIN_HASH_VALUE 5
#define MAX_HASH_VALUE 22970
/* maximum key range = 22966, duplicates = 0 */
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static unsigned int
hash_keys (const char *str, unsigned int len)
{
static unsigned short asso_values[] =
{
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 3, 22971, 22971, 3, 22971, 22971, 7, 1381,
1683, 1529, 1106, 894, 559, 1912, 52, 5, 2, 2,
3, 22971, 22971, 22971, 22971, 525, 3795, 639, 172, 884,
320, 2058, 3370, 1244, 1333, 519, 78, 1866, 777, 132,
172, 84, 432, 115, 1610, 3610, 43, 2496, 1236, 3063,
78, 2, 2, 22971, 2, 1873, 22971, 4, 300, 11,
2, 7, 82, 53, 113, 7, 1623, 2107, 41, 8,
2, 11, 27, 647, 17, 14, 3, 89, 151, 6,
233, 972, 1010, 372, 898, 24, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971,
22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971, 22971
};
register int hval = len;
switch (hval)
{
default:
hval += asso_values[(unsigned char)str[26]];
/*FALLTHROUGH*/
case 26:
case 25:
hval += asso_values[(unsigned char)str[24]];
/*FALLTHROUGH*/
case 24:
case 23:
hval += asso_values[(unsigned char)str[22]];
/*FALLTHROUGH*/
case 22:
case 21:
case 20:
hval += asso_values[(unsigned char)str[19]];
/*FALLTHROUGH*/
case 19:
hval += asso_values[(unsigned char)str[18]];
/*FALLTHROUGH*/
case 18:
case 17:
case 16:
hval += asso_values[(unsigned char)str[15]+3];
/*FALLTHROUGH*/
case 15:
hval += asso_values[(unsigned char)str[14]+4];
/*FALLTHROUGH*/
case 14:
hval += asso_values[(unsigned char)str[13]];
/*FALLTHROUGH*/
case 13:
hval += asso_values[(unsigned char)str[12]];
/*FALLTHROUGH*/
case 12:
hval += asso_values[(unsigned char)str[11]+3];
/*FALLTHROUGH*/
case 11:
hval += asso_values[(unsigned char)str[10]+3];
/*FALLTHROUGH*/
case 10:
hval += asso_values[(unsigned char)str[9]];
/*FALLTHROUGH*/
case 9:
hval += asso_values[(unsigned char)str[8]];
/*FALLTHROUGH*/
case 8:
hval += asso_values[(unsigned char)str[7]];
/*FALLTHROUGH*/
case 7:
hval += asso_values[(unsigned char)str[6]];
/*FALLTHROUGH*/
case 6:
hval += asso_values[(unsigned char)str[5]];
/*FALLTHROUGH*/
case 5:
hval += asso_values[(unsigned char)str[4]];
/*FALLTHROUGH*/
case 4:
hval += asso_values[(unsigned char)str[3]];
/*FALLTHROUGH*/
case 3:
hval += asso_values[(unsigned char)str[2]];
/*FALLTHROUGH*/
case 2:
hval += asso_values[(unsigned char)str[1]];
/*FALLTHROUGH*/
case 1:
hval += asso_values[(unsigned char)str[0]];
break;
}
return hval + asso_values[(unsigned char)str[len - 1]];
}
static struct grib_keys_hash wordlist[] =
{
{""}, {""}, {""}, {""}, {""},
#line 1200 "keys"
{"n",1195},
{""},
#line 1914 "keys"
{"t",1909},
#line 1209 "keys"
{"nd",1204},
#line 1923 "keys"
{"td",1918},
#line 1226 "keys"
{"nt",1221},
#line 1212 "keys"
{"nnn",1207},
#line 1203 "keys"
{"na",1198},
#line 662 "keys"
{"ed",657},
{""}, {""}, {""},
#line 1096 "keys"
{"m",1091},
{""}, {""},
#line 1748 "keys"
{"sd",1743},
#line 580 "keys"
{"data",575},
#line 1171 "keys"
{"min",1166},
{""},
#line 352 "keys"
{"cat",347},
{""}, {""},
#line 597 "keys"
{"date",592},
{""},
#line 884 "keys"
{"ident",879},
#line 1372 "keys"
{"one",1367},
{""},
#line 1204 "keys"
{"name",1199},
{""},
#line 1985 "keys"
{"two",1980},
{""},
#line 1949 "keys"
{"time",1944},
{""}, {""}, {""}, {""}, {""},
#line 646 "keys"
{"domain",641},
{""}, {""}, {""}, {""},
#line 1167 "keys"
{"metadata",1162},
#line 663 "keys"
{"edition",658},
#line 533 "keys"
{"const",528},
{""}, {""},
#line 1838 "keys"
{"sort",1833},
{""},
#line 1208 "keys"
{"names",1203},
#line 1749 "keys"
{"second",1744},
{""},
#line 559 "keys"
{"core",554},
#line 703 "keys"
{"enorm",698},
{""},
#line 368 "keys"
{"centre",363},
#line 1099 "keys"
{"mars",1094},
{""}, {""},
#line 1769 "keys"
{"section",1764},
#line 708 "keys"
{"eps",703},
{""},
#line 1887 "keys"
{"stream",1882},
{""}, {""}, {""},
#line 630 "keys"
{"dimension",625},
#line 938 "keys"
{"iteration",933},
#line 1477 "keys"
{"param",1472},
#line 1598 "keys"
{"rectime",1593},
{""}, {""}, {""},
#line 633 "keys"
{"direction",628},
{""},
#line 1390 "keys"
{"opttime",1385},
#line 1854 "keys"
{"spare",1849},
#line 1878 "keys"
{"step",1873},
#line 1384 "keys"
{"oper",1379},
#line 1513 "keys"
{"points",1508},
#line 841 "keys"
{"grid",836},
{""},
#line 1523 "keys"
{"present",1518},
{""}, {""},
#line 295 "keys"
{"assertion",290},
#line 714 "keys"
{"error",709},
{""}, {""},
#line 996 "keys"
{"leadtime",991},
#line 1582 "keys"
{"range",1577},
{""}, {""}, {""}, {""}, {""},
#line 117 "keys"
{"Latin",112},
{""},
#line 390 "keys"
{"class",385},
#line 1876 "keys"
{"statistics",1871},
#line 1395 "keys"
{"origin",1390},
{""},
#line 822 "keys"
{"g",817},
#line 1960 "keys"
{"total",1955},
#line 564 "keys"
{"correction",559},
#line 1576 "keys"
{"radials",1571},
#line 1510 "keys"
{"pl",1505},
{""}, {""},
#line 1519 "keys"
{"precision",1514},
#line 1186 "keys"
{"model",1181},
{""}, {""}, {""},
#line 1492 "keys"
{"partitions",1487},
#line 1480 "keys"
{"parameter",1475},
{""},
#line 1553 "keys"
{"process",1548},
{""},
#line 573 "keys"
{"count",568},
{""},
#line 1170 "keys"
{"million",1165},
#line 1976 "keys"
{"true",1971},
{""},
#line 1173 "keys"
{"minute",1168},
#line 1215 "keys"
{"normal",1210},
{""},
#line 1487 "keys"
{"parameters",1482},
{""},
#line 2029 "keys"
{"units",2024},
#line 628 "keys"
{"diagnostic",623},
#line 1604 "keys"
{"refdate",1599},
{""},
#line 1958 "keys"
{"timerepres",1953},
#line 112 "keys"
{"Lap",107},
{""},
#line 861 "keys"
{"hdate",856},
#line 639 "keys"
{"discipline",634},
{""},
#line 1172 "keys"
{"minimum",1167},
{""}, {""},
#line 1877 "keys"
{"status",1872},
#line 787 "keys"
{"file",782},
{""}, {""}, {""},
#line 1168 "keys"
{"method",1163},
#line 1577 "keys"
{"radius",1572},
#line 1028 "keys"
{"local",1023},
{""}, {""},
#line 1407 "keys"
{"padding",1402},
#line 353 "keys"
{"categories",348},
#line 1936 "keys"
{"three",1931},
#line 780 "keys"
{"false",775},
#line 832 "keys"
{"gg",827},
{""}, {""}, {""},
#line 902 "keys"
{"instrument",897},
#line 387 "keys"
{"char",382},
#line 1798 "keys"
{"section8",1793},
#line 887 "keys"
{"identifier",882},
{""},
#line 1554 "keys"
{"product",1549},
#line 963 "keys"
{"latitude",958},
{""},
#line 1605 "keys"
{"reference",1600},
#line 784 "keys"
{"fcperiod",779},
{""}, {""},
#line 1506 "keys"
{"phase",1501},
#line 127 "keys"
{"LoV",122},
#line 929 "keys"
{"isSens",924},
{""}, {""}, {""},
#line 1886 "keys"
{"stepZero",1881},
{""},
#line 592 "keys"
{"dataStream",587},
#line 2107 "keys"
{"windSpeed",2102},
#line 531 "keys"
{"consensus",526},
#line 36 "keys"
{"Di",31},
{""}, {""},
#line 666 "keys"
{"eight",661},
{""},
#line 993 "keys"
{"latitudes",988},
{""}, {""}, {""},
#line 695 "keys"
{"endStep",690},
#line 1091 "keys"
{"lowerLimit",1086},
{""}, {""},
#line 2065 "keys"
{"varno",2060},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1342 "keys"
{"offset",1337},
#line 1511 "keys"
{"platform",1506},
{""}, {""},
#line 1826 "keys"
{"signature",1821},
#line 802 "keys"
{"flags",797},
#line 583 "keys"
{"dataDate",578},
#line 1124 "keys"
{"marsStream",1119},
#line 293 "keys"
{"anoffset",288},
{""},
#line 2068 "keys"
{"version",2063},
{""}, {""}, {""},
#line 44 "keys"
{"Dstart",39},
#line 669 "keys"
{"eleven",664},
{""}, {""}, {""},
#line 1340 "keys"
{"oceanStream",1335},
#line 385 "keys"
{"channel",380},
#line 1870 "keys"
{"startStep",1865},
#line 1123 "keys"
{"marsStep",1118},
#line 1059 "keys"
{"longitude",1054},
#line 1621 "keys"
{"reserved",1616},
{""},
#line 1385 "keys"
{"operStream",1380},
#line 596 "keys"
{"dataValues",591},
{""},
#line 797 "keys"
{"flag",792},
{""}, {""},
#line 1225 "keys"
{"notDecoded",1220},
#line 876 "keys"
{"hundred",871},
{""},
#line 587 "keys"
{"dataOrigin",582},
#line 668 "keys"
{"elevation",663},
{""}, {""}, {""},
#line 1935 "keys"
{"thousand",1930},
{""}, {""},
#line 870 "keys"
{"hour",865},
{""},
#line 1088 "keys"
{"longitudes",1083},
#line 710 "keys"
{"epsPoint",705},
#line 1193 "keys"
{"month",1188},
#line 2106 "keys"
{"windPresent",2101},
#line 298 "keys"
{"average",293},
{""},
#line 1104 "keys"
{"marsDomain",1099},
{""}, {""}, {""},
#line 1103 "keys"
{"marsDir",1098},
#line 302 "keys"
{"avg",297},
#line 1119 "keys"
{"marsParam",1114},
{""},
#line 578 "keys"
{"crcrlf",573},
{""}, {""}, {""}, {""},
#line 591 "keys"
{"dataSelection",586},
{""}, {""},
#line 1132 "keys"
{"masterDir",1127},
#line 1594 "keys"
{"realPart",1589},
{""},
#line 803 "keys"
{"floatVal",798},
{""}, {""},
#line 1011 "keys"
{"levels",1006},
#line 1010 "keys"
{"levelist",1005},
#line 2044 "keys"
{"upperLimit",2039},
{""}, {""}, {""},
#line 1979 "keys"
{"truncateLaplacian",1974},
{""}, {""}, {""},
#line 1618 "keys"
{"representationMode",1613},
{""},
#line 1007 "keys"
{"level",1002},
{""},
#line 525 "keys"
{"conceptDir",520},
#line 665 "keys"
{"efiOrder",660},
#line 1138 "keys"
{"matchSort",1133},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1389 "keys"
{"optionalData",1384},
{""}, {""},
#line 2096 "keys"
{"windDirection",2091},
{""}, {""},
#line 283 "keys"
{"aerosolpacking",278},
#line 1925 "keys"
{"temperature",1920},
#line 306 "keys"
{"band",301},
{""}, {""}, {""}, {""}, {""},
#line 1049 "keys"
{"localSecond",1044},
{""}, {""}, {""},
#line 889 "keys"
{"ifsParam",884},
{""},
#line 2053 "keys"
{"values",2048},
{""}, {""},
#line 1035 "keys"
{"localDir",1030},
#line 1613 "keys"
{"referenceValue",1608},
#line 1563 "keys"
{"pv",1558},
#line 1937 "keys"
{"threshold",1932},
#line 625 "keys"
{"deletePV",620},
#line 785 "keys"
{"fgDate",780},
{""}, {""},
#line 518 "keys"
{"coefsSecond",513},
{""}, {""},
#line 2129 "keys"
{"xLast",2124},
{""},
#line 814 "keys"
{"forecastperiod",809},
{""}, {""},
#line 194 "keys"
{"P",189},
{""}, {""},
#line 674 "keys"
{"endDescriptors",669},
{""},
#line 783 "keys"
{"fcmonth",778},
#line 1804 "keys"
{"sectionPosition",1799},
{""},
#line 1006 "keys"
{"lev",1001},
{""}, {""},
#line 1211 "keys"
{"nlev",1206},
{""},
#line 1587 "keys"
{"rdbtime",1582},
{""}, {""},
#line 711 "keys"
{"epsStatistics",706},
{""}, {""},
#line 1606 "keys"
{"referenceDate",1601},
{""}, {""},
#line 388 "keys"
{"charValues",383},
{""}, {""}, {""}, {""},
#line 1143 "keys"
{"maximum",1138},
#line 927 "keys"
{"isSatellite",922},
#line 1959 "keys"
{"topLevel",1954},
#line 1120 "keys"
{"marsQuantile",1115},
#line 926 "keys"
{"isOctahedral",921},
#line 1115 "keys"
{"marsLevel",1110},
{""}, {""}, {""}, {""},
#line 335 "keys"
{"bitmap",330},
{""},
#line 2086 "keys"
{"waveDomain",2081},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 586 "keys"
{"dataLength",581},
#line 516 "keys"
{"codedValues",511},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1830 "keys"
{"siteLatitude",1825},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1753 "keys"
{"secondLatitude",1748},
{""}, {""}, {""},
#line 1114 "keys"
{"marsLatitude",1109},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1874 "keys"
{"statisticalProcess",1869},
#line 1361 "keys"
{"offsetSection0",1356},
{""},
#line 910 "keys"
{"internalVersion",905},
{""}, {""}, {""},
#line 109 "keys"
{"LaD",104},
{""}, {""},
#line 843 "keys"
{"gridDefinition",838},
{""},
#line 893 "keys"
{"indicatorOfParameter",888},
#line 812 "keys"
{"forecastSteps",807},
#line 1089 "keys"
{"longitudesList",1084},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 888 "keys"
{"ieeeFloats",883},
#line 1227 "keys"
{"number",1222},
{""}, {""},
#line 199 "keys"
{"PVPresent",194},
{""}, {""},
#line 1875 "keys"
{"statisticalProcessesList",1870},
{""}, {""},
#line 369 "keys"
{"centreDescription",364},
{""}, {""},
#line 1612 "keys"
{"referenceStep",1607},
#line 994 "keys"
{"latitudesList",989},
{""}, {""}, {""},
#line 524 "keys"
{"computeStatistics",519},
{""},
#line 734 "keys"
{"expver",729},
{""},
#line 736 "keys"
{"extraDim",731},
{""}, {""},
#line 651 "keys"
{"dx",646},
{""},
#line 1865 "keys"
{"standardParallel",1860},
{""}, {""}, {""}, {""},
#line 1033 "keys"
{"localDefinition",1028},
#line 733 "keys"
{"expoffset",728},
{""}, {""},
#line 1142 "keys"
{"max",1137},
{""}, {""},
#line 197 "keys"
{"PLPresent",192},
{""},
#line 1122 "keys"
{"marsStartStep",1117},
#line 808 "keys"
{"forecastPeriod",803},
#line 886 "keys"
{"identificationOfOriginatingGeneratingCentre",881},
#line 1078 "keys"
{"longitudeOfStretchingPole",1073},
{""}, {""},
#line 584 "keys"
{"dataFlag",579},
#line 1698 "keys"
{"satelliteSeries",1693},
{""}, {""}, {""},
#line 833 "keys"
{"global",828},
#line 1831 "keys"
{"siteLongitude",1826},
#line 517 "keys"
{"coefsFirst",512},
{""},
#line 804 "keys"
{"floatValues",799},
{""},
#line 1624 "keys"
{"reservedOctet",1619},
{""},
#line 558 "keys"
{"coordinatesPresent",553},
#line 1116 "keys"
{"marsLevelist",1111},
#line 1079 "keys"
{"longitudeOfStretchingPoleInDegrees",1074},
#line 358 "keys"
{"ccsdsFlags",353},
#line 211 "keys"
{"SecondLatitude",206},
#line 1117 "keys"
{"marsLongitude",1112},
{""}, {""},
#line 1369 "keys"
{"offsetSection8",1364},
{""}, {""},
#line 1040 "keys"
{"localLatitude",1035},
{""}, {""}, {""},
#line 359 "keys"
{"ccsdsRsi",354},
{""}, {""}, {""}, {""},
#line 1921 "keys"
{"tablesVersion",1916},
{""},
#line 641 "keys"
{"distinctLatitudes",636},
#line 1043 "keys"
{"localLongitude",1038},
{""}, {""},
#line 792 "keys"
{"firstLatitude",787},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 789 "keys"
{"firstDimension",784},
#line 512 "keys"
{"codeFigure",507},
#line 1030 "keys"
{"localDecimalScaleFactor",1025},
{""}, {""}, {""}, {""}, {""}, {""},
#line 2031 "keys"
{"unitsDecimalScaleFactor",2026},
{""}, {""}, {""}, {""}, {""}, {""},
#line 394 "keys"
{"climatologicalRegime",389},
#line 1121 "keys"
{"marsRange",1116},
#line 1180 "keys"
{"missingValue",1175},
#line 852 "keys"
{"groupSplitting",847},
{""}, {""},
#line 1549 "keys"
{"probPoint",1544},
#line 1891 "keys"
{"stringValues",1886},
{""},
#line 1881 "keys"
{"stepRange",1876},
{""}, {""},
#line 1620 "keys"
{"representativeMember",1615},
{""}, {""},
#line 909 "keys"
{"integerValues",904},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2033 "keys"
{"unitsFactor",2028},
#line 713 "keys"
{"epsStatisticsPoint",708},
{""}, {""}, {""},
#line 1719 "keys"
{"scaledDirections",1714},
{""},
#line 1037 "keys"
{"localFlag",1032},
#line 617 "keys"
{"defaultParameter",612},
{""}, {""},
#line 18 "keys"
{"Adelta",13},
#line 287 "keys"
{"angleDivisor",282},
{""}, {""}, {""},
#line 1092 "keys"
{"lowerRange",1087},
{""}, {""}, {""}, {""}, {""},
#line 2128 "keys"
{"xFirst",2123},
{""}, {""},
#line 962 "keys"
{"latLonValues",957},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1983 "keys"
{"tubeDomain",1978},
#line 1333 "keys"
{"numericValues",1328},
{""}, {""},
#line 693 "keys"
{"endOfProduct",688},
#line 829 "keys"
{"generatingProcessIdentificationNumber",824},
{""}, {""},
#line 830 "keys"
{"generatingProcessIdentifier",825},
#line 740 "keys"
{"extraValues",735},
{""}, {""},
#line 903 "keys"
{"instrumentIdentifier",898},
{""}, {""}, {""}, {""}, {""},
#line 847 "keys"
{"gridDescriptionSectionPresent",842},
#line 210 "keys"
{"SPD",205},
#line 1975 "keys"
{"treatmentOfMissingData",1970},
{""}, {""},
#line 1210 "keys"
{"neitherPresent",1205},
{""},
#line 45 "keys"
{"Dx",40},
{""},
#line 341 "keys"
{"bottomLevel",336},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 739 "keys"
{"extraLocalSectionPresent",734},
{""}, {""}, {""}, {""}, {""}, {""},
#line 706 "keys"
{"ensembleSize",701},
{""},
#line 915 "keys"
{"isAuto",910},
{""},
#line 849 "keys"
{"gridPointPosition",844},
#line 817 "keys"
{"freeFormData",812},
#line 526 "keys"
{"conceptsLocalDirAll",521},
{""},
#line 370 "keys"
{"centreForLocal",365},
{""}, {""},
#line 863 "keys"
{"heightLevelName",858},
{""}, {""},
#line 1819 "keys"
{"setDecimalPrecision",1814},
{""}, {""},
#line 1165 "keys"
{"meaningOfVerticalCoordinate",1160},
#line 2045 "keys"
{"upperRange",2040},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 520 "keys"
{"complexPacking",515},
{""}, {""}, {""},
#line 384 "keys"
{"changingPrecision",379},
{""}, {""},
#line 1355 "keys"
{"offsetDescriptors",1350},
{""},
#line 1820 "keys"
{"setLocalDefinition",1815},
{""}, {""}, {""}, {""}, {""},
#line 956 "keys"
{"laplacianOperator",951},
{""}, {""}, {""},
#line 1337 "keys"
{"observedData",1332},
{""}, {""},
#line 921 "keys"
{"isConstant",916},
{""}, {""},
#line 1373 "keys"
{"oneConstant",1368},
{""},
#line 1000 "keys"
{"lengthDescriptors",995},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1069 "keys"
{"longitudeOfIcosahedronPole",1064},
{""}, {""},
#line 509 "keys"
{"clusteringMethod",504},
{""}, {""}, {""}, {""},
#line 853 "keys"
{"groupSplittingMethodUsed",848},
{""}, {""}, {""}, {""},
#line 694 "keys"
{"endOfRange",689},
{""},
#line 581 "keys"
{"dataAccessors",576},
{""}, {""}, {""},
#line 1565 "keys"
{"qfe",1560},
{""}, {""}, {""},
#line 342 "keys"
{"boustrophedonic",337},
#line 102 "keys"
{"KS",97},
#line 612 "keys"
{"decimalScaleFactor",607},
{""}, {""}, {""}, {""}, {""},
#line 738 "keys"
{"extraLocalSectionNumber",733},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 906 "keys"
{"integerScaleFactor",901},
#line 73 "keys"
{"FirstLatitude",68},
{""}, {""}, {""}, {""}, {""}, {""},
#line 721 "keys"
{"expandedDescriptors",716},
{""},
#line 1100 "keys"
{"marsClass",1095},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 184 "keys"
{"Ni",179},
{""}, {""}, {""}, {""}, {""}, {""},
#line 898 "keys"
{"inputDataPresentIndicator",893},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 186 "keys"
{"Nr",181},
{""},
#line 1574 "keys"
{"quantile",1569},
{""}, {""}, {""}, {""},
#line 301 "keys"
{"averagingPeriod",296},
#line 1816 "keys"
{"sequences",1811},
{""}, {""}, {""},
#line 957 "keys"
{"laplacianOperatorIsSet",952},
#line 1141 "keys"
{"matrixOfValues",1136},
#line 289 "keys"
{"angleOfRotation",284},
{""}, {""},
#line 1482 "keys"
{"parameterCode",1477},
{""}, {""},
#line 1827 "keys"
{"significanceOfReferenceTime",1822},
{""},
#line 1223 "keys"
{"northernLatitudeOfDomain",1218},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 990 "keys"
{"latitudeSexagesimal",985},
#line 1090 "keys"
{"longitudinalDirectionGridLength",1085},
{""},
#line 1331 "keys"
{"numberOfVerticalPoints",1326},
{""},
#line 180 "keys"
{"NV",175},
{""}, {""},
#line 629 "keys"
{"diagnosticNumber",624},
{""}, {""}, {""}, {""}, {""},
#line 1602 "keys"
{"rectimeSecond",1597},
#line 914 "keys"
{"isAccumulation",909},
{""}, {""},
#line 1568 "keys"
{"qnh",1563},
{""}, {""},
#line 1189 "keys"
{"modelName",1184},
{""}, {""}, {""},
#line 981 "keys"
{"latitudeOfStretchingPole",976},
{""}, {""},
#line 979 "keys"
{"latitudeOfSouthernPole",974},
#line 1034 "keys"
{"localDefinitionNumber",1029},
#line 848 "keys"
{"gridName",843},
#line 181 "keys"
{"Nassigned",176},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1315 "keys"
{"numberOfSection",1310},
{""}, {""},
#line 375 "keys"
{"cfName",370},
{""}, {""}, {""}, {""},
#line 1818 "keys"
{"setCalendarId",1813},
{""},
#line 1391 "keys"
{"orderOfSPD",1386},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 885 "keys"
{"identificationNumber",880},
#line 1848 "keys"
{"southernLatitudeOfDomain",1843},
{""},
#line 1986 "keys"
{"twoOrdersOfSPD",1981},
#line 1939 "keys"
{"tiggeCentre",1934},
#line 1740 "keys"
{"scanPosition",1735},
#line 1396 "keys"
{"originalParameterNumber",1391},
{""}, {""},
#line 1484 "keys"
{"parameterName",1479},
{""},
#line 1050 "keys"
{"localSection",1045},
#line 1330 "keys"
{"numberOfVerticalGridDescriptors",1325},
{""},
#line 1906 "keys"
{"suiteName",1901},
{""}, {""},
#line 174 "keys"
{"NL",169},
{""},
#line 967 "keys"
{"latitudeOfCenterPoint",962},
#line 379 "keys"
{"changeDecimalPrecision",374},
#line 912 "keys"
{"interpretationOfNumberOfPoints",907},
#line 1329 "keys"
{"numberOfVerticalCoordinateValues",1324},
{""}, {""},
#line 183 "keys"
{"Nf",178},
#line 1943 "keys"
{"tiggeSection",1938},
{""}, {""}, {""}, {""},
#line 111 "keys"
{"LaR",106},
{""},
#line 294 "keys"
{"applicationIdentifier",289},
{""}, {""}, {""}, {""},
#line 126 "keys"
{"LoR",121},
#line 1332 "keys"
{"numberingOrderOfDiamonds",1327},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 924 "keys"
{"isEps",919},
{""}, {""}, {""},
#line 377 "keys"
{"cfVarName",372},
#line 1823 "keys"
{"shortName",1818},
#line 1566 "keys"
{"qfePresent",1561},
#line 1224 "keys"
{"nosigPresent",1219},
#line 338 "keys"
{"bitsPerValue",333},
{""},
#line 1295 "keys"
{"numberOfPartitions",1290},
{""},
#line 1328 "keys"
{"numberOfValues",1323},
{""}, {""}, {""},
#line 599 "keys"
{"dateOfForecastRun",594},
{""},
#line 968 "keys"
{"latitudeOfCenterPointInDegrees",963},
{""}, {""},
#line 2094 "keys"
{"widthOfSPD",2089},
{""}, {""}, {""}, {""}, {""}, {""},
#line 290 "keys"
{"angleOfRotationInDegrees",285},
{""}, {""}, {""},
#line 1570 "keys"
{"qnhPresent",1565},
{""}, {""},
#line 2117 "keys"
{"windVariableDirection",2112},
{""},
#line 601 "keys"
{"dateOfReference",596},
{""},
#line 1564 "keys"
{"pvlLocation",1559},
#line 626 "keys"
{"derivedForecast",621},
{""}, {""}, {""},
#line 337 "keys"
{"bitmapSectionPresent",332},
{""},
#line 1954 "keys"
{"timeOfReference",1949},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1987 "keys"
{"type",1982},
#line 2137 "keys"
{"year",2132},
#line 1575 "keys"
{"radialAngularSpacing",1570},
{""}, {""}, {""},
#line 523 "keys"
{"computeLaplacianOperator",518},
#line 1027 "keys"
{"listOfScaledFrequencies",1022},
{""}, {""},
#line 1916 "keys"
{"tableCode",1911},
{""},
#line 1912 "keys"
{"system",1907},
{""}, {""}, {""},
#line 1176 "keys"
{"minuteOfReference",1171},
{""}, {""},
#line 101 "keys"
{"K",96},
#line 579 "keys"
{"createNewData",574},
#line 1292 "keys"
{"numberOfPackedValues",1287},
#line 821 "keys"
{"functionCode",816},
#line 570 "keys"
{"correction3Part",565},
#line 1319 "keys"
{"numberOfSubsets",1314},
{""}, {""}, {""}, {""}, {""},
#line 2073 "keys"
{"verticalCoordinate",2068},
{""}, {""},
#line 1977 "keys"
{"trueLengthOfLastGroup",1972},
{""}, {""},
#line 877 "keys"
{"iDirectionIncrement",872},
{""}, {""}, {""},
#line 2142 "keys"
{"zero",2137},
{""},
#line 1266 "keys"
{"numberOfFloats",1261},
{""}, {""},
#line 765 "keys"
{"extractSubset",760},
{""},
#line 1922 "keys"
{"targetCompressionRatio",1917},
#line 307 "keys"
{"baseAddress",302},
{""}, {""}, {""},
#line 1062 "keys"
{"longitudeOfCenterPoint",1057},
#line 955 "keys"
{"landtype",950},
{""},
#line 532 "keys"
{"consensusCount",527},
{""}, {""}, {""},
#line 2136 "keys"
{"yLast",2131},
#line 664 "keys"
{"editionNumber",659},
{""}, {""},
#line 1822 "keys"
{"shapeOfVerificationArea",1817},
{""}, {""}, {""},
#line 1281 "keys"
{"numberOfLocalDefinitions",1276},
#line 1398 "keys"
{"originalSubCentreIdentifier",1393},
#line 1263 "keys"
{"numberOfDirections",1258},
{""},
#line 1750 "keys"
{"secondDimension",1745},
{""}, {""},
#line 1892 "keys"
{"subCentre",1887},
#line 1026 "keys"
{"listOfParametersUsedForClustering",1021},
#line 1803 "keys"
{"sectionNumber",1798},
#line 1136 "keys"
{"matchAerosolPacking",1131},
#line 1144 "keys"
{"md5Data",1139},
#line 611 "keys"
{"decimalPrecision",606},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 650 "keys"
{"dummyc",645},
#line 1105 "keys"
{"marsEndStep",1100},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1346 "keys"
{"offsetAfterLocalSection",1341},
{""}, {""}, {""}, {""},
#line 175 "keys"
{"NP",170},
{""}, {""},
#line 1771 "keys"
{"section0Pointer",1766},
{""}, {""}, {""}, {""}, {""}, {""},
#line 709 "keys"
{"epsContinous",704},
#line 1947 "keys"
{"tileClassification",1942},
{""},
#line 1087 "keys"
{"longitudeSexagesimal",1082},
{""}, {""}, {""}, {""},
#line 717 "keys"
{"expandedCodes",712},
{""}, {""}, {""}, {""}, {""}, {""},
#line 616 "keys"
{"defaultName",611},
{""}, {""}, {""},
#line 1262 "keys"
{"numberOfDiamonds",1257},
{""}, {""}, {""}, {""}, {""},
#line 1592 "keys"
{"rdbtimeSecond",1587},
{""},
#line 1260 "keys"
{"numberOfDataValues",1255},
{""}, {""},
#line 1555 "keys"
{"productDefinition",1550},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1800 "keys"
{"section8Pointer",1795},
{""}, {""}, {""},
#line 1160 "keys"
{"meanSize",1155},
{""}, {""}, {""},
#line 1815 "keys"
{"sensitiveAreaDomain",1810},
{""},
#line 1794 "keys"
{"section6",1789},
{""}, {""}, {""}, {""}, {""}, {""},
#line 29 "keys"
{"CDFstr",24},
{""}, {""}, {""}, {""}, {""}, {""},
#line 548 "keys"
{"coordinate2Start",543},
#line 1828 "keys"
{"siteElevation",1823},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 873 "keys"
{"hourOfReference",868},
{""}, {""}, {""}, {""},
#line 386 "keys"
{"channelNumber",381},
#line 1012 "keys"
{"levtype",1007},
#line 506 "keys"
{"clusterNumber",501},
{""}, {""}, {""}, {""}, {""},
#line 292 "keys"
{"angularPrecision",287},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 1734 "keys"
{"scaledValueOfSecondSize",1729},
{""}, {""}, {""},
#line 189 "keys"
{"Nx",184},
#line 722 "keys"
{"expandedNames",717},
#line 1308 "keys"
{"numberOfRadials",1303},
#line 1857 "keys"
{"spatialProcessing",1852},
{""},
#line 2074 "keys"
{"verticalCoordinateDefinition",2069},
#line 1347 "keys"
{"offsetAfterPadding",1342},
{""},
#line 1185 "keys"
{"modeNumber",1180},
{""}, {""}, {""}, {""}, {""},
#line 771 "keys"
{"extremeClockwiseWindDirection",766},
#line 256 "keys"
{"Xo",251},
#line 605 "keys"
{"datumSize",600},
{""},
#line 2025 "keys"
{"unitOfOffsetFromReferenceTime",2020},
{""}, {""},
#line 537 "keys"
{"controlForecastCluster",532},
{""}, {""}, {""}, {""}, {""},
#line 1196 "keys"
{"monthOfReference",1191},
{""},
#line 1064 "keys"
{"longitudeOfCentralPointInClusterDomain",1059},
{""}, {""}, {""},
#line 905 "keys"
{"integerPointValues",900},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1829 "keys"
{"siteId",1824},
{""},
#line 1051 "keys"
{"localSectionPresent",1046},
{""}, {""},
#line 778 "keys"
{"faLevelName",773},
#line 1864 "keys"
{"standardDeviation",1859},
#line 257 "keys"
{"Xp",252},
#line 1722 "keys"
{"scaledValueOfDistanceFromEnsembleMean",1717},
{""}, {""},
#line 1145 "keys"
{"md5DataSection",1140},
{""}, {""}, {""}, {""}, {""},
#line 1752 "keys"
{"secondDimensionPhysicalSignificance",1747},
#line 1736 "keys"
{"scaledValueOfStandardDeviation",1731},
{""},
#line 704 "keys"
{"ensembleForecastNumbers",699},
#line 768 "keys"
{"extractSubsetList",763},
#line 1556 "keys"
{"productDefinitionTemplateNumber",1551},
#line 705 "keys"
{"ensembleForecastNumbersList",700},
#line 343 "keys"
{"boustrophedonicOrdering",338},
#line 1548 "keys"
{"probContinous",1543},
{""},
#line 923 "keys"
{"isEPS",918},
#line 1110 "keys"
{"marsIdent",1105},
{""},
#line 1478 "keys"
{"paramId",1473},
{""},
#line 2092 "keys"
{"widthOfFirstOrderValues",2087},
{""},
#line 291 "keys"
{"angleOfRotationOfProjection",286},
{""},
#line 881 "keys"
{"iIncrement",876},
{""}, {""},
#line 1199 "keys"
{"mybits",1194},
#line 999 "keys"
{"legNumber",994},
{""}, {""}, {""}, {""},
#line 1737 "keys"
{"scaledValueOfStandardDeviationInTheCluster",1732},
{""},
#line 1272 "keys"
{"numberOfFrequencies",1267},
{""},
#line 983 "keys"
{"latitudeOfSubSatellitePoint",978},
{""}, {""}, {""},
#line 336 "keys"
{"bitmapPresent",331},
#line 1557 "keys"
{"productDefinitionTemplateNumberInternal",1552},
{""},
#line 973 "keys"
{"latitudeOfLastGridPoint",968},
#line 2135 "keys"
{"yFirst",2130},
{""}, {""}, {""},
#line 1693 "keys"
{"runwayState",1688},
#line 834 "keys"
{"globalDomain",829},
#line 1338 "keys"
{"obstype",1333},
{""}, {""}, {""}, {""}, {""},
#line 984 "keys"
{"latitudeOfSubSatellitePointInDegrees",979},
#line 1518 "keys"
{"preProcessingParameter",1513},
{""},
#line 1699 "keys"
{"scaleFactorAtReferencePoint",1694},
#line 563 "keys"
{"corr4Data",558},
{""},
#line 1964 "keys"
{"totalNumber",1959},
{""}, {""},
#line 1222 "keys"
{"northernLatitudeOfClusterDomain",1217},
{""}, {""},
#line 1190 "keys"
{"modelVersionDate",1185},
{""}, {""}, {""},
#line 974 "keys"
{"latitudeOfLastGridPointInDegrees",969},
{""}, {""}, {""}, {""},
#line 2014 "keys"
{"typicalDate",2009},
{""}, {""},
#line 568 "keys"
{"correction2Part",563},
#line 182 "keys"
{"Nb",177},
{""}, {""}, {""},
#line 777 "keys"
{"faFieldName",772},
{""},
#line 618 "keys"
{"defaultSequence",613},
#line 746 "keys"
{"extractAreaWestLongitude",741},
#line 1713 "keys"
{"scaleFactorOfSecondSize",1708},
#line 975 "keys"
{"latitudeOfNorthWestCornerOfArea",970},
#line 1107 "keys"
{"marsExpver",1102},
{""}, {""},
#line 104 "keys"
{"LLCOSP",99},
#line 1264 "keys"
{"numberOfDistributionFunctionParameters",1259},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 545 "keys"
{"coordinate1Start",540},
{""}, {""}, {""},
#line 922 "keys"
{"isCorrection",917},
{""}, {""}, {""}, {""},
#line 356 "keys"
{"ccccIdentifiers",351},
{""}, {""},
#line 623 "keys"
{"deleteExtraLocalSection",618},
{""},
#line 716 "keys"
{"expandedAbbreviations",711},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1701 "keys"
{"scaleFactorOfDistanceFromEnsembleMean",1696},
{""}, {""},
#line 689 "keys"
{"endOfFileAddress",684},
#line 1291 "keys"
{"numberOfOperationalForecastTube",1286},
{""},
#line 507 "keys"
{"clusterSize",502},
#line 842 "keys"
{"gridCoordinate",837},
#line 1847 "keys"
{"southernLatitudeOfClusterDomain",1842},
{""},
#line 1715 "keys"
{"scaleFactorOfStandardDeviation",1710},
#line 551 "keys"
{"coordinate3OfLastGridPoint",546},
#line 1727 "keys"
{"scaledValueOfFirstSize",1722},
#line 1155 "keys"
{"md5Structure",1150},
{""},
#line 28 "keys"
{"CDF",23},
#line 864 "keys"
{"heightOrPressureOfLevel",859},
{""},
#line 1543 "keys"
{"pressureLevel",1538},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1751 "keys"
{"secondDimensionCoordinateValueDefinition",1746},
#line 1177 "keys"
{"minutesAfterDataCutoff",1172},
{""}, {""}, {""},
#line 286 "keys"
{"analysisOffsets",281},
#line 1716 "keys"
{"scaleFactorOfStandardDeviationInTheCluster",1711},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1489 "keys"
{"partitionItems",1484},
{""}, {""}, {""}, {""}, {""}, {""},
#line 2051 "keys"
{"validityDate",2046},
{""}, {""}, {""},
#line 2066 "keys"
{"verificationDate",2061},
{""},
#line 1197 "keys"
{"monthlyVerificationDate",1192},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1106 "keys"
{"marsExperimentOffset",1101},
{""}, {""},
#line 1245 "keys"
{"numberOfChars",1240},
{""}, {""}, {""}, {""},
#line 1569 "keys"
{"qnhAPresent",1564},
#line 1367 "keys"
{"offsetSection6",1362},
#line 613 "keys"
{"defaultFaFieldName",608},
#line 2000 "keys"
{"typeOfLevel",1995},
#line 1768 "keys"
{"secondsOfReference",1763},
{""}, {""}, {""}, {""},
#line 2076 "keys"
{"verticalVisibilityCoded",2071},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 585 "keys"
{"dataKeys",580},
{""},
#line 1169 "keys"
{"methodNumber",1164},
{""}, {""},
#line 20 "keys"
{"Azi",15},
#line 1296 "keys"
{"numberOfPoints",1291},
{""},
#line 161 "keys"
{"N",156},
{""},
#line 707 "keys"
{"ensembleStandardDeviation",702},
{""}, {""}, {""}, {""}, {""},
#line 1249 "keys"
{"numberOfCodedValues",1244},
{""},
#line 100 "keys"
{"JS",95},
{""}, {""}, {""}, {""}, {""},
#line 1267 "keys"
{"numberOfForcasts",1262},
#line 1188 "keys"
{"modelIdentifier",1183},
#line 1902 "keys"
{"subSetK",1897},
{""}, {""},
#line 1252 "keys"
{"numberOfColumns",1247},
#line 11 "keys"
{"AA",6},
#line 588 "keys"
{"dataRepresentation",583},
{""},
#line 1008 "keys"
{"levelIndicator",1003},
#line 1720 "keys"
{"scaledFrequencies",1715},
{""}, {""}, {""}, {""},
#line 1733 "keys"
{"scaledValueOfSecondFixedSurface",1728},
#line 631 "keys"
{"dimensionNumber",626},
#line 939 "keys"
{"iterationNumber",934},
{""},
#line 566 "keys"
{"correction1Part",561},
{""},
#line 1846 "keys"
{"southPoleOnProjectionPlane",1841},
#line 1512 "keys"
{"plusOneinOrdersOfSPD",1507},
#line 634 "keys"
{"directionNumber",629},
{""}, {""},
#line 1706 "keys"
{"scaleFactorOfFirstSize",1701},
{""}, {""}, {""}, {""},
#line 279 "keys"
{"addExtraLocalSection",274},
{""}, {""}, {""},
#line 1560 "keys"
{"productionStatusOfProcessedData",1555},
{""},
#line 1490 "keys"
{"partitionNumber",1485},
{""},
#line 1696 "keys"
{"satelliteIdentifier",1691},
{""}, {""},
#line 1312 "keys"
{"numberOfReservedBytes",1307},
{""}, {""},
#line 1293 "keys"
{"numberOfParallelsBetweenAPoleAndTheEquator",1288},
{""}, {""}, {""},
#line 1256 "keys"
{"numberOfCoordinatesValues",1251},
#line 1485 "keys"
{"parameterNumber",1480},
{""}, {""},
#line 1984 "keys"
{"tubeNumber",1979},
{""},
#line 1889 "keys"
{"stretchingFactor",1884},
{""}, {""}, {""}, {""}, {""}, {""},
#line 560 "keys"
{"corr1Data",555},
{""},
#line 1153 "keys"
{"md5Section6",1148},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 176 "keys"
{"NR",171},
{""}, {""},
#line 1013 "keys"
{"libraryVersion",1008},
{""},
#line 1739 "keys"
{"scalingFactorForFrequencies",1734},
{""}, {""}, {""}, {""},
#line 1917 "keys"
{"tableNumber",1912},
#line 1697 "keys"
{"satelliteNumber",1692},
{""}, {""},
#line 61 "keys"
{"Experiment_Identifier",56},
{""}, {""},
#line 594 "keys"
{"dataTime",589},
{""},
#line 1890 "keys"
{"stretchingFactorScaled",1885},
#line 604 "keys"
{"dateTime",599},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 1723 "keys"
{"scaledValueOfDistributionFunctionParameter",1718},
{""}, {""},
#line 1067 "keys"
{"longitudeOfFirstGridPoint",1062},
{""},
#line 712 "keys"
{"epsStatisticsContinous",707},
{""}, {""}, {""},
#line 1243 "keys"
{"numberOfCategories",1238},
{""}, {""}, {""},
#line 1259 "keys"
{"numberOfDataPoints",1254},
{""}, {""}, {""},
#line 1614 "keys"
{"referenceValueError",1609},
{""}, {""},
#line 1065 "keys"
{"longitudeOfFirstDiamondCenterLine",1060},
#line 1918 "keys"
{"tableReference",1913},
{""}, {""}, {""},
#line 1068 "keys"
{"longitudeOfFirstGridPointInDegrees",1063},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1732 "keys"
{"scaledValueOfRadiusOfSphericalEarth",1727},
{""}, {""}, {""},
#line 1066 "keys"
{"longitudeOfFirstDiamondCenterLineInDegrees",1061},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1833 "keys"
{"sizeOfOffsets",1828},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 282 "keys"
{"aerosolbinnumber",277},
#line 1712 "keys"
{"scaleFactorOfSecondFixedSurface",1707},
{""}, {""}, {""},
#line 308 "keys"
{"baseDateEPS",303},
{""}, {""},
#line 1904 "keys"
{"subcentreOfAnalysis",1899},
{""}, {""},
#line 1344 "keys"
{"offsetAfterCentreLocalSection",1339},
{""}, {""}, {""},
#line 900 "keys"
{"inputExtendedDelayedDescriptorReplicationFactor",895},
{""},
#line 667 "keys"
{"elementsTable",662},
{""}, {""},
#line 810 "keys"
{"forecastPeriodTo",805},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1491 "keys"
{"partitionTable",1486},
{""}, {""}, {""},
#line 1250 "keys"
{"numberOfCoefficientsOrValuesUsedToSpecifyFirstDimensionCoordinateFunction",1245},
#line 1251 "keys"
{"numberOfCoefficientsOrValuesUsedToSpecifySecondDimensionCoordinateFunction",1246},
{""}, {""}, {""}, {""}, {""},
#line 786 "keys"
{"fgTime",781},
#line 562 "keys"
{"corr3Data",557},
{""}, {""}, {""},
#line 907 "keys"
{"integerScalingFactorAppliedToDirections",902},
#line 908 "keys"
{"integerScalingFactorAppliedToFrequencies",903},
#line 2009 "keys"
{"typeOfStatisticalProcessing",2004},
#line 1948 "keys"
{"tileIndex",1943},
{""}, {""}, {""}, {""}, {""},
#line 391 "keys"
{"classOfAnalysis",386},
#line 344 "keys"
{"bufrDataEncoded",339},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1111 "keys"
{"marsKeywords",1106},
{""}, {""}, {""},
#line 221 "keys"
{"TScalc",216},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 697 "keys"
{"endTimeStep",692},
{""}, {""},
#line 825 "keys"
{"g2grid",820},
#line 1702 "keys"
{"scaleFactorOfDistributionFunctionParameter",1697},
#line 1310 "keys"
{"numberOfRemaininChars",1305},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 576 "keys"
{"countTotal",571},
#line 1726 "keys"
{"scaledValueOfFirstFixedSurface",1721},
{""}, {""}, {""}, {""},
#line 220 "keys"
{"TS",215},
#line 1198 "keys"
{"multiplicationFactorForLatLong",1193},
{""}, {""}, {""},
#line 1194 "keys"
{"monthOfAnalysis",1189},
#line 2075 "keys"
{"verticalVisibility",2070},
#line 1584 "keys"
{"rdbSubtype",1579},
{""},
#line 1791 "keys"
{"section5",1786},
{""}, {""}, {""}, {""},
#line 1711 "keys"
{"scaleFactorOfRadiusOfSphericalEarth",1706},
#line 868 "keys"
{"horizontalCoordinateSupplement",863},
{""}, {""},
#line 824 "keys"
{"g1conceptsMasterDir",819},
{""}, {""}, {""},
#line 38 "keys"
{"DiInDegrees",33},
{""}, {""},
#line 867 "keys"
{"horizontalCoordinateDefinition",862},
{""}, {""}, {""}, {""}, {""},
#line 1244 "keys"
{"numberOfCharacters",1239},
{""}, {""},
#line 782 "keys"
{"falseNorthing",777},
{""}, {""},
#line 2019 "keys"
{"typicalSecond",2014},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 702 "keys"
{"energyNorm",697},
{""}, {""},
#line 1611 "keys"
{"referenceReflectivityForEchoTop",1606},
#line 1481 "keys"
{"parameterCategory",1476},
{""},
#line 866 "keys"
{"hideThis",861},
#line 1982 "keys"
{"tsectionNumber5",1977},
{""}, {""}, {""},
#line 598 "keys"
{"dateOfAnalysis",593},
{""},
#line 1268 "keys"
{"numberOfForecastsInCluster",1263},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1953 "keys"
{"timeOfAnalysis",1948},
#line 653 "keys"
{"earthIsOblate",648},
#line 1397 "keys"
{"originalParameterTableNumber",1392},
{""}, {""}, {""},
#line 1023 "keys"
{"listOfDistributionFunctionParameter",1018},
#line 643 "keys"
{"doExtractArea",638},
{""}, {""},
#line 809 "keys"
{"forecastPeriodFrom",804},
{""}, {""}, {""}, {""},
#line 128 "keys"
{"LoVInDegrees",123},
#line 813 "keys"
{"forecastTime",808},
{""}, {""}, {""},
#line 1383 "keys"
{"oneThousand",1378},
{""}, {""}, {""},
#line 2041 "keys"
{"unsignedIntegers",2036},
{""},
#line 561 "keys"
{"corr2Data",556},
{""}, {""},
#line 627 "keys"
{"dewPointTemperature",622},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 652 "keys"
{"dy",647},
{""}, {""}, {""}, {""},
#line 606 "keys"
{"day",601},
{""},
#line 1974 "keys"
{"totalNumberOfdimensions",1969},
{""}, {""},
#line 645 "keys"
{"doExtractSubsets",640},
{""}, {""},
#line 511 "keys"
{"cnmc_isac",506},
{""}, {""},
#line 2026 "keys"
{"unitOfTime",2021},
{""}, {""},
#line 1873 "keys"
{"startingAzimuth",1868},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1872 "keys"
{"startTimeStep",1867},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1058 "keys"
{"logTransform",1053},
#line 1888 "keys"
{"streamOfAnalysis",1883},
#line 1705 "keys"
{"scaleFactorOfFirstFixedSurface",1700},
{""}, {""},
#line 2141 "keys"
{"yearOfReference",2136},
#line 216 "keys"
{"Sub-Experiment_Identifier",211},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2004 "keys"
{"typeOfPreProcessing",1999},
{""}, {""}, {""}, {""},
#line 1192 "keys"
{"molarMass",1187},
{""}, {""}, {""}, {""},
#line 636 "keys"
{"directionScalingFactor",631},
{""}, {""}, {""}, {""}, {""},
#line 1793 "keys"
{"section5Pointer",1788},
{""}, {""},
#line 1615 "keys"
{"reflectivityCalibrationConstant",1610},
#line 1152 "keys"
{"md5Section5",1147},
{""}, {""},
#line 1118 "keys"
{"marsModel",1113},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1253 "keys"
{"numberOfComponents",1248},
{""}, {""}, {""}, {""},
#line 932 "keys"
{"is_tigge",927},
{""},
#line 1945 "keys"
{"tigge_name",1940},
#line 510 "keys"
{"clutterFilterIndicator",505},
{""}, {""}, {""}, {""},
#line 933 "keys"
{"is_uerra",928},
#line 1812 "keys"
{"section_8",1807},
{""},
#line 1248 "keys"
{"numberOfClusters",1243},
{""},
#line 1174 "keys"
{"minuteOfAnalysis",1169},
#line 110 "keys"
{"LaDInDegrees",105},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 647 "keys"
{"dummy",642},
#line 166 "keys"
{"NC",161},
{""}, {""}, {""},
#line 1502 "keys"
{"periodOfTime",1497},
#line 1166 "keys"
{"messageLength",1161},
{""}, {""}, {""},
#line 1279 "keys"
{"numberOfInts",1274},
{""}, {""},
#line 1825 "keys"
{"short_name",1820},
#line 1579 "keys"
{"radiusOfCentralCluster",1574},
{""}, {""}, {""},
#line 1879 "keys"
{"stepForClustering",1874},
#line 2035 "keys"
{"unitsOfSecondFixedSurface",2030},
#line 1978 "keys"
{"truncateDegrees",1973},
{""}, {""},
#line 1031 "keys"
{"localDefNumberOne",1026},
#line 2123 "keys"
{"xCoordinateOfOriginOfSectorImage",2118},
#line 958 "keys"
{"laplacianScalingFactor",953},
{""}, {""},
#line 577 "keys"
{"country",572},
{""}, {""}, {""}, {""}, {""},
#line 46 "keys"
{"DxInDegrees",41},
#line 1628 "keys"
{"resolutionAndComponentFlags",1623},
{""},
#line 1951 "keys"
{"timeIncrement",1946},
#line 1386 "keys"
{"operatingMode",1381},
{""}, {""}, {""},
#line 148 "keys"
{"MS",143},
#line 1729 "keys"
{"scaledValueOfLowerLimit",1724},
{""},
#line 1942 "keys"
{"tiggeModel",1937},
#line 254 "keys"
{"XR",249},
{""},
#line 1483 "keys"
{"parameterIndicator",1478},
#line 1930 "keys"
{"theMessage",1925},
{""},
#line 1057 "keys"
{"local_use",1052},
{""}, {""}, {""}, {""},
#line 1962 "keys"
{"totalInitialConditions",1957},
{""},
#line 871 "keys"
{"hourOfAnalysis",866},
{""},
#line 1931 "keys"
{"thisExperimentVersionNumber",1926},
{""},
#line 48 "keys"
{"Dy",43},
{""},
#line 859 "keys"
{"gts_header",854},
{""}, {""}, {""}, {""}, {""},
#line 619 "keys"
{"defaultShortName",614},
{""}, {""}, {""},
#line 1635 "keys"
{"resolutionAndComponentFlags8",1630},
{""}, {""}, {""}, {""}, {""},
#line 557 "keys"
{"coordinateIndexNumber",552},
#line 1109 "keys"
{"marsGrid",1104},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1836 "keys"
{"skew",1831},
{""}, {""}, {""}, {""}, {""},
#line 1280 "keys"
{"numberOfIterations",1275},
{""}, {""}, {""}, {""},
#line 1981 "keys"
{"tsectionNumber4",1976},
{""},
#line 1741 "keys"
{"scanningMode",1736},
#line 835 "keys"
{"grib1divider",830},
#line 936 "keys"
{"isectionNumber4",931},
{""}, {""}, {""}, {""}, {""},
#line 726 "keys"
{"expandedOriginalWidths",721},
{""}, {""},
#line 723 "keys"
{"expandedOriginalCodes",718},
{""}, {""},
#line 1387 "keys"
{"operationalForecastCluster",1382},
{""}, {""}, {""},
#line 1966 "keys"
{"totalNumberOfDataValuesMissingInStatisticalProcess",1961},
#line 1967 "keys"
{"totalNumberOfDirections",1962},
{""}, {""}, {""}, {""},
#line 366 "keys"
{"centralLongitude",361},
{""}, {""}, {""}, {""},
#line 1861 "keys"
{"spectralMode",1856},
{""}, {""},
#line 1113 "keys"
{"marsLamModel",1108},
#line 1599 "keys"
{"rectimeDay",1594},
{""},
#line 2101 "keys"
{"windGust",2096},
#line 1837 "keys"
{"skewness",1832},
#line 1915 "keys"
{"table2Version",1910},
{""},
#line 569 "keys"
{"correction3",564},
#line 1366 "keys"
{"offsetSection5",1361},
{""}, {""}, {""},
#line 1601 "keys"
{"rectimeMinute",1596},
{""},
#line 522 "keys"
{"compressedData",517},
#line 858 "keys"
{"gts_ddhh00",853},
#line 725 "keys"
{"expandedOriginalScales",720},
#line 1046 "keys"
{"localMinute",1041},
#line 1991 "keys"
{"typeOfCompressionUsed",1986},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2093 "keys"
{"widthOfLengths",2088},
{""},
#line 897 "keys"
{"indicatorOfUnitOfTimeRange",892},
{""},
#line 862 "keys"
{"headersOnly",857},
{""},
#line 614 "keys"
{"defaultFaLevelName",609},
#line 952 "keys"
{"kurt",947},
#line 505 "keys"
{"clusterMember9",500},
#line 1790 "keys"
{"section4Pointer",1785},
#line 1047 "keys"
{"localMonth",1042},
{""},
#line 2036 "keys"
{"unknown",2031},
{""}, {""}, {""}, {""},
#line 349 "keys"
{"calendarIdPresent",344},
{""}, {""},
#line 1029 "keys"
{"localDay",1024},
#line 1521 "keys"
{"predefined_grid",1516},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1708 "keys"
{"scaleFactorOfLowerLimit",1703},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1746 "keys"
{"scanningMode8",1741},
{""}, {""}, {""}, {""}, {""}, {""},
#line 724 "keys"
{"expandedOriginalReferences",719},
{""}, {""}, {""}, {""},
#line 1313 "keys"
{"numberOfRows",1308},
{""}, {""}, {""}, {""}, {""},
#line 1070 "keys"
{"longitudeOfLastGridPoint",1065},
{""},
#line 1787 "keys"
{"section4",1782},
{""}, {""}, {""},
#line 1206 "keys"
{"nameOfFirstFixedSurface",1201},
{""}, {""}, {""},
#line 1603 "keys"
{"reducedGrid",1598},
#line 953 "keys"
{"kurtosis",948},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 899 "keys"
{"inputDelayedDescriptorReplicationFactor",894},
#line 1558 "keys"
{"productIdentifier",1553},
{""}, {""},
#line 807 "keys"
{"forecastOrSingularVectorNumber",802},
#line 735 "keys"
{"extendedFlag",730},
#line 392 "keys"
{"climateDateFrom",387},
#line 2034 "keys"
{"unitsOfFirstFixedSurface",2029},
#line 982 "keys"
{"latitudeOfStretchingPoleInDegrees",977},
#line 504 "keys"
{"clusterMember8",499},
{""}, {""}, {""},
#line 1989 "keys"
{"typeOfAuxiliaryInformation",1984},
#line 347 "keys"
{"bufrTemplate",342},
#line 1619 "keys"
{"representationType",1614},
#line 788 "keys"
{"fileConsistencyFlags",783},
#line 1858 "keys"
{"spatialSmoothingOfProduct",1853},
{""}, {""}, {""}, {""},
#line 1938 "keys"
{"thresholdIndicator",1933},
#line 495 "keys"
{"clusterIdentifier",490},
{""}, {""},
#line 288 "keys"
{"angleMultiplier",283},
#line 1025 "keys"
{"listOfModelIdentifiers",1020},
{""}, {""}, {""}, {""},
#line 1476 "keys"
{"paleontologicalOffset",1471},
{""},
#line 661 "keys"
{"easternLongitudeOfDomain",656},
{""},
#line 2091 "keys"
{"westernLongitudeOfDomain",2086},
{""}, {""}, {""}, {""}, {""},
#line 880 "keys"
{"iDirectionIncrementInDegrees",875},
#line 1234 "keys"
{"numberOfAnalysis",1229},
{""},
#line 1638 "keys"
{"roundedMarsLatitude",1633},
#line 297 "keys"
{"auxiliary",292},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 1866 "keys"
{"standardParallelInMicrodegrees",1861},
{""}, {""}, {""}, {""}, {""},
#line 980 "keys"
{"latitudeOfSouthernPoleInDegrees",975},
{""}, {""},
#line 1868 "keys"
{"startOfMessage",1863},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1561 "keys"
{"projectionCenterFlag",1556},
#line 865 "keys"
{"heightPressureEtcOfLevels",860},
{""}, {""}, {""}, {""},
#line 1139 "keys"
{"matchTimeRepres",1134},
{""},
#line 528 "keys"
{"conceptsLocalMarsDirAll",523},
#line 1933 "keys"
{"thisMarsStream",1928},
{""},
#line 1278 "keys"
{"numberOfIntegers",1273},
#line 1254 "keys"
{"numberOfContributingSpectralBands",1249},
#line 572 "keys"
{"correction4Part",567},
#line 737 "keys"
{"extraDimensionPresent",732},
{""}, {""},
#line 911 "keys"
{"internationalDataSubCategory",906},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1399 "keys"
{"originatingCentre",1394},
{""},
#line 37 "keys"
{"DiGiven",32},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1401 "keys"
{"originatingCentrer",1396},
#line 1913 "keys"
{"systemNumber",1908},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1269 "keys"
{"numberOfForecastsInEnsemble",1264},
{""}, {""}, {""},
#line 2125 "keys"
{"xDirectionGridLength",2120},
#line 1963 "keys"
{"totalLength",1958},
{""}, {""}, {""},
#line 530 "keys"
{"conceptsMasterMarsDir",525},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1869 "keys"
{"startOfRange",1864},
{""},
#line 770 "keys"
{"extractedDateTimeNumberOfSubsets",765},
#line 1780 "keys"
{"section2Present",1775},
{""},
#line 837 "keys"
{"grib2LocalSectionPresent",832},
{""}, {""}, {""}, {""}, {""}, {""},
#line 838 "keys"
{"grib2divider",833},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1181 "keys"
{"missingValueManagement",1176},
{""}, {""}, {""}, {""}, {""},
#line 1588 "keys"
{"rdbtimeDay",1583},
#line 883 "keys"
{"iScansPositively",878},
#line 1048 "keys"
{"localNumberOfObservations",1043},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1969 "keys"
{"totalNumberOfFrequencies",1964},
#line 1590 "keys"
{"rdbtimeMinute",1585},
{""}, {""}, {""},
#line 892 "keys"
{"incrementOfLengths",887},
{""},
#line 2077 "keys"
{"visibility",2072},
#line 1343 "keys"
{"offsetAfterBitmap",1338},
{""},
#line 2043 "keys"
{"updateSequenceNumber",2038},
{""}, {""}, {""}, {""},
#line 766 "keys"
{"extractSubsetIntervalEnd",761},
#line 1776 "keys"
{"section1Pointer",1771},
#line 1639 "keys"
{"roundedMarsLevelist",1634},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1860 "keys"
{"spectralDataRepresentationType",1855},
{""}, {""},
#line 218 "keys"
{"TAFstr",213},
#line 521 "keys"
{"componentIndex",516},
{""},
#line 1841 "keys"
{"southEastLatitudeOfVerficationArea",1836},
{""}, {""},
#line 1247 "keys"
{"numberOfClusterLowResolution",1242},
{""},
#line 767 "keys"
{"extractSubsetIntervalStart",762},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1402 "keys"
{"override_large_constant_fields",1397},
#line 1133 "keys"
{"masterTableNumber",1128},
{""},
#line 1955 "keys"
{"timeRangeIndicator",1950},
{""}, {""},
#line 609 "keys"
{"dayOfReference",604},
{""}, {""}, {""},
#line 1767 "keys"
{"secondsOfAnalysis",1762},
{""}, {""}, {""},
#line 1905 "keys"
{"subdivisionsOfBasicAngle",1900},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1562 "keys"
{"projectionCentreFlag",1557},
{""}, {""},
#line 836 "keys"
{"grib2LocalSectionNumber",831},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1063 "keys"
{"longitudeOfCenterPointInDegrees",1058},
{""}, {""},
#line 1322 "keys"
{"numberOfTimeSteps",1317},
#line 1207 "keys"
{"nameOfSecondFixedSurface",1202},
{""},
#line 691 "keys"
{"endOfInterval",686},
{""}, {""},
#line 373 "keys"
{"centuryOfReference",368},
#line 1626 "keys"
{"reservedSection3",1621},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 74 "keys"
{"GDSPresent",69},
{""},
#line 1609 "keys"
{"referenceOfLengths",1604},
{""}, {""},
#line 1909 "keys"
{"swapScanningLon",1904},
{""},
#line 995 "keys"
{"latitudinalDirectionGridLength",990},
{""},
#line 2040 "keys"
{"unpackedValues",2035},
{""}, {""},
#line 2049 "keys"
{"uuidOfVGrid",2044},
{""}, {""},
#line 565 "keys"
{"correction1",560},
{""},
#line 1919 "keys"
{"tablesLocalDir",1914},
{""}, {""},
#line 1108 "keys"
{"marsForecastMonth",1103},
{""}, {""}, {""},
#line 1374 "keys"
{"oneMillionConstant",1369},
{""},
#line 658 "keys"
{"eastLongitudeOfCluster",653},
{""},
#line 2088 "keys"
{"westLongitudeOfCluster",2083},
#line 632 "keys"
{"dimensionType",627},
{""},
#line 2122 "keys"
{"wrongPadding",2117},
{""},
#line 1282 "keys"
{"numberOfLogicals",1277},
{""}, {""}, {""},
#line 1572 "keys"
{"qualityControl",1567},
{""}, {""},
#line 212 "keys"
{"SecondOfModelVersion",207},
#line 1365 "keys"
{"offsetSection4",1360},
{""}, {""},
#line 851 "keys"
{"groupLengths",846},
#line 1404 "keys"
{"packedValues",1399},
{""}, {""}, {""},
#line 276 "keys"
{"accumulationInterval",271},
{""}, {""}, {""},
#line 937 "keys"
{"isotopeIdentificationNumber",932},
{""}, {""}, {""},
#line 1633 "keys"
{"resolutionAndComponentFlags6",1628},
{""}, {""},
#line 656 "keys"
{"earthMinorAxis",651},
{""}, {""}, {""},
#line 595 "keys"
{"dataType",590},
{""}, {""},
#line 846 "keys"
{"gridDefinitionTemplateNumber",841},
#line 1786 "keys"
{"section3Pointer",1781},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 1770 "keys"
{"section0Length",1765},
{""},
#line 513 "keys"
{"codeType",508},
#line 1992 "keys"
{"typeOfDistributionFunction",1987},
#line 1944 "keys"
{"tiggeSuiteID",1939},
#line 1216 "keys"
{"northLatitudeOfCluster",1211},
#line 1990 "keys"
{"typeOfCalendar",1985},
#line 99 "keys"
{"J",94},
{""}, {""}, {""}, {""},
#line 940 "keys"
{"jDirectionIncrement",935},
{""},
#line 1127 "keys"
{"marsType",1122},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1801 "keys"
{"sectionLengthLimitForEnsembles",1796},
#line 1883 "keys"
{"stepType",1878},
{""},
#line 1843 "keys"
{"southEastLongitudeOfVerficationArea",1838},
#line 567 "keys"
{"correction2",562},
#line 1522 "keys"
{"predefined_grid_values",1517},
{""}, {""},
#line 805 "keys"
{"forecastLeadTime",800},
{""}, {""}, {""},
#line 1504 "keys"
{"perturbationNumber",1499},
#line 1004 "keys"
{"lengthOfMessage",999},
#line 1125 "keys"
{"marsStream1",1120},
{""},
#line 275 "keys"
{"_numberOfValues",270},
{""}, {""}, {""},
#line 582 "keys"
{"dataCategory",577},
{""}, {""}, {""},
#line 1799 "keys"
{"section8Length",1794},
{""}, {""}, {""}, {""},
#line 850 "keys"
{"gridType",845},
{""}, {""}, {""}, {""},
#line 1617 "keys"
{"reportType",1612},
#line 1335 "keys"
{"observationGeneratingProcessIdentifier",1330},
{""},
#line 2124 "keys"
{"xCoordinateOfSubSatellitePoint",2119},
{""}, {""}, {""}, {""},
#line 190 "keys"
{"Ny",185},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1014 "keys"
{"listMembersMissing",1009},
{""}, {""}, {""},
#line 790 "keys"
{"firstDimensionCoordinateValueDefinition",785},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 972 "keys"
{"latitudeOfIcosahedronPole",967},
{""},
#line 1844 "keys"
{"southLatitudeOfCluster",1839},
{""}, {""}, {""}, {""},
#line 1610 "keys"
{"referenceOfWidths",1605},
{""}, {""}, {""}, {""},
#line 2027 "keys"
{"unitOfTimeIncrement",2022},
{""}, {""}, {""},
#line 1288 "keys"
{"numberOfModels",1283},
#line 1045 "keys"
{"localLongitude2",1040},
#line 1859 "keys"
{"spectralDataRepresentationMode",1854},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1290 "keys"
{"numberOfOctetsExtraDescriptors",1285},
#line 1137 "keys"
{"matchLandType",1132},
{""}, {""}, {""},
#line 217 "keys"
{"TAF",212},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1126 "keys"
{"marsStream2",1121},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 811 "keys"
{"forecastProbabilityNumber",806},
{""},
#line 1908 "keys"
{"swapScanningLat",1903},
{""},
#line 1044 "keys"
{"localLongitude1",1039},
{""}, {""}, {""},
#line 1842 "keys"
{"southEastLongitudeOfLPOArea",1837},
#line 1779 "keys"
{"section2Pointer",1774},
#line 554 "keys"
{"coordinate4OfLastGridPoint",549},
#line 1965 "keys"
{"totalNumberOfClusters",1960},
{""},
#line 1849 "keys"
{"sp1",1844},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1265 "keys"
{"numberOfEffectiveValues",1260},
{""},
#line 818 "keys"
{"frequency",813},
{""}, {""}, {""},
#line 2130 "keys"
{"yCoordinateOfOriginOfSectorImage",2125},
#line 1920 "keys"
{"tablesMasterDir",1915},
#line 2020 "keys"
{"typicalTime",2015},
{""},
#line 1056 "keys"
{"local_padding",1051},
{""},
#line 1772 "keys"
{"section1",1767},
#line 2023 "keys"
{"unexpandedDescriptors",2018},
{""}, {""},
#line 49 "keys"
{"DyInDegrees",44},
#line 1283 "keys"
{"numberOfMembersInCluster",1278},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1855 "keys"
{"spare1",1850},
{""}, {""}, {""},
#line 2024 "keys"
{"unexpandedDescriptorsEncoded",2019},
{""}, {""}, {""},
#line 281 "keys"
{"aerosolType",276},
#line 1271 "keys"
{"numberOfForecastsInTube",1266},
#line 106 "keys"
{"La1",101},
{""},
#line 901 "keys"
{"inputShortDelayedDescriptorReplicationFactor",896},
{""}, {""},
#line 1862 "keys"
{"spectralType",1857},
{""},
#line 123 "keys"
{"Lo1",118},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 118 "keys"
{"Latin1",113},
{""}, {""},
#line 113 "keys"
{"Lar1",108},
{""},
#line 1097 "keys"
{"mAngleMultiplier",1092},
#line 951 "keys"
{"kindOfProduct",946},
{""}, {""},
#line 660 "keys"
{"easternLongitudeOfClusterDomain",655},
#line 141 "keys"
{"Lor1",136},
#line 2090 "keys"
{"westernLongitudeOfClusterDomain",2085},
{""}, {""}, {""},
#line 1300 "keys"
{"numberOfPointsAlongSecondAxis",1295},
{""},
#line 1009 "keys"
{"levelType",1004},
{""}, {""}, {""}, {""},
#line 2138 "keys"
{"yearOfAnalysis",2133},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1988 "keys"
{"typeOfAnalysis",1983},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1559 "keys"
{"productType",1554},
{""},
#line 340 "keys"
{"boot_edition",335},
{""},
#line 393 "keys"
{"climateDateTo",388},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1932 "keys"
{"thisMarsClass",1927},
{""}, {""}, {""}, {""}, {""},
#line 806 "keys"
{"forecastMonth",801},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 465 "keys"
{"cloudsCode3",460},
{""}, {""}, {""}, {""}, {""}, {""},
#line 779 "keys"
{"faModelName",774},
{""}, {""},
#line 195 "keys"
{"P1",190},
#line 944 "keys"
{"jIncrement",939},
{""}, {""}, {""},
#line 854 "keys"
{"groupWidth",849},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1585 "keys"
{"rdbType",1580},
{""}, {""},
#line 1968 "keys"
{"totalNumberOfForecastProbabilities",1963},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 2052 "keys"
{"validityTime",2047},
{""},
#line 1608 "keys"
{"referenceForGroupWidths",1603},
{""}, {""}, {""},
#line 607 "keys"
{"dayOfAnalysis",602},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1840 "keys"
{"southEastLatitudeOfLPOArea",1835},
{""}, {""}, {""},
#line 378 "keys"
{"cfVarNameECMF",373},
#line 1824 "keys"
{"shortNameECMF",1819},
{""},
#line 1154 "keys"
{"md5Section7",1149},
{""}, {""}, {""}, {""},
#line 969 "keys"
{"latitudeOfCentralPointInClusterDomain",964},
{""}, {""},
#line 1622 "keys"
{"reserved1",1617},
#line 855 "keys"
{"groupWidths",850},
#line 615 "keys"
{"defaultFaModelName",610},
#line 1345 "keys"
{"offsetAfterData",1340},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 508 "keys"
{"clusteringDomain",503},
#line 1514 "keys"
{"postAuxiliary",1509},
{""},
#line 1184 "keys"
{"mixedCoordinateFieldFlag",1179},
{""},
#line 945 "keys"
{"jPointsAreConsecutive",940},
{""},
#line 305 "keys"
{"backgroundProcess",300},
#line 1515 "keys"
{"postAuxiliaryArrayPresent",1510},
{""},
#line 1894 "keys"
{"subDefinitions2",1889},
#line 1072 "keys"
{"longitudeOfNorthWestCornerOfArea",1067},
{""}, {""},
#line 1505 "keys"
{"perturbedType",1500},
{""}, {""},
#line 1754 "keys"
{"secondLatitudeInDegrees",1749},
{""}, {""},
#line 644 "keys"
{"doExtractDateTime",639},
#line 624 "keys"
{"deleteLocalDefinition",619},
{""}, {""},
#line 1393 "keys"
{"orientationOfTheGrid",1388},
{""}, {""},
#line 1275 "keys"
{"numberOfGroups",1270},
{""}, {""},
#line 727 "keys"
{"expandedTypes",722},
#line 1871 "keys"
{"startStepInHours",1866},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1075 "keys"
{"longitudeOfSouthEastCornerOfArea",1070},
#line 1893 "keys"
{"subDefinitions1",1888},
#line 1076 "keys"
{"longitudeOfSouthernPole",1071},
{""}, {""},
#line 1297 "keys"
{"numberOfPointsAlongAMeridian",1292},
#line 890 "keys"
{"ijDirectionIncrementGiven",885},
{""}, {""},
#line 1810 "keys"
{"section_6",1805},
{""}, {""},
#line 299 "keys"
{"averaging1Flag",294},
{""},
#line 1625 "keys"
{"reservedSection2",1620},
#line 815 "keys"
{"formatVersionMajorNumber",810},
#line 1202 "keys"
{"n3",1197},
{""},
#line 1246 "keys"
{"numberOfClusterHighResolution",1241},
#line 1607 "keys"
{"referenceForGroupLengths",1602},
#line 845 "keys"
{"gridDefinitionSection",840},
{""},
#line 1258 "keys"
{"numberOfDataMatrices",1253},
{""}, {""}, {""}, {""},
#line 1077 "keys"
{"longitudeOfSouthernPoleInDegrees",1072},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 828 "keys"
{"generalExtended2ordr",823},
{""}, {""}, {""},
#line 267 "keys"
{"Yo",262},
{""}, {""}, {""},
#line 769 "keys"
{"extractedAreaNumberOfSubsets",764},
{""}, {""}, {""},
#line 527 "keys"
{"conceptsLocalDirECMF",522},
{""},
#line 1358 "keys"
{"offsetFromOriginToInnerBound",1353},
#line 675 "keys"
{"endGridDefinition",670},
{""}, {""}, {""},
#line 1851 "keys"
{"sp3",1846},
{""},
#line 1400 "keys"
{"originatingCentreOfAnalysis",1395},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 882 "keys"
{"iScansNegatively",877},
{""}, {""}, {""},
#line 1130 "keys"
{"mars_labeling",1125},
{""}, {""},
#line 268 "keys"
{"Yp",263},
{""},
#line 1782 "keys"
{"section3",1777},
{""}, {""}, {""},
#line 878 "keys"
{"iDirectionIncrementGiven",873},
#line 571 "keys"
{"correction4",566},
#line 280 "keys"
{"additionalFlagPresent",275},
{""},
#line 333 "keys"
{"binaryScaleFactor",328},
#line 1623 "keys"
{"reservedNeedNotBePresent",1618},
{""},
#line 1298 "keys"
{"numberOfPointsAlongAParallel",1293},
{""}, {""}, {""}, {""},
#line 1036 "keys"
{"localExtensionPadding",1031},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 296 "keys"
{"attributeOfTile",291},
{""}, {""},
#line 1159 "keys"
{"meanRVR4",1154},
#line 1616 "keys"
{"remarkPresent",1611},
{""}, {""}, {""}, {""}, {""},
#line 1388 "keys"
{"optimisationTime",1383},
{""}, {""}, {""},
#line 1150 "keys"
{"md5Section3",1145},
{""}, {""}, {""}, {""},
#line 2111 "keys"
{"windSpeedTrend4",2106},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1362 "keys"
{"offsetSection1",1357},
#line 759 "keys"
{"extractDateTimeSecondEnd",754},
{""},
#line 2132 "keys"
{"yDirectionGridLength",2127},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 310 "keys"
{"baseTimeEPS",305},
{""},
#line 1632 "keys"
{"resolutionAndComponentFlags4",1627},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1356 "keys"
{"offsetEndSection4",1351},
{""},
#line 761 "keys"
{"extractDateTimeSecondStart",756},
{""},
#line 2015 "keys"
{"typicalDay",2010},
{""},
#line 1146 "keys"
{"md5GridSection",1141},
{""},
#line 27 "keys"
{"CCCC",22},
{""},
#line 1901 "keys"
{"subSetJ",1896},
{""}, {""},
#line 1721 "keys"
{"scaledValueOfCentralWaveNumber",1716},
{""},
#line 2017 "keys"
{"typicalMinute",2012},
{""}, {""}, {""}, {""}, {""},
#line 1795 "keys"
{"section6Length",1790},
{""}, {""}, {""}, {""},
#line 950 "keys"
{"keySat",945},
{""}, {""},
#line 1276 "keys"
{"numberOfGroupsOfDataValues",1271},
#line 1191 "keys"
{"modelVersionTime",1186},
{""}, {""}, {""},
#line 1055 "keys"
{"localYear",1050},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2121 "keys"
{"windVariableDirectionTrend4",2116},
{""}, {""}, {""}, {""}, {""}, {""},
#line 114 "keys"
{"Lar1InDegrees",109},
#line 934 "keys"
{"isectionNumber2",929},
{""},
#line 1636 "keys"
{"rootGroupObjectHeaderAddress",1631},
#line 1946 "keys"
{"tigge_short_name",1941},
{""}, {""},
#line 142 "keys"
{"Lor1InDegrees",137},
#line 801 "keys"
{"flagShowingPostAuxiliaryArrayInUse",796},
{""}, {""},
#line 1718 "keys"
{"scaleValuesBy",1713},
{""},
#line 107 "keys"
{"La1InDegrees",102},
{""}, {""}, {""}, {""}, {""}, {""},
#line 124 "keys"
{"Lo1InDegrees",119},
{""},
#line 1405 "keys"
{"packingError",1400},
#line 1339 "keys"
{"oceanAtmosphereCoupling",1334},
#line 764 "keys"
{"extractDateTimeYearStart",759},
#line 1994 "keys"
{"typeOfFirstFixedSurface",1989},
{""},
#line 1744 "keys"
{"scanningMode6",1739},
{""},
#line 1747 "keys"
{"scanningModeForOneDiamond",1742},
#line 1041 "keys"
{"localLatitude1",1036},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 948 "keys"
{"keyData",943},
#line 1394 "keys"
{"orientationOfTheGridInDegrees",1389},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 879 "keys"
{"iDirectionIncrementGridLength",874},
{""}, {""},
#line 1546 "keys"
{"primaryMissingValue",1541},
{""}, {""}, {""},
#line 2038 "keys"
{"unpackedError",2033},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1060 "keys"
{"longitudeFirstInDegrees",1055},
{""}, {""},
#line 1996 "keys"
{"typeOfGrid",1991},
{""}, {""}, {""}, {""},
#line 744 "keys"
{"extractAreaNorthLatitude",739},
#line 455 "keys"
{"cloudsCode1",450},
{""}, {""}, {""}, {""}, {""}, {""},
#line 502 "keys"
{"clusterMember6",497},
{""},
#line 637 "keys"
{"dirty_statistics",632},
#line 635 "keys"
{"directionOfVariation",630},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1178 "keys"
{"minutesAfterReferenceTimeOfDataCutoff",1173},
{""}, {""}, {""}, {""},
#line 1700 "keys"
{"scaleFactorOfCentralWaveNumber",1695},
{""}, {""},
#line 1501 "keys"
{"percentileValue",1496},
#line 1316 "keys"
{"numberOfSingularVectorsComputed",1311},
#line 745 "keys"
{"extractAreaSouthLatitude",740},
{""}, {""}, {""},
#line 1488 "keys"
{"parametersVersion",1483},
#line 300 "keys"
{"averaging2Flag",295},
#line 819 "keys"
{"frequencyNumber",814},
{""},
#line 39 "keys"
{"DiInMetres",34},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1201 "keys"
{"n2",1196},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 753 "keys"
{"extractDateTimeMinuteEnd",748},
#line 1299 "keys"
{"numberOfPointsAlongFirstAxis",1294},
{""}, {""}, {""}, {""},
#line 1289 "keys"
{"numberOfOctectsForNumberOfPoints",1284},
{""}, {""}, {""},
#line 1255 "keys"
{"numberOfControlForecastTube",1250},
#line 1882 "keys"
{"stepRangeInHours",1877},
{""}, {""}, {""},
#line 781 "keys"
{"falseEasting",776},
#line 1578 "keys"
{"radiusInMetres",1573},
{""}, {""}, {""}, {""},
#line 755 "keys"
{"extractDateTimeMinuteStart",750},
{""},
#line 756 "keys"
{"extractDateTimeMonthEnd",751},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1850 "keys"
{"sp2",1845},
#line 758 "keys"
{"extractDateTimeMonthStart",753},
#line 720 "keys"
{"expandedCrex_widths",715},
#line 1314 "keys"
{"numberOfSecondOrderPackedValues",1309},
#line 718 "keys"
{"expandedCrex_scales",713},
#line 460 "keys"
{"cloudsCode2",455},
#line 622 "keys"
{"deleteCalendarId",617},
#line 1080 "keys"
{"longitudeOfSubSatellitePoint",1075},
{""}, {""},
#line 40 "keys"
{"Dj",35},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1956 "keys"
{"timeRangeIndicatorFromStepRange",1951},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1081 "keys"
{"longitudeOfSubSatellitePointInDegrees",1076},
{""}, {""}, {""},
#line 1856 "keys"
{"spare2",1851},
{""}, {""}, {""}, {""}, {""},
#line 925 "keys"
{"isHindcast",920},
{""}, {""},
#line 1213 "keys"
{"normAtFinalTime",1208},
#line 108 "keys"
{"La2",103},
{""}, {""}, {""},
#line 970 "keys"
{"latitudeOfFirstGridPoint",965},
{""},
#line 2131 "keys"
{"yCoordinateOfSubSatellitePoint",2126},
#line 125 "keys"
{"Lo2",120},
#line 1629 "keys"
{"resolutionAndComponentFlags1",1624},
{""}, {""}, {""},
#line 1773 "keys"
{"section1Flags",1768},
{""}, {""},
#line 120 "keys"
{"Latin2",115},
#line 1364 "keys"
{"offsetSection3",1359},
#line 1024 "keys"
{"listOfEnsembleForecastNumbers",1019},
#line 115 "keys"
{"Lar2",110},
{""}, {""}, {""}, {""}, {""},
#line 642 "keys"
{"distinctLongitudes",637},
#line 143 "keys"
{"Lor2",138},
#line 719 "keys"
{"expandedCrex_units",714},
{""}, {""},
#line 42 "keys"
{"DjInDegrees",37},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1971 "keys"
{"totalNumberOfIterations",1966},
{""}, {""}, {""},
#line 1627 "keys"
{"reservedSection4",1622},
{""},
#line 2055 "keys"
{"variationOfVisibilityDirection",2050},
{""}, {""},
#line 1550 "keys"
{"probProductDefinition",1545},
#line 1317 "keys"
{"numberOfSingularVectorsEvolved",1312},
{""}, {""}, {""}, {""}, {""},
#line 2056 "keys"
{"variationOfVisibilityDirectionAngle",2051},
{""}, {""}, {""}, {""}, {""},
#line 1941 "keys"
{"tiggeLocalVersion",1936},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1101 "keys"
{"marsClass1",1096},
{""}, {""}, {""}, {""},
#line 1940 "keys"
{"tiggeLAMName",1935},
#line 312 "keys"
{"basicAngleOfTheInitialProductionDomain",307},
#line 1547 "keys"
{"primaryMissingValueSubstitute",1542},
#line 1593 "keys"
{"rdbtimeYear",1588},
{""}, {""}, {""}, {""},
#line 196 "keys"
{"P2",191},
#line 162 "keys"
{"N1",157},
{""}, {""},
#line 116 "keys"
{"Lar2InDegrees",111},
{""}, {""},
#line 1792 "keys"
{"section5Length",1787},
{""}, {""}, {""},
#line 144 "keys"
{"Lor2InDegrees",139},
{""},
#line 2007 "keys"
{"typeOfSecondFixedSurface",2002},
{""}, {""},
#line 1595 "keys"
{"realPartOf00",1590},
{""},
#line 1148 "keys"
{"md5Section1",1143},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1032 "keys"
{"localDefNumberTwo",1027},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1214 "keys"
{"normAtInitialTime",1209},
{""}, {""}, {""}, {""},
#line 372 "keys"
{"centuryOfAnalysis",367},
{""}, {""}, {""}, {""}, {""},
#line 1270 "keys"
{"numberOfForecastsInTheCluster",1265},
{""}, {""},
#line 47 "keys"
{"DxInMetres",42},
{""}, {""}, {""}, {""}, {""}, {""},
#line 355 "keys"
{"cavokOrVisibility",350},
{""}, {""}, {""}, {""},
#line 904 "keys"
{"instrumentType",899},
#line 1993 "keys"
{"typeOfEnsembleForecast",1988},
#line 538 "keys"
{"coordAveraging0",533},
{""}, {""}, {""},
#line 1631 "keys"
{"resolutionAndComponentFlags3",1626},
{""}, {""}, {""},
#line 1783 "keys"
{"section3Flags",1778},
#line 1695 "keys"
{"satelliteID",1690},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1039 "keys"
{"localHour",1034},
{""}, {""}, {""},
#line 931 "keys"
{"is_s2s",926},
{""},
#line 1789 "keys"
{"section4Padding",1784},
{""}, {""},
#line 1832 "keys"
{"sizeOfLength",1827},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 556 "keys"
{"coordinateFlag2",551},
{""},
#line 966 "keys"
{"latitudeLongitudeValues",961},
#line 1600 "keys"
{"rectimeHour",1595},
#line 1149 "keys"
{"md5Section2",1144},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1580 "keys"
{"radiusOfClusterDomain",1575},
{""}, {""},
#line 2010 "keys"
{"typeOfTimeIncrement",2005},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2112 "keys"
{"windUnits",2107},
#line 555 "keys"
{"coordinateFlag1",550},
{""},
#line 536 "keys"
{"constituentType",531},
{""},
#line 796 "keys"
{"firstOrderValues",791},
{""},
#line 249 "keys"
{"WRAPstr",244},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 1156 "keys"
{"meanRVR1",1151},
{""}, {""},
#line 816 "keys"
{"formatVersionMinorNumber",811},
{""}, {""},
#line 729 "keys"
{"experimentVersionNumber",724},
{""}, {""}, {""}, {""},
#line 1071 "keys"
{"longitudeOfLastGridPointInDegrees",1066},
#line 1885 "keys"
{"stepUnits",1880},
{""}, {""}, {""},
#line 1503 "keys"
{"periodOfTimeIntervals",1498},
{""},
#line 273 "keys"
{"_TS",268},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1809 "keys"
{"section_5",1804},
#line 2002 "keys"
{"typeOfOriginalFieldValues",1997},
{""}, {""}, {""}, {""}, {""}, {""},
#line 145 "keys"
{"M",140},
#line 94 "keys"
{"II",89},
{""}, {""},
#line 869 "keys"
{"horizontalDimensionProcessed",864},
{""}, {""}, {""}, {""},
#line 1183 "keys"
{"mixedCoordinateDefinition",1178},
#line 334 "keys"
{"bitMapIndicator",329},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1179 "keys"
{"missingDataFlag",1174},
{""}, {""}, {""},
#line 1303 "keys"
{"numberOfPointsAlongXAxis",1298},
{""}, {""}, {""}, {""},
#line 1788 "keys"
{"section4Length",1783},
{""},
#line 1630 "keys"
{"resolutionAndComponentFlags2",1625},
#line 1134 "keys"
{"masterTablesVersionNumber",1129},
{""}, {""}, {""}, {""}, {""}, {""},
#line 638 "keys"
{"disableGrib1LocalSection",633},
#line 1757 "keys"
{"secondOrderOfDifferentWidth",1752},
{""}, {""}, {""},
#line 820 "keys"
{"frequencyScalingFactor",815},
#line 1363 "keys"
{"offsetSection2",1358},
{""}, {""}, {""}, {""}, {""},
#line 1927 "keys"
{"templatesLocalDir",1922},
{""},
#line 752 "keys"
{"extractDateTimeHourStart",747},
#line 542 "keys"
{"coordAveragingTims",537},
#line 2118 "keys"
{"windVariableDirectionTrend1",2113},
{""}, {""}, {""},
#line 985 "keys"
{"latitudeOfTangencyPoint",980},
#line 1311 "keys"
{"numberOfRepresentativeMember",1306},
{""}, {""}, {""},
#line 1735 "keys"
{"scaledValueOfSecondWavelength",1730},
#line 732 "keys"
{"experimentVersionNumberOfAnalysis",727},
#line 1195 "keys"
{"monthOfEndOfOverallTimeInterval",1190},
{""}, {""}, {""}, {""},
#line 248 "keys"
{"WRAP",243},
#line 350 "keys"
{"calendarIdentification",345},
{""}, {""}, {""},
#line 354 "keys"
{"categoryType",349},
{""},
#line 1018 "keys"
{"listMembersUsed",1013},
{""}, {""},
#line 1863 "keys"
{"sphericalHarmonics",1858},
{""}, {""},
#line 798 "keys"
{"flagForAnyFurtherInformation",793},
{""}, {""},
#line 198 "keys"
{"PUnset",193},
{""}, {""}, {""},
#line 1929 "keys"
{"theHindcastMarsStream",1924},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1061 "keys"
{"longitudeLastInDegrees",1056},
#line 799 "keys"
{"flagForIrregularGridCoordinateList",794},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1895 "keys"
{"subLocalDefinition1",1890},
#line 85 "keys"
{"GTSstr",80},
{""}, {""}, {""}, {""}, {""}, {""},
#line 648 "keys"
{"dummy1",643},
{""},
#line 1233 "keys"
{"numberMissingFromAveragesOrAccumulations",1228},
{""}, {""},
#line 550 "keys"
{"coordinate3OfFirstGridPoint",545},
{""}, {""}, {""},
#line 470 "keys"
{"cloudsCode4",465},
{""}, {""}, {""}, {""},
#line 1867 "keys"
{"startOfHeaders",1862},
{""}, {""},
#line 1694 "keys"
{"sampleSizeOfModelClimate",1689},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1756 "keys"
{"secondOrderFlags",1751},
{""}, {""}, {""}, {""},
#line 1042 "keys"
{"localLatitude2",1037},
{""}, {""},
#line 928 "keys"
{"isSatelliteType",923},
{""}, {""}, {""}, {""}, {""},
#line 692 "keys"
{"endOfMessage",687},
{""},
#line 1796 "keys"
{"section7",1791},
{""}, {""},
#line 793 "keys"
{"firstLatitudeInDegrees",788},
{""},
#line 1544 "keys"
{"pressureUnits",1539},
{""}, {""},
#line 947 "keys"
{"julianDay",942},
{""}, {""}, {""}, {""}, {""},
#line 84 "keys"
{"GTS",79},
#line 1775 "keys"
{"section1Padding",1770},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 2005 "keys"
{"typeOfProcessedData",2000},
{""}, {""},
#line 826 "keys"
{"gaussianGridName",821},
{""}, {""}, {""},
#line 1003 "keys"
{"lengthOfHeaders",998},
{""}, {""},
#line 2013 "keys"
{"typicalCentury",2008},
{""},
#line 263 "keys"
{"YR",258},
{""},
#line 1589 "keys"
{"rdbtimeHour",1584},
{""},
#line 1897 "keys"
{"subLocalDefinitionLength1",1892},
{""}, {""}, {""},
#line 800 "keys"
{"flagForNormalOrStaggeredGrid",795},
#line 593 "keys"
{"dataSubCategory",588},
#line 1743 "keys"
{"scanningMode5",1738},
#line 1714 "keys"
{"scaleFactorOfSecondWavelength",1709},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1802 "keys"
{"sectionLengthLimitForProbability",1797},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2030 "keys"
{"unitsBias",2025},
#line 844 "keys"
{"gridDefinitionDescription",839},
{""}, {""}, {""}, {""}, {""},
#line 1835 "keys"
{"sizeOfPostAuxiliaryArrayPlusOne",1830},
{""},
#line 943 "keys"
{"jDirectionIncrementInDegrees",938},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1038 "keys"
{"localFlagLatestVersion",1033},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1730 "keys"
{"scaledValueOfMajorAxisOfOblateSpheroidEarth",1725},
#line 728 "keys"
{"expandedUnits",723},
#line 608 "keys"
{"dayOfEndOfOverallTimeInterval",603},
{""},
#line 1728 "keys"
{"scaledValueOfFirstWavelength",1723},
{""}, {""},
#line 1634 "keys"
{"resolutionAndComponentFlags7",1629},
{""}, {""}, {""},
#line 1158 "keys"
{"meanRVR3",1153},
{""}, {""}, {""}, {""},
#line 178 "keys"
{"NT",173},
#line 250 "keys"
{"X1",245},
#line 1972 "keys"
{"totalNumberOfTileAttributePairs",1967},
#line 501 "keys"
{"clusterMember5",496},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 762 "keys"
{"extractDateTimeYearEnd",757},
{""},
#line 1095 "keys"
{"ls_labeling",1090},
#line 930 "keys"
{"is_rotated_grid",925},
{""}, {""}, {""}, {""}, {""}, {""},
#line 185 "keys"
{"Nj",180},
#line 1093 "keys"
{"lowerThreshold",1088},
{""}, {""},
#line 41 "keys"
{"DjGiven",36},
{""}, {""}, {""},
#line 1392 "keys"
{"orderOfSpatialDifferencing",1387},
#line 1774 "keys"
{"section1Length",1769},
{""}, {""}, {""},
#line 1724 "keys"
{"scaledValueOfEarthMajorAxis",1719},
{""}, {""},
#line 1725 "keys"
{"scaledValueOfEarthMinorAxis",1720},
#line 485 "keys"
{"cloudsTitle3",480},
{""}, {""},
#line 589 "keys"
{"dataRepresentationTemplateNumber",584},
#line 1219 "keys"
{"northWestLatitudeOfVerficationArea",1214},
{""}, {""}, {""},
#line 1785 "keys"
{"section3Padding",1780},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1205 "keys"
{"nameECMF",1200},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 2067 "keys"
{"verifyingMonth",2062},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2120 "keys"
{"windVariableDirectionTrend3",2115},
#line 1517 "keys"
{"preBitmapValues",1512},
#line 1652 "keys"
{"runwayDepositState4",1647},
{""}, {""}, {""}, {""}, {""},
#line 1151 "keys"
{"md5Section4",1146},
#line 515 "keys"
{"codedNumberOfGroups",510},
#line 946 "keys"
{"jScansPositively",941},
{""}, {""}, {""}, {""}, {""}, {""},
#line 549 "keys"
{"coordinate3Flag",544},
{""}, {""}, {""}, {""}, {""}, {""},
#line 964 "keys"
{"latitudeFirstInDegrees",959},
{""}, {""}, {""}, {""},
#line 367 "keys"
{"centralLongitudeInMicrodegrees",362},
#line 2046 "keys"
{"upperThreshold",2041},
#line 303 "keys"
{"azimuthalWidth",298},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1094 "keys"
{"lowerThresholdValue",1089},
{""}, {""},
#line 1884 "keys"
{"stepTypeInternal",1879},
{""}, {""},
#line 1709 "keys"
{"scaleFactorOfMajorAxisOfOblateSpheroidEarth",1704},
{""},
#line 1102 "keys"
{"marsClass2",1097},
{""},
#line 1707 "keys"
{"scaleFactorOfFirstWavelength",1702},
{""}, {""}, {""},
#line 1852 "keys"
{"spaceUnitFlag",1847},
{""}, {""}, {""}, {""}, {""}, {""},
#line 2139 "keys"
{"yearOfCentury",2134},
#line 163 "keys"
{"N2",158},
{""}, {""},
#line 1497 "keys"
{"patch_precip_fp",1492},
#line 1808 "keys"
{"section_4",1803},
{""}, {""}, {""},
#line 2032 "keys"
{"unitsECMF",2027},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1637 "keys"
{"rootTablesDir",1632},
#line 1970 "keys"
{"totalNumberOfGridPoints",1965},
{""}, {""}, {""},
#line 590 "keys"
{"dataRepresentationType",585},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 167 "keys"
{"NC1",162},
#line 1784 "keys"
{"section3Length",1779},
{""},
#line 1703 "keys"
{"scaleFactorOfEarthMajorAxis",1698},
{""}, {""},
#line 1704 "keys"
{"scaleFactorOfEarthMinorAxis",1699},
{""},
#line 1813 "keys"
{"selectStepTemplateInstant",1808},
#line 1926 "keys"
{"temperatureAndDewpointPresent",1921},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 187 "keys"
{"NrInRadiusOfEarth",182},
{""},
#line 1778 "keys"
{"section2Padding",1773},
#line 1073 "keys"
{"longitudeOfReferencePoint",1068},
{""}, {""},
#line 2047 "keys"
{"upperThresholdValue",2042},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1221 "keys"
{"northWestLongitudeOfVerficationArea",1216},
{""},
#line 1924 "keys"
{"tempPressureUnits",1919},
{""}, {""},
#line 2126 "keys"
{"xDirectionGridLengthInMetres",2121},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1074 "keys"
{"longitudeOfReferencePointInDegrees",1069},
{""}, {""}, {""},
#line 997 "keys"
{"legBaseDate",992},
{""},
#line 1368 "keys"
{"offsetSection7",1363},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1814 "keys"
{"selectStepTemplateInterval",1809},
{""},
#line 1131 "keys"
{"mask",1126},
{""}, {""}, {""},
#line 2109 "keys"
{"windSpeedTrend2",2104},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2021 "keys"
{"typicalYear",2016},
{""},
#line 654 "keys"
{"earthMajorAxis",649},
{""},
#line 1403 "keys"
{"pack",1398},
{""}, {""},
#line 2127 "keys"
{"xDirectionGridLengthInMillimetres",2122},
{""}, {""}, {""},
#line 1903 "keys"
{"subSetM",1898},
{""},
#line 1273 "keys"
{"numberOfGridInReference",1268},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2008 "keys"
{"typeOfSizeInterval",2003},
{""},
#line 2108 "keys"
{"windSpeedTrend1",2103},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1005 "keys"
{"lengthOfTimeRange",1000},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 1157 "keys"
{"meanRVR2",1152},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 371 "keys"
{"centreForTable2",366},
#line 1309 "keys"
{"numberOfReforecastYearsInModelClimate",1304},
{""}, {""}, {""},
#line 2003 "keys"
{"typeOfPacking",1998},
{""}, {""}, {""},
#line 50 "keys"
{"DyInMetres",45},
{""}, {""}, {""},
#line 1220 "keys"
{"northWestLongitudeOfLPOArea",1215},
{""}, {""}, {""},
#line 1777 "keys"
{"section2Length",1772},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 304 "keys"
{"backgroundGeneratingProcessIdentifier",299},
{""}, {""}, {""},
#line 1147 "keys"
{"md5Headers",1142},
{""}, {""}, {""},
#line 2037 "keys"
{"unpack",2032},
{""}, {""}, {""}, {""},
#line 894 "keys"
{"indicatorOfTypeOfLevel",889},
#line 546 "keys"
{"coordinate2End",541},
{""}, {""}, {""},
#line 1742 "keys"
{"scanningMode4",1737},
{""}, {""}, {""}, {""},
#line 2039 "keys"
{"unpackedSubsetPrecision",2034},
{""},
#line 274 "keys"
{"_leg_number",269},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1755 "keys"
{"secondOfEndOfOverallTimeInterval",1750},
{""}, {""}, {""}, {""}, {""}, {""},
#line 389 "keys"
{"checkInternalVersion",384},
#line 1928 "keys"
{"templatesMasterDir",1923},
{""},
#line 2119 "keys"
{"windVariableDirectionTrend2",2114},
{""}, {""}, {""}, {""},
#line 1567 "keys"
{"qfeUnits",1562},
{""}, {""},
#line 823 "keys"
{"g1conceptsLocalDirAll",818},
{""},
#line 2100 "keys"
{"windDirectionTrend4",2095},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1839 "keys"
{"sourceOfGridDefinition",1834},
{""},
#line 98 "keys"
{"ITN",93},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1571 "keys"
{"qnhUnits",1566},
{""}, {""}, {""}, {""}, {""},
#line 500 "keys"
{"clusterMember4",495},
{""}, {""}, {""}, {""}, {""}, {""},
#line 547 "keys"
{"coordinate2Flag",542},
{""},
#line 574 "keys"
{"countOfGroupLengths",569},
{""},
#line 1486 "keys"
{"parameterUnits",1481},
#line 1980 "keys"
{"tsectionNumber3",1975},
{""}, {""},
#line 475 "keys"
{"cloudsTitle1",470},
#line 935 "keys"
{"isectionNumber3",930},
#line 1896 "keys"
{"subLocalDefinition2",1891},
{""}, {""},
#line 149 "keys"
{"MinuteOfModelVersion",144},
#line 2054 "keys"
{"variationOfVisibility",2049},
#line 1175 "keys"
{"minuteOfEndOfOverallTimeInterval",1170},
{""},
#line 1648 "keys"
{"runwayDepositCodeState4",1643},
#line 649 "keys"
{"dummy2",644},
#line 1054 "keys"
{"localUsePresent",1049},
{""}, {""}, {""}, {""}, {""},
#line 177 "keys"
{"NRj",172},
{""}, {""},
#line 1591 "keys"
{"rdbtimeMonth",1586},
{""}, {""},
#line 1187 "keys"
{"modelErrorType",1182},
{""}, {""},
#line 1973 "keys"
{"totalNumberOfTubes",1968},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 791 "keys"
{"firstDimensionPhysicalSignificance",786},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1321 "keys"
{"numberOfTimeRange",1316},
{""}, {""},
#line 1640 "keys"
{"roundedMarsLongitude",1635},
{""}, {""}, {""},
#line 374 "keys"
{"centuryOfReferenceTimeOfData",369},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1218 "keys"
{"northWestLatitudeOfLPOArea",1213},
{""},
#line 2072 "keys"
{"versionOfModelClimate",2067},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 164 "keys"
{"NAT",159},
{""}, {""}, {""}, {""}, {""},
#line 480 "keys"
{"cloudsTitle2",475},
#line 750 "keys"
{"extractDateTimeHourEnd",745},
{""}, {""}, {""}, {""},
#line 1898 "keys"
{"subLocalDefinitionLength2",1893},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 30 "keys"
{"CLNOMA",25},
{""},
#line 157 "keys"
{"Model_Additional_Information",152},
{""}, {""}, {""},
#line 1112 "keys"
{"marsKeywords1",1107},
{""}, {""}, {""}, {""},
#line 659 "keys"
{"eastLongitudeOfDomainOfTubing",654},
#line 514 "keys"
{"codedNumberOfFirstOrderPackedValues",509},
#line 2089 "keys"
{"westLongitudeOfDomainOfTubing",2084},
{""}, {""},
#line 365 "keys"
{"centralClusterDefinition",360},
#line 1797 "keys"
{"section7Length",1792},
{""}, {""},
#line 1354 "keys"
{"offsetBeforePV",1349},
{""}, {""},
#line 543 "keys"
{"coordinate1End",538},
{""}, {""}, {""}, {""}, {""},
#line 621 "keys"
{"definitionFilesVersion",616},
{""},
#line 1140 "keys"
{"matrixBitmapsPresent",1135},
#line 620 "keys"
{"defaultTypeOfLevel",615},
{""}, {""}, {""}, {""}, {""}, {""},
#line 160 "keys"
{"MonthOfModelVersion",155},
{""}, {""},
#line 1232 "keys"
{"numberIncludedInAverage",1227},
#line 1098 "keys"
{"mBasicAngle",1093},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 252 "keys"
{"X2",247},
{""}, {""}, {""},
#line 56 "keys"
{"Ensemble_Combination_Number",51},
{""}, {""}, {""}, {""},
#line 2060 "keys"
{"variationOfVisibilityDirectionTrend4",2055},
{""}, {""}, {""}, {""},
#line 1217 "keys"
{"northLatitudeOfDomainOfTubing",1212},
#line 57 "keys"
{"Ensemble_Identifier",52},
#line 345 "keys"
{"bufrHeaderCentre",340},
{""},
#line 1235 "keys"
{"numberOfBits",1230},
#line 1731 "keys"
{"scaledValueOfMinorAxisOfOblateSpheroidEarth",1726},
#line 1738 "keys"
{"scaledValueOfUpperLimit",1733},
{""}, {""}, {""}, {""},
#line 247 "keys"
{"WMO",242},
{""}, {""}, {""},
#line 1649 "keys"
{"runwayDepositState1",1644},
{""}, {""},
#line 1527 "keys"
{"presentTrend4",1522},
{""},
#line 1353 "keys"
{"offsetBeforePL",1348},
{""}, {""}, {""}, {""}, {""}, {""},
#line 544 "keys"
{"coordinate1Flag",539},
{""}, {""}, {""}, {""}, {""}, {""},
#line 2016 "keys"
{"typicalHour",2011},
{""},
#line 976 "keys"
{"latitudeOfReferencePoint",971},
{""}, {""}, {""}, {""}, {""},
#line 1414 "keys"
{"padding_grid90_1",1409},
#line 119 "keys"
{"Latin1InDegrees",114},
#line 1834 "keys"
{"sizeOfPostAuxiliaryArray",1829},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 741 "keys"
{"extractAreaEastLongitude",736},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1516 "keys"
{"powerOfTenUsedToScaleClimateWeight",1511},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 1336 "keys"
{"observationType",1331},
{""}, {""},
#line 1805 "keys"
{"section_1",1800},
{""}, {""},
#line 1845 "keys"
{"southLatitudeOfDomainOfTubing",1840},
{""}, {""}, {""}, {""}, {""}, {""},
#line 497 "keys"
{"clusterMember10",492},
{""},
#line 978 "keys"
{"latitudeOfSouthEastCornerOfArea",973},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1899 "keys"
{"subLocalDefinitionNumber1",1894},
{""}, {""}, {""}, {""}, {""}, {""},
#line 575 "keys"
{"countOfICEFieldsUsed",570},
{""},
#line 1352 "keys"
{"offsetBeforeData",1347},
#line 1997 "keys"
{"typeOfHorizontalLine",1992},
{""}, {""}, {""},
#line 540 "keys"
{"coordAveraging2",535},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 278 "keys"
{"addEmptySection2",273},
#line 941 "keys"
{"jDirectionIncrementGiven",936},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1360 "keys"
{"offsetICEFieldsUsed",1355},
{""}, {""}, {""},
#line 1499 "keys"
{"pentagonalResolutionParameterK",1494},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1305 "keys"
{"numberOfPointsUsed",1300},
{""}, {""}, {""},
#line 1350 "keys"
{"offsetBSection6",1345},
#line 1229 "keys"
{"numberInMixedCoordinateDefinition",1224},
#line 539 "keys"
{"coordAveraging1",534},
#line 1934 "keys"
{"thisMarsType",1929},
{""}, {""},
#line 1710 "keys"
{"scaleFactorOfMinorAxisOfOblateSpheroidEarth",1705},
#line 1717 "keys"
{"scaleFactorOfUpperLimit",1712},
{""}, {""}, {""}, {""},
#line 1680 "keys"
{"runwayFrictionCodeValueState4",1675},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 168 "keys"
{"NC2",163},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 219 "keys"
{"TIDE",214},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1668 "keys"
{"runwayDesignatorState4",1663},
{""}, {""}, {""},
#line 1084 "keys"
{"longitudeOfThePolePoint",1079},
{""}, {""},
#line 891 "keys"
{"implementationDateOfModelCycle",886},
{""},
#line 87 "keys"
{"HDF5str",82},
{""}, {""}, {""}, {""},
#line 1688 "keys"
{"runwayFrictionCoefficientState4",1683},
{""}, {""}, {""}, {""},
#line 1596 "keys"
{"recentWeather",1591},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1684 "keys"
{"runwayFrictionCoefficientCodeState4",1679},
#line 222 "keys"
{"TT",217},
{""}, {""}, {""}, {""}, {""},
#line 1085 "keys"
{"longitudeOfThePolePointInDegrees",1080},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1318 "keys"
{"numberOfStepsUsedForClustering",1313},
{""}, {""}, {""}, {""}, {""}, {""},
#line 255 "keys"
{"XRInMetres",250},
#line 8 "keys"
{"************_PRODUCT_***************",3},
{""}, {""}, {""},
#line 534 "keys"
{"constantAntennaElevationAngle",529},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 2057 "keys"
{"variationOfVisibilityDirectionTrend1",2052},
{""}, {""},
#line 971 "keys"
{"latitudeOfFirstGridPointInDegrees",966},
#line 1017 "keys"
{"listMembersMissing4",1012},
{""},
#line 535 "keys"
{"constantFieldHalfByte",530},
#line 170 "keys"
{"NG",165},
{""}, {""},
#line 1257 "keys"
{"numberOfDataBinsAlongRadials",1252},
{""},
#line 1950 "keys"
{"timeCoordinateDefinition",1945},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 410 "keys"
{"cloudsAbbreviation4",405},
#line 942 "keys"
{"jDirectionIncrementGridLength",937},
{""}, {""}, {""}, {""},
#line 1765 "keys"
{"secondaryMissingValue",1760},
{""}, {""}, {""}, {""},
#line 1307 "keys"
{"numberOfRadarSitesUsed",1302},
{""}, {""}, {""}, {""}, {""},
#line 376 "keys"
{"cfNameECMF",371},
#line 1651 "keys"
{"runwayDepositState3",1646},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1760 "keys"
{"secondaryBitmap",1755},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1910 "keys"
{"swapScanningX",1905},
#line 672 "keys"
{"endDayTrend3",667},
#line 2097 "keys"
{"windDirectionTrend1",2092},
{""},
#line 1406 "keys"
{"packingType",1401},
{""},
#line 1545 "keys"
{"primaryBitmap",1540},
{""}, {""}, {""}, {""}, {""},
#line 2133 "keys"
{"yDirectionGridLengthInMetres",2128},
#line 1880 "keys"
{"stepInHours",1875},
{""}, {""},
#line 121 "keys"
{"Latin2InDegrees",116},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 490 "keys"
{"cloudsTitle4",485},
{""},
#line 684 "keys"
{"endMinuteTrend4",679},
{""},
#line 496 "keys"
{"clusterMember1",491},
{""}, {""},
#line 43 "keys"
{"DjInMetres",38},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1135 "keys"
{"matchAerosolBinNumber",1130},
{""}, {""}, {""},
#line 1961 "keys"
{"totalAerosolBinsNumbers",1956},
{""},
#line 1807 "keys"
{"section_3",1802},
#line 1284 "keys"
{"numberOfMissing",1279},
{""}, {""}, {""},
#line 1645 "keys"
{"runwayDepositCodeState1",1640},
#line 949 "keys"
{"keyMore",944},
#line 2134 "keys"
{"yDirectionGridLengthInMillimetres",2129},
{""},
#line 2095 "keys"
{"widthOfWidths",2090},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 896 "keys"
{"indicatorOfUnitForTimeRange",891},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1083 "keys"
{"longitudeOfThePoleOfStretching",1078},
{""}, {""}, {""}, {""},
#line 860 "keys"
{"halfByte",855},
{""}, {""}, {""},
#line 2059 "keys"
{"variationOfVisibilityDirectionTrend3",2054},
#line 1766 "keys"
{"secondaryMissingValueSubstitute",1761},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 916 "keys"
{"isCavok",911},
{""}, {""},
#line 1677 "keys"
{"runwayFrictionCodeValueState1",1672},
#line 66 "keys"
{"ExtremeValuesInMaximumRVR4",61},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1761 "keys"
{"secondaryBitmapPresent",1756},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 730 "keys"
{"experimentVersionNumber1",725},
{""}, {""}, {""},
#line 1001 "keys"
{"lengthIncrementForTheGroupLengths",996},
{""}, {""}, {""}, {""},
#line 1762 "keys"
{"secondaryBitmaps",1757},
{""},
#line 1665 "keys"
{"runwayDesignatorState1",1660},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1285 "keys"
{"numberOfMissingInStatisticalProcess",1280},
#line 696 "keys"
{"endStepInHours",691},
{""}, {""}, {""}, {""}, {""},
#line 1685 "keys"
{"runwayFrictionCoefficientState1",1680},
#line 272 "keys"
{"_T",267},
{""}, {""}, {""},
#line 469 "keys"
{"cloudsCode3Trend4",464},
{""},
#line 1349 "keys"
{"offsetBSection5",1344},
{""}, {""}, {""}, {""},
#line 1681 "keys"
{"runwayFrictionCoefficientCodeState1",1676},
{""}, {""}, {""}, {""},
#line 1995 "keys"
{"typeOfGeneratingProcess",1990},
#line 1323 "keys"
{"numberOfUnexpandedDescriptors",1318},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1551 "keys"
{"probabilityType",1546},
{""}, {""}, {""}, {""}, {""}, {""},
#line 856 "keys"
{"gts_CCCC",851},
#line 1573 "keys"
{"qualityControlIndicator",1568},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 640 "keys"
{"distanceFromTubeToEnsembleMean",635},
{""}, {""}, {""},
#line 34 "keys"
{"Date_E4",29},
#line 1763 "keys"
{"secondaryBitmapsCount",1758},
{""}, {""},
#line 872 "keys"
{"hourOfEndOfOverallTimeInterval",867},
{""}, {""}, {""}, {""}, {""}, {""},
#line 965 "keys"
{"latitudeLastInDegrees",960},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 657 "keys"
{"earthMinorAxisInMetres",652},
#line 2018 "keys"
{"typicalMonth",2013},
{""}, {""}, {""},
#line 1524 "keys"
{"presentTrend1",1519},
{""}, {""}, {""},
#line 2058 "keys"
{"variationOfVisibilityDirectionTrend2",2053},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1679 "keys"
{"runwayFrictionCodeValueState3",1674},
{""}, {""}, {""}, {""}, {""}, {""},
#line 553 "keys"
{"coordinate4OfFirstGridPoint",548},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1470 "keys"
{"padding_sec1_loc",1465},
{""}, {""}, {""},
#line 987 "keys"
{"latitudeOfThePolePoint",982},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1667 "keys"
{"runwayDesignatorState3",1662},
{""},
#line 1357 "keys"
{"offsetFreeFormData",1352},
{""}, {""}, {""},
#line 1552 "keys"
{"probabilityTypeName",1547},
{""}, {""},
#line 1650 "keys"
{"runwayDepositState2",1645},
{""}, {""}, {""}, {""},
#line 1687 "keys"
{"runwayFrictionCoefficientState3",1682},
#line 600 "keys"
{"dateOfIceFieldUsed",595},
{""},
#line 2099 "keys"
{"windDirectionTrend3",2094},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1683 "keys"
{"runwayFrictionCoefficientCodeState3",1678},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1261 "keys"
{"numberOfDaysInClimateSamplingWindow",1256},
#line 743 "keys"
{"extractAreaLongitudeRank",738},
{""},
#line 1660 "keys"
{"runwayDepthOfDepositState4",1655},
{""}, {""}, {""}, {""}, {""},
#line 499 "keys"
{"clusterMember3",494},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1495 "keys"
{"pastTendencyRVR3",1490},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 749 "keys"
{"extractDateTimeDayStart",744},
{""}, {""},
#line 1647 "keys"
{"runwayDepositCodeState3",1642},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1806 "keys"
{"section_2",1801},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 158 "keys"
{"Model_Identifier",153},
#line 383 "keys"
{"changeIndicatorTrend4",378},
#line 1900 "keys"
{"subLocalDefinitionNumber2",1895},
{""}, {""}, {""},
#line 63 "keys"
{"ExtremeValuesInMaximumRVR1",58},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 93 "keys"
{"ICPLSIZE",88},
#line 670 "keys"
{"endDayTrend1",665},
{""}, {""}, {""}, {""},
#line 1678 "keys"
{"runwayFrictionCodeValueState2",1673},
{""}, {""},
#line 1294 "keys"
{"numberOfParametersUsedForClustering",1289},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1231 "keys"
{"numberInTheGridCoordinateList",1226},
{""}, {""}, {""}, {""}, {""}, {""},
#line 731 "keys"
{"experimentVersionNumber2",726},
{""}, {""},
#line 466 "keys"
{"cloudsCode3Trend1",461},
#line 1052 "keys"
{"localTablesVersion",1047},
#line 147 "keys"
{"METARstr",142},
{""}, {""}, {""},
#line 1656 "keys"
{"runwayDepthOfDepositCodeState4",1651},
{""},
#line 1666 "keys"
{"runwayDesignatorState2",1661},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 1686 "keys"
{"runwayFrictionCoefficientState2",1681},
{""}, {""}, {""},
#line 1237 "keys"
{"numberOfBitsForScaledGroupLengths",1232},
{""},
#line 31 "keys"
{"DELETE",26},
{""}, {""}, {""}, {""}, {""},
#line 1682 "keys"
{"runwayFrictionCoefficientCodeState2",1677},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1277 "keys"
{"numberOfHorizontalPoints",1272},
{""}, {""}, {""}, {""},
#line 360 "keys"
{"ceilingAndVisibilityOK",355},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1128 "keys"
{"marsType1",1123},
{""}, {""}, {""},
#line 464 "keys"
{"cloudsCode2Trend4",459},
{""}, {""},
#line 671 "keys"
{"endDayTrend2",666},
{""},
#line 991 "keys"
{"latitudeWhereDxAndDyAreSpecified",986},
{""},
#line 1533 "keys"
{"presentWeather2Present",1528},
{""}, {""}, {""}, {""}, {""},
#line 2110 "keys"
{"windSpeedTrend3",2105},
{""}, {""}, {""},
#line 552 "keys"
{"coordinate4Flag",547},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 992 "keys"
{"latitudeWhereDxAndDyAreSpecifiedInDegrees",987},
#line 395 "keys"
{"cloudsAbbreviation1",390},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 65 "keys"
{"ExtremeValuesInMaximumRVR3",60},
{""}, {""}, {""}, {""}, {""}, {""},
#line 986 "keys"
{"latitudeOfThePoleOfStretching",981},
#line 1526 "keys"
{"presentTrend3",1521},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 351 "keys"
{"calendarIdentificationTemplateNumber",346},
{""}, {""}, {""}, {""}, {""},
#line 1466 "keys"
{"padding_local1_31",1461},
{""}, {""}, {""}, {""}, {""},
#line 874 "keys"
{"hoursAfterDataCutoff",869},
{""}, {""},
#line 989 "keys"
{"latitudeOfTheSouthernPoleOfProjection",984},
{""}, {""}, {""},
#line 757 "keys"
{"extractDateTimeMonthRank",752},
{""}, {""}, {""}, {""},
#line 1341 "keys"
{"octetAtWichPackedDataBegins",1336},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 468 "keys"
{"cloudsCode3Trend3",463},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1998 "keys"
{"typeOfIntervalForFirstAndSecondSize",1993},
{""}, {""}, {""}, {""}, {""},
#line 1657 "keys"
{"runwayDepthOfDepositState1",1652},
#line 1781 "keys"
{"section2Used",1776},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1412 "keys"
{"padding_grid50_1",1407},
{""}, {""}, {""},
#line 2098 "keys"
{"windDirectionTrend2",2093},
{""}, {""}, {""}, {""}, {""},
#line 2050 "keys"
{"uvRelativeToGrid",2045},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1498 "keys"
{"pentagonalResolutionParameterJ",1493},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 2081 "keys"
{"visibilityInKilometresTrend4",2076},
{""}, {""},
#line 498 "keys"
{"clusterMember2",493},
#line 1304 "keys"
{"numberOfPointsAlongYAxis",1299},
#line 529 "keys"
{"conceptsMasterDir",524},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 380 "keys"
{"changeIndicatorTrend1",375},
{""}, {""}, {""}, {""}, {""}, {""},
#line 193 "keys"
{"Original_Parameter_Identifier",188},
#line 1646 "keys"
{"runwayDepositCodeState2",1641},
{""}, {""},
#line 1301 "keys"
{"numberOfPointsAlongTheXAxis",1296},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 831 "keys"
{"getNumberOfValues",826},
{""},
#line 840 "keys"
{"gribTablesVersionNo",835},
{""},
#line 64 "keys"
{"ExtremeValuesInMaximumRVR2",59},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 2028 "keys"
{"unitOfTimeRange",2023},
#line 1306 "keys"
{"numberOfPressureLevelsUsedForClustering",1301},
{""},
#line 459 "keys"
{"cloudsCode1Trend4",454},
#line 1999 "keys"
{"typeOfIntervalForFirstAndSecondWavelength",1994},
{""}, {""}, {""}, {""}, {""}, {""},
#line 86 "keys"
{"HDF5",81},
#line 1653 "keys"
{"runwayDepthOfDepositCodeState1",1648},
{""}, {""},
#line 742 "keys"
{"extractAreaLatitudeRank",737},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 1821 "keys"
{"shapeOfTheEarth",1816},
{""}, {""}, {""}, {""}, {""},
#line 467 "keys"
{"cloudsCode3Trend2",462},
#line 998 "keys"
{"legBaseTime",993},
{""},
#line 1493 "keys"
{"pastTendencyRVR1",1488},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1659 "keys"
{"runwayDepthOfDepositState3",1654},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1957 "keys"
{"timeUnitFlag",1952},
#line 959 "keys"
{"laplacianScalingFactorUnset",954},
{""}, {""}, {""}, {""},
#line 309 "keys"
{"baseDateOfThisLeg",304},
{""}, {""}, {""}, {""},
#line 461 "keys"
{"cloudsCode2Trend1",456},
{""}, {""},
#line 2064 "keys"
{"variationOfVisibilityTrend4",2059},
{""}, {""}, {""},
#line 1022 "keys"
{"listOfContributingSpectralBands",1017},
{""}, {""}, {""},
#line 1469 "keys"
{"padding_local_7_1",1464},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1428 "keys"
{"padding_loc190_1",1423},
{""},
#line 1016 "keys"
{"listMembersMissing3",1011},
{""}, {""}, {""}, {""}, {""},
#line 382 "keys"
{"changeIndicatorTrend3",377},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 839 "keys"
{"gribMasterTablesVersionNumber",834},
#line 146 "keys"
{"METAR",141},
{""}, {""},
#line 405 "keys"
{"cloudsAbbreviation3",400},
{""}, {""}, {""},
#line 1811 "keys"
{"section_7",1806},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1494 "keys"
{"pastTendencyRVR2",1489},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1528 "keys"
{"presentWeather1Present",1523},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 1525 "keys"
{"presentTrend2",1520},
{""}, {""}, {""}, {""}, {""}, {""},
#line 346 "keys"
{"bufrHeaderSubCentre",341},
{""}, {""}, {""}, {""}, {""},
#line 1655 "keys"
{"runwayDepthOfDepositCodeState3",1650},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 26 "keys"
{"BufrTemplate",21},
{""}, {""},
#line 602 "keys"
{"dateOfSSTFieldUsed",597},
{""}, {""}, {""}, {""}, {""},
#line 259 "keys"
{"Y1",254},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 895 "keys"
{"indicatorOfUnitForTimeIncrement",890},
{""}, {""}, {""}, {""},
#line 1658 "keys"
{"runwayDepthOfDepositState2",1653},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2078 "keys"
{"visibilityInKilometresTrend1",2073},
{""}, {""}, {""}, {""},
#line 463 "keys"
{"cloudsCode2Trend3",458},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 1242 "keys"
{"numberOfBytesPerInteger",1237},
{""}, {""}, {""}, {""}, {""},
#line 673 "keys"
{"endDayTrend4",668},
{""}, {""}, {""}, {""}, {""},
#line 1002 "keys"
{"lengthOf4DvarWindow",997},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1853 "keys"
{"spacingOfBinsAlongRadials",1848},
{""},
#line 203 "keys"
{"Product_Identifier",198},
{""},
#line 1020 "keys"
{"listMembersUsed3",1015},
{""}, {""},
#line 381 "keys"
{"changeIndicatorTrend2",376},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 489 "keys"
{"cloudsTitle3Trend4",484},
{""}, {""}, {""}, {""}, {""}, {""},
#line 690 "keys"
{"endOfHeadersMarker",685},
{""}, {""}, {""}, {""}, {""},
#line 2048 "keys"
{"uuidOfHGrid",2043},
{""},
#line 456 "keys"
{"cloudsCode1Trend1",451},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 348 "keys"
{"bufrdcExpandedDescriptors",343},
{""},
#line 541 "keys"
{"coordAveraging3",536},
{""}, {""},
#line 772 "keys"
{"extremeCounterClockwiseWindDirection",767},
{""},
#line 2140 "keys"
{"yearOfEndOfOverallTimeInterval",2135},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 1507 "keys"
{"physicalFlag1",1502},
{""}, {""}, {""}, {""}, {""},
#line 603 "keys"
{"dateSSTFieldUsed",598},
#line 1654 "keys"
{"runwayDepthOfDepositCodeState2",1649},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 776 "keys"
{"extremeValuesRVR4",771},
{""},
#line 1745 "keys"
{"scanningMode7",1740},
#line 1952 "keys"
{"timeIncrementBetweenSuccessiveFields",1947},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 1086 "keys"
{"longitudeOfTheSouthernPoleOfProjection",1081},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 2080 "keys"
{"visibilityInKilometresTrend3",2075},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 33 "keys"
{"Date_E3",28},
{""}, {""},
#line 462 "keys"
{"cloudsCode2Trend2",457},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 715 "keys"
{"expandBy",710},
{""}, {""}, {""}, {""}, {""}, {""},
#line 519 "keys"
{"commonBlock",514},
{""}, {""}, {""}, {""},
#line 1129 "keys"
{"marsType2",1124},
{""}, {""},
#line 1334 "keys"
{"observationDiagnostic",1329},
#line 503 "keys"
{"clusterMember7",498},
{""}, {""}, {""},
#line 1465 "keys"
{"padding_local1_1",1460},
{""}, {""}, {""},
#line 1015 "keys"
{"listMembersMissing2",1010},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 747 "keys"
{"extractDateTimeDayEnd",742},
{""},
#line 1467 "keys"
{"padding_local40_1",1462},
#line 682 "keys"
{"endMinuteTrend2",677},
{""}, {""}, {""}, {""}, {""}, {""},
#line 400 "keys"
{"cloudsAbbreviation2",395},
{""}, {""}, {""},
#line 458 "keys"
{"cloudsCode1Trend3",453},
{""}, {""}, {""}, {""},
#line 62 "keys"
{"Extra_Data_FreeFormat_0_none",57},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 425 "keys"
{"cloudsBase3",420},
#line 1182 "keys"
{"missingValueManagementUsed",1177},
{""},
#line 977 "keys"
{"latitudeOfReferencePointInDegrees",972},
#line 681 "keys"
{"endMinuteTrend1",676},
#line 1764 "keys"
{"secondaryBitmapsSize",1759},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1500 "keys"
{"pentagonalResolutionParameterM",1495},
{""}, {""}, {""},
#line 201 "keys"
{"P_TACC",196},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 680 "keys"
{"endMark",675},
#line 1464 "keys"
{"padding_local11_1",1459},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 316 "keys"
{"beginDayTrend4",311},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 449 "keys"
{"cloudsBaseCoded3Trend4",444},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 2079 "keys"
{"visibilityInKilometresTrend2",2074},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 324 "keys"
{"beginMinuteTrend4",319},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 75 "keys"
{"GG",70},
{""}, {""}, {""}, {""},
#line 486 "keys"
{"cloudsTitle3Trend1",481},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1496 "keys"
{"pastTendencyRVR4",1491},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 457 "keys"
{"cloudsCode1Trend2",452},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 484 "keys"
{"cloudsTitle2Trend4",479},
{""}, {""},
#line 857 "keys"
{"gts_TTAAii",852},
{""}, {""}, {""},
#line 773 "keys"
{"extremeValuesRVR1",768},
#line 1082 "keys"
{"longitudeOfTangencyPoint",1077},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1586 "keys"
{"rdb_key",1581},
#line 204 "keys"
{"RENAME",199},
{""}, {""}, {""},
#line 2061 "keys"
{"variationOfVisibilityTrend1",2056},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1053 "keys"
{"localTablesVersionNumber",1048},
#line 1479 "keys"
{"paramIdECMF",1474},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1325 "keys"
{"numberOfUsedSpatialTiles",1320},
{""}, {""}, {""},
#line 794 "keys"
{"firstMonthUsedToBuildClimateMonth1",789},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 1583 "keys"
{"rangeBinSpacing",1578},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1692 "keys"
{"runwaySideCodeState4",1687},
{""}, {""},
#line 2087 "keys"
{"weightAppliedToClimateMonth1",2082},
{""}, {""}, {""}, {""},
#line 32 "keys"
{"Date_E2",27},
{""}, {""}, {""},
#line 2084 "keys"
{"visibilityTrend3",2079},
{""}, {""},
#line 1676 "keys"
{"runwayExtentOfContaminationState4",1671},
{""}, {""},
#line 1458 "keys"
{"padding_loc50_1",1453},
#line 1672 "keys"
{"runwayExtentOfContaminationCodeState4",1667},
{""},
#line 488 "keys"
{"cloudsTitle3Trend3",483},
{""}, {""}, {""}, {""},
#line 1664 "keys"
{"runwayDesignatorRVR4",1659},
{""}, {""}, {""}, {""}, {""},
#line 1326 "keys"
{"numberOfUsedTileAttributes",1321},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 270 "keys"
{"ZLBASE",265},
{""}, {""}, {""}, {""}, {""},
#line 1287 "keys"
{"numberOfModeOfDistribution",1282},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1019 "keys"
{"listMembersUsed2",1014},
{""}, {""}, {""},
#line 1509 "keys"
{"physicalMeaningOfVerticalCoordinate",1504},
#line 1236 "keys"
{"numberOfBitsContainingEachPackedValue",1231},
{""}, {""}, {""},
#line 1371 "keys"
{"offsetValuesBy",1366},
{""}, {""},
#line 775 "keys"
{"extremeValuesRVR3",770},
{""}, {""}, {""}, {""}, {""},
#line 22 "keys"
{"BOX",17},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 242 "keys"
{"UseEcmfConventions",237},
{""}, {""},
#line 446 "keys"
{"cloudsBaseCoded3Trend1",441},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 261 "keys"
{"Y2",256},
{""}, {""}, {""}, {""}, {""},
#line 321 "keys"
{"beginMinuteTrend1",316},
#line 1359 "keys"
{"offsetFromReferenceOfFirstTime",1354},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 332 "keys"
{"beginYearTrend4",327},
{""}, {""},
#line 474 "keys"
{"cloudsCode4Trend4",469},
#line 479 "keys"
{"cloudsTitle1Trend4",474},
{""}, {""}, {""}, {""}, {""},
#line 2069 "keys"
{"versionNumberOfExperimentalSuite",2064},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 444 "keys"
{"cloudsBaseCoded2Trend4",439},
#line 2012 "keys"
{"typeOfWavelengthInterval",2007},
{""}, {""}, {""},
#line 487 "keys"
{"cloudsTitle3Trend2",482},
{""}, {""},
#line 415 "keys"
{"cloudsBase1",410},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1274 "keys"
{"numberOfGridUsed",1269},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 481 "keys"
{"cloudsTitle2Trend1",476},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 51 "keys"
{"ECMWF",46},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 35 "keys"
{"DayOfModelVersion",30},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 774 "keys"
{"extremeValuesRVR2",769},
#line 445 "keys"
{"cloudsBaseCoded3",440},
{""}, {""},
#line 1508 "keys"
{"physicalFlag2",1503},
{""}, {""}, {""},
#line 2063 "keys"
{"variationOfVisibilityTrend3",2058},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 448 "keys"
{"cloudsBaseCoded3Trend3",443},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 420 "keys"
{"cloudsBase2",415},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 795 "keys"
{"firstMonthUsedToBuildClimateMonth2",790},
#line 323 "keys"
{"beginMinuteTrend3",318},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1673 "keys"
{"runwayExtentOfContaminationState1",1668},
{""}, {""}, {""},
#line 1669 "keys"
{"runwayExtentOfContaminationCodeState1",1664},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1327 "keys"
{"numberOfVGridUsed",1322},
{""}, {""},
#line 688 "keys"
{"endMonthTrend4",683},
{""}, {""}, {""}, {""}, {""}, {""},
#line 610 "keys"
{"dayOfTheYearDate",605},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 284 "keys"
{"alternativeRowScanning",279},
#line 2116 "keys"
{"windUnitsTrend4",2111},
{""},
#line 2070 "keys"
{"versionNumberOfGribLocalTables",2065},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 208 "keys"
{"RVR4_1",203},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 483 "keys"
{"cloudsTitle2Trend3",478},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 264 "keys"
{"YRInMetres",259},
{""}, {""},
#line 313 "keys"
{"beginDayTrend1",308},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 439 "keys"
{"cloudsBaseCoded1Trend4",434},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 988 "keys"
{"latitudeOfThePolePointInDegrees",983},
{""},
#line 1431 "keys"
{"padding_loc191_3",1426},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2082 "keys"
{"visibilityTrend1",2077},
#line 447 "keys"
{"cloudsBaseCoded3Trend2",442},
{""}, {""}, {""}, {""}, {""}, {""},
#line 471 "keys"
{"cloudsCode4Trend1",466},
#line 476 "keys"
{"cloudsTitle1Trend1",471},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 322 "keys"
{"beginMinuteTrend2",317},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1675 "keys"
{"runwayExtentOfContaminationState3",1670},
{""}, {""}, {""},
#line 1671 "keys"
{"runwayExtentOfContaminationCodeState3",1666},
{""}, {""},
#line 441 "keys"
{"cloudsBaseCoded2Trend1",436},
{""},
#line 1461 "keys"
{"padding_loc7_1",1456},
#line 1462 "keys"
{"padding_loc9_1",1457},
{""},
#line 1460 "keys"
{"padding_loc6_1",1455},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1320 "keys"
{"numberOfTensOfThousandsOfYearsOfOffset",1315},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 875 "keys"
{"hoursAfterReferenceTimeOfDataCutoff",870},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1538 "keys"
{"presentWeather3Present",1533},
{""},
#line 2105 "keys"
{"windGustTrend4",2100},
#line 1759 "keys"
{"secondaryBitMap",1754},
{""},
#line 655 "keys"
{"earthMajorAxisInMetres",650},
#line 1452 "keys"
{"padding_loc30_2",1447},
{""}, {""}, {""}, {""},
#line 1459 "keys"
{"padding_loc5_1",1454},
{""}, {""}, {""},
#line 2083 "keys"
{"visibilityTrend2",2078},
{""}, {""}, {""}, {""},
#line 2006 "keys"
{"typeOfSSTFieldUsed",2001},
{""}, {""}, {""},
#line 482 "keys"
{"cloudsTitle2Trend2",477},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1021 "keys"
{"listMembersUsed4",1016},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1451 "keys"
{"padding_loc30_1",1446},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 169 "keys"
{"NEAREST",164},
#line 320 "keys"
{"beginHourTrend4",315},
{""}, {""}, {""}, {""},
#line 70 "keys"
{"ExtremeValuesRVR4",65},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1689 "keys"
{"runwaySideCodeState1",1684},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2062 "keys"
{"variationOfVisibilityTrend2",2057},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 473 "keys"
{"cloudsCode4Trend3",468},
#line 478 "keys"
{"cloudsTitle1Trend3",473},
{""},
#line 1455 "keys"
{"padding_loc38_1",1450},
{""}, {""}, {""}, {""}, {""},
#line 1661 "keys"
{"runwayDesignatorRVR1",1656},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1468 "keys"
{"padding_local_35",1463},
{""}, {""}, {""}, {""},
#line 231 "keys"
{"Threshold_Or_Distribution_0_no_1_yes",226},
#line 1674 "keys"
{"runwayExtentOfContaminationState2",1669},
#line 443 "keys"
{"cloudsBaseCoded2Trend3",438},
{""}, {""},
#line 1670 "keys"
{"runwayExtentOfContaminationCodeState2",1665},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1228 "keys"
{"numberInHorizontalCoordinates",1223},
{""}, {""}, {""}, {""},
#line 205 "keys"
{"RVR1_1",200},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 435 "keys"
{"cloudsBaseCoded1",430},
{""},
#line 152 "keys"
{"Minute_E4",147},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 436 "keys"
{"cloudsBaseCoded1Trend1",431},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 315 "keys"
{"beginDayTrend3",310},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 209 "keys"
{"SOH",204},
{""}, {""},
#line 1230 "keys"
{"numberInTheAuxiliaryArray",1225},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 430 "keys"
{"cloudsBase4",425},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 472 "keys"
{"cloudsCode4Trend2",467},
#line 477 "keys"
{"cloudsTitle1Trend2",472},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 440 "keys"
{"cloudsBaseCoded2",435},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 92 "keys"
{"ICEFieldsUsed",87},
{""}, {""}, {""}, {""}, {""},
#line 442 "keys"
{"cloudsBaseCoded2Trend2",437},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 207 "keys"
{"RVR3_1",202},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1240 "keys"
{"numberOfBytesInLocalDefinition",1235},
{""}, {""}, {""}, {""},
#line 258 "keys"
{"XpInGridLengths",253},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1429 "keys"
{"padding_loc191_1",1424},
{""}, {""},
#line 438 "keys"
{"cloudsBaseCoded1Trend3",433},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 67 "keys"
{"ExtremeValuesRVR1",62},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1447 "keys"
{"padding_loc29_2",1442},
{""}, {""}, {""},
#line 1758 "keys"
{"secondOrderValuesDifferentWidths",1753},
{""},
#line 357 "keys"
{"ccsdsBlockSize",352},
{""}, {""},
#line 1907 "keys"
{"superblockExtensionAddress",1902},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 311 "keys"
{"baseTimeOfThisLeg",306},
{""}, {""}, {""},
#line 1691 "keys"
{"runwaySideCodeState3",1686},
{""}, {""}, {""},
#line 285 "keys"
{"altitudeOfTheCameraFromTheEarthSCenterMeasuredInUnitsOfTheEarth",280},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1446 "keys"
{"padding_loc29_1",1441},
{""},
#line 1434 "keys"
{"padding_loc20_1",1429},
{""},
#line 188 "keys"
{"Number_Combination_Ensembles_1_none",183},
#line 685 "keys"
{"endMonthTrend1",680},
{""}, {""}, {""},
#line 327 "keys"
{"beginMonthTrend3",322},
{""}, {""}, {""}, {""},
#line 1663 "keys"
{"runwayDesignatorRVR3",1658},
{""}, {""}, {""},
#line 1324 "keys"
{"numberOfUnusedBitsAtEndOfSection3",1319},
{""}, {""}, {""}, {""},
#line 6 "keys"
{"************_ENSEMBLE_**************",1},
{""},
#line 1413 "keys"
{"padding_grid5_1",1408},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1430 "keys"
{"padding_loc191_2",1425},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1445 "keys"
{"padding_loc28_1",1440},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 206 "keys"
{"RVR2_1",201},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 137 "keys"
{"Local_Number_Members_Used",132},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2085 "keys"
{"visibilityTrend4",2080},
{""}, {""}, {""}, {""}, {""}, {""},
#line 683 "keys"
{"endMinuteTrend3",678},
{""},
#line 494 "keys"
{"cloudsTitle4Trend4",489},
{""}, {""}, {""},
#line 1817 "keys"
{"setBitsPerValue",1812},
{""}, {""}, {""},
#line 437 "keys"
{"cloudsBaseCoded1Trend2",432},
{""}, {""}, {""}, {""}, {""},
#line 69 "keys"
{"ExtremeValuesRVR3",64},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1474 "keys"
{"padding_sec3_1",1469},
{""}, {""}, {""}, {""},
#line 314 "keys"
{"beginDayTrend2",309},
{""}, {""}, {""}, {""}, {""},
#line 2071 "keys"
{"versionNumberOfSuperblock",2066},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 129 "keys"
{"Local_Number_Members_Missing",124},
{""}, {""}, {""}, {""}, {""}, {""},
#line 97 "keys"
{"ITERATOR",92},
{""}, {""},
#line 1456 "keys"
{"padding_loc3_1",1451},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1439 "keys"
{"padding_loc244_3",1434},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1433 "keys"
{"padding_loc19_2",1428},
#line 2102 "keys"
{"windGustTrend1",2097},
#line 339 "keys"
{"bitsPerValueAndRepack",334},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1463 "keys"
{"padding_loc9_2",1458},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1415 "keys"
{"padding_loc10_1",1410},
{""}, {""}, {""}, {""}, {""}, {""},
#line 760 "keys"
{"extractDateTimeSecondRank",755},
{""}, {""}, {""}, {""},
#line 1427 "keys"
{"padding_loc18_2",1422},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1411 "keys"
{"padding_grid4_1",1406},
{""}, {""}, {""},
#line 200 "keys"
{"P_INST",195},
{""}, {""}, {""}, {""},
#line 1432 "keys"
{"padding_loc192_1",1427},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1426 "keys"
{"padding_loc18_1",1421},
{""},
#line 68 "keys"
{"ExtremeValuesRVR2",63},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1302 "keys"
{"numberOfPointsAlongTheYAxis",1297},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 215 "keys"
{"Show_Combination_Ensem_E4_0_no_1_yes",210},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1690 "keys"
{"runwaySideCodeState2",1685},
{""}, {""}, {""}, {""},
#line 687 "keys"
{"endMonthTrend3",682},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 450 "keys"
{"cloudsBaseCoded4",445},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1662 "keys"
{"runwayDesignatorRVR2",1657},
{""}, {""}, {""},
#line 920 "keys"
{"isCavokTrend4",915},
{""}, {""}, {""},
#line 454 "keys"
{"cloudsBaseCoded4Trend4",449},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1440 "keys"
{"padding_loc245_1",1435},
{""}, {""}, {""}, {""}, {""}, {""},
#line 171 "keys"
{"NH",166},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1420 "keys"
{"padding_loc13_5",1415},
{""}, {""}, {""}, {""}, {""}, {""},
#line 330 "keys"
{"beginYearTrend2",325},
#line 491 "keys"
{"cloudsTitle4Trend1",486},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 133 "keys"
{"Local_Number_Members_Possible",128},
{""}, {""}, {""}, {""}, {""}, {""},
#line 329 "keys"
{"beginYearTrend1",324},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 325 "keys"
{"beginMonthTrend1",320},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 60 "keys"
{"Ensemble_Identifier_E4",55},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 754 "keys"
{"extractDateTimeMinuteRank",749},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1441 "keys"
{"padding_loc245_2",1436},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 179 "keys"
{"NUT",174},
{""}, {""}, {""}, {""}, {""},
#line 1471 "keys"
{"padding_sec2_1",1466},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 913 "keys"
{"intervalBetweenTimes",908},
#line 364 "keys"
{"ceilingAndVisibilityOKTrend4",359},
{""},
#line 414 "keys"
{"cloudsAbbreviation4Trend4",409},
{""}, {""}, {""}, {""}, {""}, {""},
#line 2104 "keys"
{"windGustTrend3",2099},
{""}, {""},
#line 1409 "keys"
{"padding_grid1_2",1404},
{""},
#line 1449 "keys"
{"padding_loc2_1",1444},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 701 "keys"
{"endYearTrend4",696},
{""}, {""},
#line 326 "keys"
{"beginMonthTrend2",321},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 7 "keys"
{"************_EXPERIMENT_************",2},
{""}, {""},
#line 1408 "keys"
{"padding_grid1_1",1403},
{""}, {""}, {""},
#line 493 "keys"
{"cloudsTitle4Trend3",488},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 2011 "keys"
{"typeOfTimeIncrementBetweenSuccessiveFieldsUsedInTheStatisticalProcessing",2006},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 748 "keys"
{"extractDateTimeDayRank",743},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1442 "keys"
{"padding_loc26_1",1437},
{""}, {""}, {""},
#line 1437 "keys"
{"padding_loc244_1",1432},
{""},
#line 2114 "keys"
{"windUnitsTrend2",2109},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 2113 "keys"
{"windUnitsTrend1",2108},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 451 "keys"
{"cloudsBaseCoded4Trend1",446},
{""}, {""}, {""},
#line 686 "keys"
{"endMonthTrend2",681},
#line 763 "keys"
{"extractDateTimeYearRank",758},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1419 "keys"
{"padding_loc13_4",1414},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 151 "keys"
{"Minute_E3",146},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1438 "keys"
{"padding_loc244_2",1433},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 1410 "keys"
{"padding_grid3_1",1405},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 492 "keys"
{"cloudsTitle4Trend2",487},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 214 "keys"
{"Show_Combination_Ensem_E3_0_no_1_yes",209},
{""}, {""},
#line 1378 "keys"
{"oneMinuteMeanMaximumRVR4",1373},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 1348 "keys"
{"offsetBBitmap",1343},
{""}, {""}, {""}, {""}, {""},
#line 192 "keys"
{"Original_Parameter_Iden_CodeTable2",187},
{""}, {""}, {""}, {""}, {""}, {""},
#line 361 "keys"
{"ceilingAndVisibilityOKTrend1",356},
{""},
#line 399 "keys"
{"cloudsAbbreviation1Trend4",394},
{""},
#line 1473 "keys"
{"padding_sec2_3",1468},
{""}, {""}, {""}, {""}, {""}, {""},
#line 453 "keys"
{"cloudsBaseCoded4Trend3",448},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 318 "keys"
{"beginHourTrend2",313},
{""}, {""},
#line 1424 "keys"
{"padding_loc16_1",1419},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2103 "keys"
{"windGustTrend2",2098},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 317 "keys"
{"beginHourTrend1",312},
{""}, {""}, {""},
#line 827 "keys"
{"genVertHeightCoords",822},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 59 "keys"
{"Ensemble_Identifier_E3",54},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2022 "keys"
{"typicalYearOfCentury",2017},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 277 "keys"
{"accuracyMultipliedByFactor",272},
{""}, {""}, {""}, {""}, {""}, {""},
#line 213 "keys"
{"Show_Combination_Ensem_E2_0_no_1_yes",208},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 917 "keys"
{"isCavokTrend1",912},
#line 1581 "keys"
{"radiusOfTheEarth",1576},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 363 "keys"
{"ceilingAndVisibilityOKTrend3",358},
#line 679 "keys"
{"endHourTrend4",674},
#line 409 "keys"
{"cloudsAbbreviation3Trend4",404},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 452 "keys"
{"cloudsBaseCoded4Trend2",447},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 328 "keys"
{"beginMonthTrend4",323},
#line 150 "keys"
{"Minute_E2",145},
{""}, {""}, {""}, {""}, {""}, {""},
#line 52 "keys"
{"ECMWF_s",47},
{""}, {""},
#line 191 "keys"
{"Original_CodeTable_2_Version_Number",186},
{""}, {""}, {""}, {""}, {""},
#line 1286 "keys"
{"numberOfMissingValues",1281},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1375 "keys"
{"oneMinuteMeanMaximumRVR1",1370},
#line 1382 "keys"
{"oneMinuteMeanMinimumRVR4",1377},
{""}, {""}, {""},
#line 58 "keys"
{"Ensemble_Identifier_E2",53},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1537 "keys"
{"presentWeather2PresentTrend4",1532},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 411 "keys"
{"cloudsAbbreviation4Trend1",406},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 362 "keys"
{"ceilingAndVisibilityOKTrend2",357},
#line 698 "keys"
{"endYearTrend1",693},
#line 404 "keys"
{"cloudsAbbreviation2Trend4",399},
{""}, {""},
#line 25 "keys"
{"BUFRstr",20},
{""}, {""}, {""}, {""},
#line 1472 "keys"
{"padding_sec2_2",1467},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1450 "keys"
{"padding_loc2_2",1445},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 429 "keys"
{"cloudsBase3Trend4",424},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1423 "keys"
{"padding_loc15_1",1418},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 751 "keys"
{"extractDateTimeHourRank",746},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1377 "keys"
{"oneMinuteMeanMaximumRVR3",1372},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1448 "keys"
{"padding_loc29_3",1443},
{""}, {""}, {""}, {""}, {""},
#line 919 "keys"
{"isCavokTrend3",914},
{""}, {""}, {""}, {""}, {""}, {""},
#line 202 "keys"
{"P_TAVG",197},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 266 "keys"
{"YearOfModelVersion",261},
{""},
#line 132 "keys"
{"Local_Number_Members_Missing_E4",127},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 165 "keys"
{"NB",160},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 228 "keys"
{"TYPE_OF",223},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1351 "keys"
{"offsetBeforeBitmap",1346},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 230 "keys"
{"TYPE_PF",225},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1379 "keys"
{"oneMinuteMeanMinimumRVR1",1374},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1597 "keys"
{"recentWeatherTry",1592},
{""}, {""},
#line 1534 "keys"
{"presentWeather2PresentTrend1",1529},
{""},
#line 1422 "keys"
{"padding_loc14_2",1417},
{""}, {""}, {""}, {""}, {""}, {""},
#line 251 "keys"
{"X1InGridLengths",246},
{""}, {""}, {""}, {""},
#line 1376 "keys"
{"oneMinuteMeanMaximumRVR2",1371},
{""},
#line 396 "keys"
{"cloudsAbbreviation1Trend1",391},
{""}, {""},
#line 91 "keys"
{"Hour_E4",86},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1421 "keys"
{"padding_loc14_1",1416},
{""},
#line 413 "keys"
{"cloudsAbbreviation4Trend3",408},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 1532 "keys"
{"presentWeather1PresentTrend4",1527},
{""}, {""},
#line 700 "keys"
{"endYearTrend3",695},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 426 "keys"
{"cloudsBase3Trend1",421},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1435 "keys"
{"padding_loc21_1",1430},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 226 "keys"
{"TYPE_FF",221},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1381 "keys"
{"oneMinuteMeanMinimumRVR3",1376},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 1536 "keys"
{"presentWeather2PresentTrend3",1531},
#line 24 "keys"
{"BUFR",19},
{""},
#line 424 "keys"
{"cloudsBase2Trend4",419},
{""}, {""}, {""}, {""}, {""},
#line 1911 "keys"
{"swapScanningY",1906},
{""}, {""}, {""},
#line 229 "keys"
{"TYPE_OR",224},
{""},
#line 676 "keys"
{"endHourTrend1",671},
#line 406 "keys"
{"cloudsAbbreviation3Trend1",401},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1475 "keys"
{"padding_sec4_1",1470},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 918 "keys"
{"isCavokTrend2",913},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 136 "keys"
{"Local_Number_Members_Possible_E4",131},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 428 "keys"
{"cloudsBase3Trend3",423},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1436 "keys"
{"padding_loc23_1",1431},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 1454 "keys"
{"padding_loc37_2",1449},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 331 "keys"
{"beginYearTrend3",326},
{""},
#line 1380 "keys"
{"oneMinuteMeanMinimumRVR2",1375},
{""}, {""},
#line 103 "keys"
{"LBC_Initial_Conditions",98},
#line 1453 "keys"
{"padding_loc37_1",1448},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1535 "keys"
{"presentWeather2PresentTrend2",1530},
{""}, {""}, {""}, {""}, {""},
#line 88 "keys"
{"HourOfModelVersion",83},
{""}, {""},
#line 253 "keys"
{"X2InGridLengths",248},
#line 398 "keys"
{"cloudsAbbreviation1Trend3",393},
{""}, {""}, {""}, {""}, {""},
#line 401 "keys"
{"cloudsAbbreviation2Trend1",396},
{""}, {""},
#line 241 "keys"
{"Total_Number_Members_Used",236},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 1529 "keys"
{"presentWeather1PresentTrend1",1524},
{""},
#line 131 "keys"
{"Local_Number_Members_Missing_E3",126},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 412 "keys"
{"cloudsAbbreviation4Trend2",407},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 419 "keys"
{"cloudsBase1Trend4",414},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 699 "keys"
{"endYearTrend2",694},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 239 "keys"
{"Total_Number_Members_Missing",234},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 427 "keys"
{"cloudsBase3Trend2",422},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 2042 "keys"
{"unusedBitsInBitmap",2037},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 1417 "keys"
{"padding_loc13_2",1412},
#line 421 "keys"
{"cloudsBase2Trend1",416},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 224 "keys"
{"TYPE_CF",219},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 1416 "keys"
{"padding_loc13_1",1411},
#line 678 "keys"
{"endHourTrend3",673},
#line 408 "keys"
{"cloudsAbbreviation3Trend3",403},
{""},
#line 95 "keys"
{"INBITS",90},
{""}, {""}, {""}, {""},
#line 1241 "keys"
{"numberOfBytesOfFreeFormatData",1236},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 2115 "keys"
{"windUnitsTrend3",2110},
#line 269 "keys"
{"YpInGridLengths",264},
#line 1531 "keys"
{"presentWeather1PresentTrend3",1526},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 130 "keys"
{"Local_Number_Members_Missing_E2",125},
#line 271 "keys"
{"ZLMULT",266},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 423 "keys"
{"cloudsBase2Trend3",418},
{""},
#line 2001 "keys"
{"typeOfLevelECMF",1996},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1444 "keys"
{"padding_loc27_2",1439},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 403 "keys"
{"cloudsAbbreviation2Trend3",398},
{""}, {""}, {""}, {""}, {""},
#line 397 "keys"
{"cloudsAbbreviation1Trend2",392},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1443 "keys"
{"padding_loc27_1",1438},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1530 "keys"
{"presentWeather1PresentTrend2",1525},
#line 416 "keys"
{"cloudsBase1Trend1",411},
#line 240 "keys"
{"Total_Number_Members_Possible",235},
#line 135 "keys"
{"Local_Number_Members_Possible_E3",130},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 319 "keys"
{"beginHourTrend3",314},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1520 "keys"
{"precisionOfTheUnpackedSubset",1515},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 422 "keys"
{"cloudsBase2Trend2",417},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 265 "keys"
{"YY",260},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 225 "keys"
{"TYPE_FC",220},
{""}, {""}, {""},
#line 677 "keys"
{"endHourTrend2",672},
#line 407 "keys"
{"cloudsAbbreviation3Trend2",402},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 418 "keys"
{"cloudsBase1Trend3",413},
{""},
#line 140 "keys"
{"Local_Number_Members_Used_E4",135},
{""}, {""}, {""}, {""}, {""},
#line 134 "keys"
{"Local_Number_Members_Possible_E2",129},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 235 "keys"
{"Time_Range_One_E4",230},
{""}, {""}, {""},
#line 1425 "keys"
{"padding_loc17_2",1420},
{""}, {""}, {""}, {""}, {""},
#line 71 "keys"
{"FMULTE",66},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1457 "keys"
{"padding_loc4_2",1452},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 90 "keys"
{"Hour_E3",85},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 402 "keys"
{"cloudsAbbreviation2Trend2",397},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 417 "keys"
{"cloudsBase1Trend2",412},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 80 "keys"
{"GRIBEditionNumber",75},
{""}, {""}, {""}, {""},
#line 153 "keys"
{"Missing_Model_LBC",148},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1542 "keys"
{"presentWeather3PresentTrend4",1537},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1164 "keys"
{"meanValueRVR4",1159},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 10 "keys"
{"7777",5},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 434 "keys"
{"cloudsBase4Trend4",429},
{""}, {""}, {""},
#line 89 "keys"
{"Hour_E2",84},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 139 "keys"
{"Local_Number_Members_Used_E3",134},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 234 "keys"
{"Time_Range_One_E3",229},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 223 "keys"
{"TYPE_AN",218},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 105 "keys"
{"LSTCUM",100},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1539 "keys"
{"presentWeather3PresentTrend1",1534},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 138 "keys"
{"Local_Number_Members_Used_E2",133},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 233 "keys"
{"Time_Range_One_E2",228},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 431 "keys"
{"cloudsBase4Trend1",426},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 55 "keys"
{"Ensemble_Combinat_Number_0_none_E4",50},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 960 "keys"
{"lastMonthUsedToBuildClimateMonth1",955},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1541 "keys"
{"presentWeather3PresentTrend3",1536},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 433 "keys"
{"cloudsBase4Trend3",428},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 1418 "keys"
{"padding_loc13_3",1413},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1161 "keys"
{"meanValueRVR1",1156},
{""},
#line 1239 "keys"
{"numberOfBitsUsedForTheScaledGroupLengths",1234},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 1540 "keys"
{"presentWeather3PresentTrend2",1535},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 432 "keys"
{"cloudsBase4Trend2",427},
{""}, {""}, {""}, {""},
#line 122 "keys"
{"Less_Than_Or_To_Overall_Distribution",117},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 961 "keys"
{"lastMonthUsedToBuildClimateMonth2",956},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 260 "keys"
{"Y1InGridLengths",255},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 54 "keys"
{"Ensemble_Combinat_Number_0_none_E3",49},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1163 "keys"
{"meanValueRVR3",1158},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 227 "keys"
{"TYPE_FX",222},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 53 "keys"
{"Ensemble_Combinat_Number_0_none_E2",48},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 232 "keys"
{"Threshold_Or_Distribution_Units",227},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 262 "keys"
{"Y2InGridLengths",257},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 9 "keys"
{"*********_EXTRA_DATA_***************",4},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 1162 "keys"
{"meanValueRVR2",1157},
{""}, {""}, {""}, {""}, {""},
#line 1644 "keys"
{"runwayBrakingActionState4",1639},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 159 "keys"
{"Model_LBC_Member_Identifier",154},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 72 "keys"
{"FMULTM",67},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 1641 "keys"
{"runwayBrakingActionState1",1636},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 1370 "keys"
{"offsetToEndOf4DvarWindow",1365},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 19 "keys"
{"At_least__Or_Distribut_Proportion_Of",14},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 238 "keys"
{"Time_Range_Two_E4",233},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 76 "keys"
{"GRIB",71},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 954 "keys"
{"lBB",949},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1643 "keys"
{"runwayBrakingActionState3",1638},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 23 "keys"
{"BUDG",18},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 237 "keys"
{"Time_Range_Two_E3",232},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 1642 "keys"
{"runwayBrakingActionState2",1637},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 236 "keys"
{"Time_Range_Two_E2",231},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 156 "keys"
{"Missing_Model_LBC_E4",151},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
#line 1238 "keys"
{"numberOfBitsUsedForTheGroupWidths",1233},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 155 "keys"
{"Missing_Model_LBC_E3",150},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""},
#line 243 "keys"
{"Used_Model_LBC",238},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 77 "keys"
{"GRIBEXSection1Problem",72},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 154 "keys"
{"Missing_Model_LBC_E2",149},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 96 "keys"
{"INGRIB",91},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 16 "keys"
{"AEC_PAD_RSI_OPTION_MASK",11},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 79 "keys"
{"GRIBEX_boustrophedonic",74},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 21 "keys"
{"BBB",16},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 173 "keys"
{"NINT_RITZ_EXP",168},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 78 "keys"
{"GRIBEXShBugPresent",73},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 172 "keys"
{"NINT_LOG10_RITZ",167},
{""}, {""}, {""}, {""}, {""}, {""},
#line 246 "keys"
{"Used_Model_LBC_E4",241},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 17 "keys"
{"AEC_RESTRICTED_OPTION_MASK",12},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
#line 245 "keys"
{"Used_Model_LBC_E3",240},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 244 "keys"
{"Used_Model_LBC_E2",239},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 12 "keys"
{"AEC_DATA_3BYTE_OPTION_MASK",7},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""},
#line 81 "keys"
{"GRIB_DEPTH",76},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 83 "keys"
{"GRIB_LONGITUDE",78},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 82 "keys"
{"GRIB_LATITUDE",77},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""},
#line 13 "keys"
{"AEC_DATA_MSB_OPTION_MASK",8},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 15 "keys"
{"AEC_DATA_SIGNED_OPTION_MASK",10},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 14 "keys"
{"AEC_DATA_PREPROCESS_OPTION_MASK",9}
};
#ifdef __GNUC__
__inline
#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
struct grib_keys_hash *
grib_keys_hash_get (const char *str, unsigned int len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash_keys (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
register const char *s = wordlist[key].name;
if (*str == *s && !strcmp (str + 1, s + 1))
return &wordlist[key];
}
}
return 0;
}
/*
* Copyright 2005-2016 ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/**************************************
* Enrico Fucile
**************************************/
static int mapping[] = {
0, /* 00 */
0, /* 01 */
0, /* 02 */
0, /* 03 */
0, /* 04 */
0, /* 05 */
0, /* 06 */
0, /* 07 */
0, /* 08 */
0, /* 09 */
0, /* 0a */
0, /* 0b */
0, /* 0c */
0, /* 0d */
0, /* 0e */
0, /* 0f */
0, /* 10 */
0, /* 11 */
0, /* 12 */
0, /* 13 */
0, /* 14 */
0, /* 15 */
0, /* 16 */
0, /* 17 */
0, /* 18 */
0, /* 19 */
0, /* 1a */
0, /* 1b */
0, /* 1c */
0, /* 1d */
0, /* 1e */
0, /* 1f */
0, /* 20 */
0, /* 21 */
0, /* 22 */
0, /* 23 */
0, /* 24 */
0, /* 25 */
0, /* 26 */
0, /* 27 */
0, /* 28 */
0, /* 29 */
0, /* 2a */
0, /* 2b */
0, /* 2c */
0, /* 2d */
38, /* . */
39, /* / */
1, /* 0 */
2, /* 1 */
3, /* 2 */
4, /* 3 */
5, /* 4 */
6, /* 5 */
7, /* 6 */
8, /* 7 */
9, /* 8 */
10, /* 9 */
0, /* 3a */
0, /* 3b */
0, /* 3c */
0, /* 3d */
0, /* 3e */
0, /* 3f */
0, /* 40 */
11, /* A */
12, /* B */
13, /* C */
14, /* D */
15, /* E */
16, /* F */
17, /* G */
18, /* H */
19, /* I */
20, /* J */
21, /* K */
22, /* L */
23, /* M */
24, /* N */
25, /* O */
26, /* P */
27, /* Q */
28, /* R */
29, /* S */
30, /* T */
31, /* U */
32, /* V */
33, /* W */
34, /* X */
35, /* Y */
36, /* Z */
0, /* 5b */
0, /* 5c */
0, /* 5d */
0, /* 5e */
37, /* _ */
0, /* 60 */
38, /* a */
39, /* b */
40, /* c */
41, /* d */
42, /* e */
43, /* f */
44, /* g */
45, /* h */
46, /* i */
47, /* j */
48, /* k */
49, /* l */
50, /* m */
51, /* n */
52, /* o */
53, /* p */
54, /* q */
55, /* r */
56, /* s */
57, /* t */
58, /* u */
59, /* v */
60, /* w */
61, /* x */
62, /* y */
63, /* z */
0, /* 7b */
0, /* 7c */
0, /* 7d */
0, /* 7e */
0, /* 7f */
0, /* 80 */
0, /* 81 */
0, /* 82 */
0, /* 83 */
0, /* 84 */
0, /* 85 */
0, /* 86 */
0, /* 87 */
0, /* 88 */
0, /* 89 */
0, /* 8a */
0, /* 8b */
0, /* 8c */
0, /* 8d */
0, /* 8e */
0, /* 8f */
0, /* 90 */
0, /* 91 */
0, /* 92 */
0, /* 93 */
0, /* 94 */
0, /* 95 */
0, /* 96 */
0, /* 97 */
0, /* 98 */
0, /* 99 */
0, /* 9a */
0, /* 9b */
0, /* 9c */
0, /* 9d */
0, /* 9e */
0, /* 9f */
0, /* a0 */
0, /* a1 */
0, /* a2 */
0, /* a3 */
0, /* a4 */
0, /* a5 */
0, /* a6 */
0, /* a7 */
0, /* a8 */
0, /* a9 */
0, /* aa */
0, /* ab */
0, /* ac */
0, /* ad */
0, /* ae */
0, /* af */
0, /* b0 */
0, /* b1 */
0, /* b2 */
0, /* b3 */
0, /* b4 */
0, /* b5 */
0, /* b6 */
0, /* b7 */
0, /* b8 */
0, /* b9 */
0, /* ba */
0, /* bb */
0, /* bc */
0, /* bd */
0, /* be */
0, /* bf */
0, /* c0 */
0, /* c1 */
0, /* c2 */
0, /* c3 */
0, /* c4 */
0, /* c5 */
0, /* c6 */
0, /* c7 */
0, /* c8 */
0, /* c9 */
0, /* ca */
0, /* cb */
0, /* cc */
0, /* cd */
0, /* ce */
0, /* cf */
0, /* d0 */
0, /* d1 */
0, /* d2 */
0, /* d3 */
0, /* d4 */
0, /* d5 */
0, /* d6 */
0, /* d7 */
0, /* d8 */
0, /* d9 */
0, /* da */
0, /* db */
0, /* dc */
0, /* dd */
0, /* de */
0, /* df */
0, /* e0 */
0, /* e1 */
0, /* e2 */
0, /* e3 */
0, /* e4 */
0, /* e5 */
0, /* e6 */
0, /* e7 */
0, /* e8 */
0, /* e9 */
0, /* ea */
0, /* eb */
0, /* ec */
0, /* ed */
0, /* ee */
0, /* ef */
0, /* f0 */
0, /* f1 */
0, /* f2 */
0, /* f3 */
0, /* f4 */
0, /* f5 */
0, /* f6 */
0, /* f7 */
0, /* f8 */
0, /* f9 */
0, /* fa */
0, /* fb */
0, /* fc */
0, /* fd */
0, /* fe */
0, /* ff */
};
#define SIZE 64
#if GRIB_PTHREADS
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void init() {
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&mutex,&attr);
pthread_mutexattr_destroy(&attr);
}
#elif GRIB_OMP_THREADS
static int once = 0;
static omp_nest_lock_t mutex;
static void init()
{
GRIB_OMP_CRITICAL(lock_grib_hash_keys_c)
{
if (once == 0)
{
omp_init_nest_lock(&mutex);
once = 1;
}
}
}
#endif
struct grib_itrie {
grib_itrie* next[SIZE];
grib_context *context;
int id;
int* count;
};
grib_itrie *grib_hash_keys_new(grib_context* c,int* count) {
grib_itrie* t = (grib_itrie*)grib_context_malloc_clear(c,sizeof(grib_itrie));
t->context = c;
t->id=-1;
t->count=count;
return t;
}
void grib_hash_keys_delete(grib_itrie *t) {
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
if(t) {
int i;
for(i = 0; i < SIZE; i++)
if (t->next[i])
grib_hash_keys_delete(t->next[i]);
grib_context_free(t->context,t);
}
GRIB_MUTEX_UNLOCK(&mutex)
}
int grib_hash_keys_get_id(grib_itrie* t,const char* key)
{
const char *k=key;
grib_itrie* last=t;
struct grib_keys_hash* hash=grib_keys_hash_get(key,strlen(key));
if (hash) {
/* printf("%s found %s (%d)\n",key,hash->name,hash->id); */
return hash->id;
}
/* printf("+++ \"%s\"\n",key); */
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
while(*k && t) t = t->next[mapping[(int)*k++]];
if(t != NULL && t->id != -1) {
GRIB_MUTEX_UNLOCK(&mutex)
return t->id+TOTAL_KEYWORDS+1;
} else {
int ret=grib_hash_keys_insert(last,key);
GRIB_MUTEX_UNLOCK(&mutex)
return ret+TOTAL_KEYWORDS+1;
}
}
int grib_hash_keys_insert(grib_itrie* t,const char* key)
{
const char *k = key;
grib_itrie *last = t;
int* count;
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
count=t->count;
while(*k && t) {
last = t;
t = t->next[mapping[(int)*k]];
if(t) k++;
}
if (*k!=0) {
t=last;
while(*k) {
int j = mapping[(int)*k++];
t->next[j] = grib_hash_keys_new(t->context,count);
t = t->next[j];
}
}
if (*(t->count)+TOTAL_KEYWORDS < ACCESSORS_ARRAY_SIZE) {
t->id=*(t->count);
(*(t->count))++;
} else {
grib_context_log(t->context,GRIB_LOG_ERROR,
"grib_hash_keys_get_id: too many accessors, increase ACCESSORS_ARRAY_SIZE\n");
Assert(*(t->count)+TOTAL_KEYWORDS < ACCESSORS_ARRAY_SIZE);
}
GRIB_MUTEX_UNLOCK(&mutex)
/*printf("grib_hash_keys_get_id: %s -> %d\n",key,t->id);*/
return t->id;
}
int grib_hash_keys_get_size(grib_itrie* t) {return *(t->count);}
| 31.512162 | 124 | 0.291935 | [
"model",
"3d"
] |
9af1b90932ad36c0c91655a8ee82bc51429f1a17 | 1,343 | h | C | ext/ruby_prof/rp_measurement.h | smcgivern/ruby-prof | e6c7d9b605e327f4852104ac2dcd989ad80310f9 | [
"BSD-2-Clause"
] | null | null | null | ext/ruby_prof/rp_measurement.h | smcgivern/ruby-prof | e6c7d9b605e327f4852104ac2dcd989ad80310f9 | [
"BSD-2-Clause"
] | null | null | null | ext/ruby_prof/rp_measurement.h | smcgivern/ruby-prof | e6c7d9b605e327f4852104ac2dcd989ad80310f9 | [
"BSD-2-Clause"
] | null | null | null | /* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
Please see the LICENSE file for copyright and distribution information */
#ifndef __rp_measurementMENT_H__
#define __rp_measurementMENT_H__
#include "ruby_prof.h"
extern VALUE mMeasure;
typedef double (*get_measurement)(rb_trace_arg_t* trace_arg);
typedef enum
{
MEASURE_WALL_TIME,
MEASURE_PROCESS_TIME,
MEASURE_ALLOCATIONS,
MEASURE_MEMORY
} prof_measure_mode_t;
typedef struct
{
get_measurement measure;
prof_measure_mode_t mode;
double multiplier;
bool track_allocations;
} prof_measurer_t;
/* Callers and callee information for a method. */
typedef struct prof_measurement_t
{
double total_time;
double self_time;
double wait_time;
int called;
VALUE object;
} prof_measurement_t;
prof_measurer_t* prof_get_measurer(prof_measure_mode_t measure, bool track_allocations);
double prof_measure(prof_measurer_t* measurer, rb_trace_arg_t* trace_arg);
prof_measurement_t* prof_measurement_create(void);
void prof_measurement_free(prof_measurement_t* measurement);
VALUE prof_measurement_wrap(prof_measurement_t* measurement);
prof_measurement_t* prof_get_measurement(VALUE self);
void prof_measurement_mark(void* data);
void rp_init_measure(void);
#endif //__rp_measurementMENT_H__
| 26.333333 | 99 | 0.799702 | [
"object"
] |
9af35f4cc4947ab3559bb2b65735f13955d52914 | 3,473 | h | C | rack/drain/util/Frame.h | fmidev/rack | 95c39ef610637e8068253efc36aab40177caff03 | [
"MIT"
] | 20 | 2018-03-21T10:58:00.000Z | 2022-02-11T14:43:03.000Z | rack/drain/util/Frame.h | fmidev/rack | 95c39ef610637e8068253efc36aab40177caff03 | [
"MIT"
] | null | null | null | rack/drain/util/Frame.h | fmidev/rack | 95c39ef610637e8068253efc36aab40177caff03 | [
"MIT"
] | 6 | 2018-07-04T04:55:56.000Z | 2021-04-15T19:25:13.000Z | /*
MIT License
Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
Part of Rack development has been done in the BALTRAD projects part-financed
by the European Union (European Regional Development Fund and European
Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
*/
#ifndef DRAIN_FRAME_H_
#define DRAIN_FRAME_H_
#include <ostream>
#include <stdexcept>
#include "drain/util/Log.h"
//#include "drain/util/Point.h"
//#include "drain/util/Range.h"
#include "drain/util/UniTuple.h"
namespace drain {
/*
template <class T>
struct Frame2D : public UniTuple<T,2> {
T &width;
T &height;
// Consider ranges
Frame2D(T w=0, T h=0): UniTuple<T,2>(), width(this->next()), height(this->next()) {
this->set(w,h);
};
Frame2D(const Frame2D & frame): UniTuple<T,2>(), width(this->next()), height(this->next()) {
this->assign(frame);
};
inline
T getArea(){
return width*height;
}
};
*/
template <class T>
class Frame2D : public drain::UniTuple<T,2> { //: protected AreaGeometryStruct {
public:
T & width;
T & height;
inline
Frame2D(T width=0, T height=0) : width(this->next()), height(this->next()){ //, area(0){
this->set(width, height?height:width);
};
Frame2D(const Frame2D<T> & geometry) : width(this->next()), height(this->next()) {
//this->set(geometry.tuple());
this->set(geometry.width, geometry.height);
}
// Reference, N>=2
template <T N>
Frame2D(drain::UniTuple<T,N> & tuple, T i) :
drain::UniTuple<T,2>(tuple, i),
width(this->next()),
height(this->next()){
//updateTuple();
};
virtual ~Frame2D(){};
Frame2D & operator=(const Frame2D & geometry){
this->set(geometry.width, geometry.height);
//this->assign(geometry);
return *this;
}
template <class T2>
inline
Frame2D & operator=(const T2 & frame){
this->set(0,0); // could be init!
this->assign(frame);
return *this;
}
inline
void setWidth(T w){
width = w;
// updateTuple();
}
inline
void setHeight(T h){
height = h;
// updateTuple();
}
/*
inline
void setArea(T w, T h){
this->set(w, h);
//updateTuple();
}
void setArea(const Frame2D & geometry){
setArea(geometry.getWidth(), geometry.getHeight());
}
*/
inline
T getWidth() const {
return width;
};
inline
T getHeight() const {
return height;
};
inline
T getArea() const {
return width*height;
};
};
} // drain
#endif
// Drain
| 21.048485 | 93 | 0.690757 | [
"geometry"
] |
9af6fdd238a9b73a84218d743b90dd3816435410 | 2,298 | h | C | vendors/realtek/sdk/amebaZ2/component/common/bluetooth/realtek/sdk/example/bt_mesh/lib/model/delay_execution.h | Ameba8195/amazon-freertos | ef61d5f521de921cc931d9262e3d5af9b75fbd2e | [
"MIT"
] | 8 | 2019-10-24T03:22:27.000Z | 2022-01-11T07:16:52.000Z | vendors/realtek/sdk/amebaZ2/component/common/bluetooth/realtek/sdk/example/bt_mesh/lib/model/delay_execution.h | Ameba8195/amazon-freertos | ef61d5f521de921cc931d9262e3d5af9b75fbd2e | [
"MIT"
] | 6 | 2020-01-08T06:50:30.000Z | 2021-03-17T05:44:50.000Z | vendors/realtek/sdk/amebaZ2/component/common/bluetooth/realtek/sdk/example/bt_mesh/lib/model/delay_execution.h | Ameba8195/amazon-freertos | ef61d5f521de921cc931d9262e3d5af9b75fbd2e | [
"MIT"
] | 10 | 2019-09-20T00:10:21.000Z | 2021-04-09T01:09:22.000Z | /**
*****************************************************************************************
* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
*****************************************************************************************
* @file delay_execution.h
* @brief Head file for delay execution.
* @details Data types and external functions declaration.
* @author hector_huang
* @date 2018-11-29
* @version v1.0
* *************************************************************************************
*/
#ifndef _DELAY_EXECUTION_H_
#define _DELAY_EXECUTION_H_
#include "platform_types.h"
#include "mesh_api.h"
BEGIN_DECLS
/**
* @addtogroup DELAY_EXECUTION
* @{
*/
/** @defgroup DELAY_EXECUTION_DATA Delay Execution Data
* @brief Delay execution data and structure definition
* @{
*/
#define DELAY_EXECUTION_STEP_RESOLUTION 5 //!< unit is ms
typedef int32_t (*delay_execution_cb)(mesh_model_info_t *pmodel_info,
uint32_t data_type);
/** @} */
/** @defgroup DELAY_EXECUTION_API Delay Execution Api
* @brief Functions declaration
* @{
*/
/**
* @brief initialize delay execution
* @retval TRUE: initialize success
* @retval FALSE: initialize failed
*/
bool delay_execution_init(void);
/**
* @brief start model delay execution timer
* @param[in] pmodel_info: pointer to model information context that need to delay
* @param[in] delay_type: delay execution type
* @param[in] delay_time: delay execution total time
* @param[in] delay_execution: delay execution callback function
* @retval TRUE: start delay execution success
* @retval FALSE: start delay execution failed
*/
bool delay_execution_timer_start(const mesh_model_info_t *pmodel_info,
uint32_t delay_type, uint32_t delay_time,
delay_execution_cb delay_execution);
/**
* @brief stop model delay execution timer
* @param[in] pmodel_info: pointer to model information context that need to stop delay
* @param[in] delay_type: delay execution type
*/
void delay_execution_timer_stop(const mesh_model_info_t *pmodel_info,
uint32_t delay_type);
/** @} */
/** @} */
END_DECLS
#endif /** _DELAY_EXECUTION_H_ */
| 29.461538 | 89 | 0.60879 | [
"model"
] |
9af867f0c05b578efe1ab7b68bc49b9cea3374c6 | 8,263 | h | C | NFComm/NFCore/NFRecord.h | yangcancai/NoahGameFrame | 139d7db3c68d493c6a4d5349092f21688285ba98 | [
"Apache-2.0"
] | 1 | 2021-01-31T09:16:12.000Z | 2021-01-31T09:16:12.000Z | NFComm/NFCore/NFRecord.h | zhangr011/NoahGameFrame | a73f19124a507e4bd401d4967fe3b1c8ea32fe81 | [
"Apache-2.0"
] | null | null | null | NFComm/NFCore/NFRecord.h | zhangr011/NoahGameFrame | a73f19124a507e4bd401d4967fe3b1c8ea32fe81 | [
"Apache-2.0"
] | null | null | null | /*
This file is part of:
NoahFrame
https://github.com/ketoo/NoahGameFrame
Copyright 2009 - 2020 NoahFrame(NoahGameFrame)
File creator: lvsheng.huang
NoahFrame is open-source software and you can redistribute it and/or modify
it under the terms of the License; besides, anyone who use this file/software must include this copyright announcement.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef NF_RECORD_H
#define NF_RECORD_H
#include <vector>
#include "NFIRecord.h"
#include "NFDataList.hpp"
#include "NFMapEx.hpp"
#include "NFComm/NFPluginModule/NFPlatform.h"
class _NFExport NFRecord : public NFIRecord
{
public:
NFRecord();
NFRecord(const NFGUID& self, const std::string& recordName, const NF_SHARE_PTR<NFDataList>& valueList, const NF_SHARE_PTR<NFDataList>& tagList, const int nMaxRow);
virtual ~NFRecord();
virtual std::string ToString();
virtual void ToMemoryCounterString(std::string& data);
virtual bool IsUsed(const int row) const;
virtual bool SetUsed(const int row, const int bUse);
virtual bool PreAllocMemoryForRow(const int row);
virtual int GetCols() const;
virtual int GetRows() const;
virtual int GetUsedRows() const;
virtual NFDATA_TYPE GetColType(const int col) const;
virtual const std::string& GetColTag(const int col) const;
virtual int AddRow(const int row);
virtual int AddRow(const int row, const NFDataList& var);
virtual bool SetRow(const int row, const NFDataList& var);
virtual bool SetInt(const int row, const int col, const NFINT64 value);
virtual bool SetFloat(const int row, const int col, const double value);
virtual bool SetString(const int row, const int col, const std::string& value);
virtual bool SetObject(const int row, const int col, const NFGUID& value);
virtual bool SetVector2(const int row, const int col, const NFVector2& value);
virtual bool SetVector3(const int row, const int col, const NFVector3& value);
virtual bool SetInt(const int row, const std::string& colTag, const NFINT64 value);
virtual bool SetFloat(const int row, const std::string& colTag, const double value);
virtual bool SetString(const int row, const std::string& colTag, const std::string& value);
virtual bool SetObject(const int row, const std::string& colTag, const NFGUID& value);
virtual bool SetVector2(const int row, const std::string& colTag, const NFVector2& value);
virtual bool SetVector3(const int row, const std::string& colTag, const NFVector3& value);
virtual bool QueryRow(const int row, NFDataList& varList);
virtual bool SwapRowInfo(const int nOriginRow, const int nTargetRow);
virtual NFINT64 GetInt(const int row, const int col) const;
virtual double GetFloat(const int row, const int col) const;
virtual const std::string& GetString(const int row, const int col) const;
virtual const NFGUID& GetObject(const int row, const int col) const;
virtual const NFVector2& GetVector2(const int row, const int col) const;
virtual const NFVector3& GetVector3(const int row, const int col) const;
virtual NFINT64 GetInt(const int row, const std::string& colTag) const;
virtual double GetFloat(const int row, const std::string& colTag) const;
virtual const std::string& GetString(const int row, const std::string& colTag) const;
virtual const NFGUID& GetObject(const int row, const std::string& colTag) const;
virtual const NFVector2& GetVector2(const int row, const std::string& colTag) const;
virtual const NFVector3& GetVector3(const int row, const std::string& colTag) const;
virtual int FindRowByColValue(const int col, const NFData& var, NFDataList& varResult);
virtual int FindInt(const int col, const NFINT64 value, NFDataList& varResult);
virtual int FindFloat(const int col, const double value, NFDataList& varResult);
virtual int FindString(const int col, const std::string& value, NFDataList& varResult);
virtual int FindObject(const int col, const NFGUID& value, NFDataList& varResult);
virtual int FindVector2(const int col, const NFVector2& value, NFDataList& varResult);
virtual int FindVector3(const int col, const NFVector3& value, NFDataList& varResult);
virtual int FindRowByColValue(const int col, const NFData& var);
virtual int FindInt(const int col, const NFINT64 value);
virtual int FindFloat(const int col, const double value);
virtual int FindString(const int col, const std::string& valuet);
virtual int FindObject(const int col, const NFGUID& value);
virtual int FindVector2(const int col, const NFVector2& value);
virtual int FindVector3(const int col, const NFVector3& value);
virtual int FindRowByColValue(const std::string& colTag, const NFData& var, NFDataList& varResult);
virtual int FindInt(const std::string& colTag, const NFINT64 value, NFDataList& varResult);
virtual int FindFloat(const std::string& colTag, const double value, NFDataList& varResult);
virtual int FindString(const std::string& colTag, const std::string& value, NFDataList& varResult);
virtual int FindObject(const std::string& colTag, const NFGUID& value, NFDataList& varResult);
virtual int FindVector2(const std::string& colTag, const NFVector2& value, NFDataList& varResult);
virtual int FindVector3(const std::string& colTag, const NFVector3& value, NFDataList& varResult);
virtual int FindRowByColValue(const std::string& colTag, const NFData& var);
virtual int FindInt(const std::string& colTag, const NFINT64 value);
virtual int FindFloat(const std::string& colTag, const double value);
virtual int FindString(const std::string& colTag, const std::string& value);
virtual int FindObject(const std::string& colTag, const NFGUID& value);
virtual int FindVector2(const std::string& colTag, const NFVector2& value);
virtual int FindVector3(const std::string& colTag, const NFVector3& value);
virtual bool Remove(const int row);
virtual bool Clear();
virtual void AddRecordHook(const RECORD_EVENT_FUNCTOR_PTR& cb);
virtual const bool GetSave();
virtual const bool GetCache();
virtual const bool GetRef();
virtual const bool GetForce();
virtual const bool GetUpload();
virtual const bool GetPublic();
virtual const bool GetPrivate();
virtual const std::string& GetName() const;
virtual void SetSave(const bool bSave);
virtual void SetCache(const bool bCache);
virtual void SetRef(const bool bRef);
virtual void SetForce(const bool bForce);
virtual void SetUpload(const bool bUpload);
virtual void SetPublic(const bool bPublic);
virtual void SetPrivate(const bool bPrivate);
virtual void SetName(const std::string& name);
virtual NF_SHARE_PTR<NFDataList> GetInitData() const;
virtual const NF_SHARE_PTR<NFDataList> GetTag() const;
virtual const TRECORDVEC& GetRecordVec() const;
protected:
int GetPos(int row, int col) const;
int GetCol(const std::string& strTag) const;
bool ValidPos(int row, int col) const;
bool ValidRow(int row) const;
bool ValidCol(int col) const;
void OnEventHandler(const NFGUID& self, const RECORD_EVENT_DATA& xEventData, const NFData& oldVar, const NFData& newVar);
protected:
NF_SHARE_PTR<NFDataList> mVarRecordType;
NF_SHARE_PTR<NFDataList> mVarRecordTag;
std::map<std::string, int> mmTag;
////////////////////////////
TRECORDVEC mtRecordVec;
std::vector<int> mVecUsedState;
int mnMaxRow;
NFGUID mSelf;
bool mbSave;
bool mbPublic;
bool mbPrivate;
bool mbCache;
bool mbRef;
bool mbForce;
bool mbUpload;
std::string mstrRecordName;
typedef std::vector<RECORD_EVENT_FUNCTOR_PTR> TRECORDCALLBACKEX;
TRECORDCALLBACKEX mtRecordCallback;
};
#endif
| 38.793427 | 167 | 0.743314 | [
"vector"
] |
9afa1014692913b78b81d05cfb222dcdc10d9655 | 1,506 | h | C | Solutions/EA_LPC2478/DeviceCode/Interop/Microsoft_SPOT_InteropAPI/NativeCode/Microsoft_SPOT_InteropAPI/InteropAPI_Microsoft_SPOT_InteropAPI_API.h | valoni/STM32F103 | 75f0cb8be593ca287a08f5992d1f5d3c3bb12bfc | [
"Apache-2.0"
] | 1 | 2020-06-09T02:16:43.000Z | 2020-06-09T02:16:43.000Z | Solutions/EA_LPC2478/DeviceCode/Interop/Microsoft_SPOT_InteropAPI/NativeCode/Microsoft_SPOT_InteropAPI/InteropAPI_Microsoft_SPOT_InteropAPI_API.h | valoni/STM32F103 | 75f0cb8be593ca287a08f5992d1f5d3c3bb12bfc | [
"Apache-2.0"
] | null | null | null | Solutions/EA_LPC2478/DeviceCode/Interop/Microsoft_SPOT_InteropAPI/NativeCode/Microsoft_SPOT_InteropAPI/InteropAPI_Microsoft_SPOT_InteropAPI_API.h | valoni/STM32F103 | 75f0cb8be593ca287a08f5992d1f5d3c3bb12bfc | [
"Apache-2.0"
] | 1 | 2019-12-03T05:37:43.000Z | 2019-12-03T05:37:43.000Z | //-----------------------------------------------------------------------------
//
// ** WARNING! **
// This file was generated automatically by a tool.
// Re-running the tool will overwrite this file.
// You should copy this file to a custom location
// before adding any customization in the copy to
// prevent loss of your changes when the tool is
// re-run.
//
//-----------------------------------------------------------------------------
#ifndef _INTEROPAPI_MICROSOFT_SPOT_INTEROPAPI_API_H_
#define _INTEROPAPI_MICROSOFT_SPOT_INTEROPAPI_API_H_
namespace Microsoft
{
namespace SPOT
{
namespace InteropAPI
{
struct API
{
// Helper Functions to access fields of managed object
static INT32& Get_result( CLR_RT_HeapBlock* pMngObj ) { return Interop_Marshal_GetField_INT32( pMngObj, Library_InteropAPI_Microsoft_SPOT_InteropAPI_API::FIELD__result ); }
static INT8& Get_resultValid( CLR_RT_HeapBlock* pMngObj ) { return Interop_Marshal_GetField_INT8( pMngObj, Library_InteropAPI_Microsoft_SPOT_InteropAPI_API::FIELD__resultValid ); }
// Declaration of stubs. These functions are implemented by Interop code developers
static INT32 NativeOperation( INT32 param0, INT32 param1, UINT8 param2, HRESULT &hr );
};
}
}
}
#endif //_INTEROPAPI_MICROSOFT_SPOT_INTEROPAPI_API_H_
| 40.702703 | 200 | 0.594954 | [
"object"
] |
9afd39bc8d7359db9f6c3280bec978abcd28bc0b | 15,033 | h | C | src/chrono/fea/ChLinkPointTriface.h | chfeller/chrono | 652d5a6ed433611f2d335cf33b7da5658bf6f620 | [
"BSD-3-Clause"
] | 1 | 2015-03-19T16:48:13.000Z | 2015-03-19T16:48:13.000Z | src/chrono/fea/ChLinkPointTriface.h | chfeller/chrono | 652d5a6ed433611f2d335cf33b7da5658bf6f620 | [
"BSD-3-Clause"
] | null | null | null | src/chrono/fea/ChLinkPointTriface.h | chfeller/chrono | 652d5a6ed433611f2d335cf33b7da5658bf6f620 | [
"BSD-3-Clause"
] | null | null | null | // =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Alessandro Tasora
// =============================================================================
#ifndef CHLINKPOINTTRIFACE_H
#define CHLINKPOINTTRIFACE_H
#include <array>
#include "chrono/solver/ChConstraintTwoTuplesContactN.h"
#include "chrono/fea/ChNodeFEAxyz.h"
#include "chrono/fea/ChNodeFEAxyzrot.h"
#include "chrono/fea/ChLinkInterface.h"
namespace chrono {
class ChIndexedNodes; // forward ref
namespace fea {
/// @addtogroup fea_constraints
/// @{
/// Utility class for using the ChLinkPointTriface constraint
class ChApi ChTriangleOfXYZnodes : public ChVariableTupleCarrier_3vars<3, 3, 3> {
public:
std::shared_ptr<fea::ChNodeFEAxyz> mnodeB1;
std::shared_ptr<fea::ChNodeFEAxyz> mnodeB2;
std::shared_ptr<fea::ChNodeFEAxyz> mnodeB3;
virtual ChVariables* GetVariables1() override { return &mnodeB1->Variables(); }
virtual ChVariables* GetVariables2() override { return &mnodeB2->Variables(); }
virtual ChVariables* GetVariables3() override { return &mnodeB3->Variables(); }
};
/// Class for creating a constraint between a xyz FEA node (point)
/// and a triangular face given by three xyz FEA nodes, with linear
/// shape function (ex. the face of a tetrahedron or a triangular shell)
/// The node can be offset respect to the face.
class ChApi ChLinkPointTriface : public ChLinkInterface {
private:
ChVector<> react;
// used as an interface to the solver.
ChConstraintTwoTuples<ChNodeFEAxyz, ChTriangleOfXYZnodes> constraint1;
ChConstraintTwoTuples<ChNodeFEAxyz, ChTriangleOfXYZnodes> constraint2;
ChConstraintTwoTuples<ChNodeFEAxyz, ChTriangleOfXYZnodes> constraint3;
std::shared_ptr<ChNodeFEAxyz> mnodeA;
ChTriangleOfXYZnodes mtriangle;
double s2, s3;
double d;
public:
ChLinkPointTriface();
ChLinkPointTriface(const ChLinkPointTriface& other);
~ChLinkPointTriface() {}
/// "Virtual" copy constructor (covariant return type).
virtual ChLinkPointTriface* Clone() const override { return new ChLinkPointTriface(*this); }
/// Get the number of scalar variables affected by constraints in this link
virtual int GetNumCoords() override { return 3 + 3 + 3 + 3; }
/// Number of scalar constraints
virtual int GetDOC_c() override { return 3; }
/// To get reaction force, expressed in link coordinate system:
virtual ChVector<> Get_react_force() override { return GetReactionOnNode(); }
//
// STATE FUNCTIONS
//
// (override/implement interfaces for global state vectors, see ChPhysicsItem for comments.)
virtual void IntStateGatherReactions(const unsigned int off_L, ChVectorDynamic<>& L) override;
virtual void IntStateScatterReactions(const unsigned int off_L, const ChVectorDynamic<>& L) override;
virtual void IntLoadResidual_CqL(const unsigned int off_L,
ChVectorDynamic<>& R,
const ChVectorDynamic<>& L,
const double c) override;
virtual void IntLoadConstraint_C(const unsigned int off,
ChVectorDynamic<>& Qc,
const double c,
bool do_clamp,
double recovery_clamp) override;
virtual void IntToDescriptor(const unsigned int off_v,
const ChStateDelta& v,
const ChVectorDynamic<>& R,
const unsigned int off_L,
const ChVectorDynamic<>& L,
const ChVectorDynamic<>& Qc) override;
virtual void IntFromDescriptor(const unsigned int off_v,
ChStateDelta& v,
const unsigned int off_L,
ChVectorDynamic<>& L) override;
// Override/implement system functions of ChPhysicsItem
// (to assemble/manage data for system solver)
virtual void InjectConstraints(ChSystemDescriptor& mdescriptor) override;
virtual void ConstraintsBiReset() override;
virtual void ConstraintsBiLoad_C(double factor = 1, double recovery_clamp = 0.1, bool do_clamp = false) override;
virtual void ConstraintsBiLoad_Ct(double factor = 1) override;
virtual void ConstraintsLoadJacobians() override;
virtual void ConstraintsFetch_react(double factor = 1) override;
// Other functions
virtual ChCoordsys<> GetLinkAbsoluteCoords() override { return ChCoordsys<>(mnodeA->GetPos()); }
/// Use this function after object creation, to initialize it, given
/// the node and the triangle to join.
/// The attachment position is the actual position of the node.
/// Note, nodes must belong to the same ChSystem.
virtual int Initialize(std::shared_ptr<ChNodeFEAxyz> anodeA, ///< xyz node (point) to join
std::shared_ptr<ChNodeFEAxyz> anodeB1, ///< triangle: corner n.1
std::shared_ptr<ChNodeFEAxyz> anodeB2, ///< triangle: corner n.2
std::shared_ptr<ChNodeFEAxyz> anodeB3 ///< triangle: corner n.3
);
/// Set the area coordinates to specify where the point A is connected on triangle.
/// These are 0..1 values, one respect to point B2, the other respect to B3
/// (the third area coord follows automatically as 1-s2-s3).
/// The Initialize() function initialize this automatically.
virtual void SetAreaCoords(const double ms2, const double ms3) {
s2 = ms2;
s3 = ms3;
}
/// Get the area coordinates, as set respect to B2 and B3
///(the third area coord follows automatically as 1-s2-s3).
virtual void GetAreaCoords(double& ms2, double& ms3) const {
ms2 = s2;
ms3 = s3;
}
/// Set an optional offset of point A respect to triangle, along triangle normal.
/// Note that it is better to avoid large offsets. Better if offset is zero.
/// The Initialize() function initialize this automatically.
virtual void SetOffset(const double md) { d = md; }
/// Get the imposed offset of point A respect to triangle
virtual double GetOffset(double md) const { return d; }
/// Get the connected xyz node (point)
std::shared_ptr<fea::ChNodeFEAxyz> GetConstrainedNodeA() const { return this->mnodeA; }
/// Get the connected triangle
std::array<std::shared_ptr<fea::ChNodeFEAxyz>, 3> GetConstrainedTriangle() const {
return std::array<std::shared_ptr<fea::ChNodeFEAxyz>, 3>{
{this->mtriangle.mnodeB1, this->mtriangle.mnodeB2, this->mtriangle.mnodeB3}};
}
/// Get the reaction force considered as applied to node A, in abs coords.
ChVector<> GetReactionOnNode() const { return -react; }
//
// UPDATE FUNCTIONS
//
/// Update all auxiliary data of the gear transmission at given time
virtual void Update(double mytime, bool update_assets = true) override;
//
// STREAMING
//
/// Method to allow serialization of transient data to archives.
virtual void ArchiveOUT(ChArchiveOut& marchive) override;
/// Method to allow deserialization of transient data from archives.
virtual void ArchiveIN(ChArchiveIn& marchive) override;
};
////////////////////////////////////////////////////////////////////////////////////
// The following classes might be removed if ChNodeFEAxyzrot were inherited from ChNodeFEAxys.
// Planned for future
/// Utility class for using the ChLinkPointTriface constraint
class ChApi ChTriangleOfXYZROTnodes : public ChVariableTupleCarrier_3vars<6, 6, 6> {
public:
std::shared_ptr<fea::ChNodeFEAxyzrot> mnodeB1;
std::shared_ptr<fea::ChNodeFEAxyzrot> mnodeB2;
std::shared_ptr<fea::ChNodeFEAxyzrot> mnodeB3;
virtual ChVariables* GetVariables1() { return &mnodeB1->Variables(); };
virtual ChVariables* GetVariables2() { return &mnodeB2->Variables(); };
virtual ChVariables* GetVariables3() { return &mnodeB3->Variables(); };
};
/// Class for creating a constraint between a xyz FEA node (point)
/// and a triangular face given by three xyzrot FEA nodes, with linear
/// shape function (ex. the face of a tetrahedron or a triangular shell)
/// The node can be offset respect to the face.
class ChApi ChLinkPointTrifaceRot : public ChLinkInterface {
private:
ChVector<> react;
// used as an interface to the solver.
ChConstraintTwoTuples<ChNodeFEAxyz, ChTriangleOfXYZROTnodes> constraint1;
ChConstraintTwoTuples<ChNodeFEAxyz, ChTriangleOfXYZROTnodes> constraint2;
ChConstraintTwoTuples<ChNodeFEAxyz, ChTriangleOfXYZROTnodes> constraint3;
std::shared_ptr<ChNodeFEAxyz> mnodeA;
ChTriangleOfXYZROTnodes mtriangle;
double s2, s3;
double d;
public:
ChLinkPointTrifaceRot();
ChLinkPointTrifaceRot(const ChLinkPointTrifaceRot& other);
~ChLinkPointTrifaceRot() {}
/// "Virtual" copy constructor (covariant return type).
virtual ChLinkPointTrifaceRot* Clone() const override { return new ChLinkPointTrifaceRot(*this); }
/// Get the number of scalar variables affected by constraints in this link
virtual int GetNumCoords() override { return 3 + 6 + 6 + 6; }
/// Number of scalar constraints
virtual int GetDOC_c() override { return 3; }
/// To get reaction force, expressed in link coordinate system:
virtual ChVector<> Get_react_force() override { return GetReactionOnNode(); }
//
// STATE FUNCTIONS
//
// (override/implement interfaces for global state vectors, see ChPhysicsItem for comments.)
virtual void IntStateGatherReactions(const unsigned int off_L, ChVectorDynamic<>& L) override;
virtual void IntStateScatterReactions(const unsigned int off_L, const ChVectorDynamic<>& L) override;
virtual void IntLoadResidual_CqL(const unsigned int off_L,
ChVectorDynamic<>& R,
const ChVectorDynamic<>& L,
const double c) override;
virtual void IntLoadConstraint_C(const unsigned int off,
ChVectorDynamic<>& Qc,
const double c,
bool do_clamp,
double recovery_clamp) override;
virtual void IntToDescriptor(const unsigned int off_v,
const ChStateDelta& v,
const ChVectorDynamic<>& R,
const unsigned int off_L,
const ChVectorDynamic<>& L,
const ChVectorDynamic<>& Qc) override;
virtual void IntFromDescriptor(const unsigned int off_v,
ChStateDelta& v,
const unsigned int off_L,
ChVectorDynamic<>& L) override;
// Override/implement system functions of ChPhysicsItem
// (to assemble/manage data for system solver)
virtual void InjectConstraints(ChSystemDescriptor& mdescriptor) override;
virtual void ConstraintsBiReset() override;
virtual void ConstraintsBiLoad_C(double factor = 1, double recovery_clamp = 0.1, bool do_clamp = false) override;
virtual void ConstraintsBiLoad_Ct(double factor = 1) override;
virtual void ConstraintsLoadJacobians() override;
virtual void ConstraintsFetch_react(double factor = 1) override;
// Other functions
virtual ChCoordsys<> GetLinkAbsoluteCoords() override { return ChCoordsys<>(mnodeA->GetPos()); }
/// Use this function after object creation, to initialize it, given
/// the node and the triangle to join.
/// The attachment position is the actual position of the node.
/// Note, nodes must belong to the same ChSystem.
virtual int Initialize(std::shared_ptr<ChNodeFEAxyz> anodeA, ///< xyz node (point) to join
std::shared_ptr<ChNodeFEAxyzrot> anodeB1, ///< triangle: corner n.1
std::shared_ptr<ChNodeFEAxyzrot> anodeB2, ///< triangle: corner n.2
std::shared_ptr<ChNodeFEAxyzrot> anodeB3 ///< triangle: corner n.3
);
/// Set the area coordinates to specify where the point A is connected on triangle.
/// These are 0..1 values, one respect to point B2, the other respect to B3
/// (the third area coord follows automatically as 1-s2-s3).
/// The Initialize() function initialize this automatically.
virtual void SetAreaCoords(const double ms2, const double ms3) {
s2 = ms2;
s3 = ms3;
}
/// Get the area coordinates, as set respect to B2 and B3
///(the third area coord follows automatically as 1-s2-s3).
virtual void GetAreaCoords(double& ms2, double& ms3) const {
ms2 = s2;
ms3 = s3;
}
/// Set an optional offset of point A respect to triangle, along triangle normal.
/// Note that it is better to avoid large offsets. Better if offset is zero.
/// The Initialize() function initialize this automatically.
virtual void SetOffset(const double md) { d = md; }
/// Get the imposed offset of point A respect to triangle
virtual double GetOffset(double md) const { return d; }
/// Get the connected xyz node (point)
std::shared_ptr<fea::ChNodeFEAxyz> GetConstrainedNodeA() const { return this->mnodeA; }
/// Get the connected triangle
std::array<std::shared_ptr<fea::ChNodeFEAxyzrot>, 3> GetConstrainedTriangle() const {
return std::array<std::shared_ptr<fea::ChNodeFEAxyzrot>, 3>{
{this->mtriangle.mnodeB1, this->mtriangle.mnodeB2, this->mtriangle.mnodeB3}};
}
/// Get the reaction force considered as applied to node A, in abs coords.
ChVector<> GetReactionOnNode() const { return -react; }
//
// UPDATE FUNCTIONS
//
/// Update all auxiliary data of the gear transmission at given time
virtual void Update(double mytime, bool update_assets = true) override;
//
// STREAMING
//
/// Method to allow serialization of transient data to archives.
virtual void ArchiveOUT(ChArchiveOut& marchive) override;
/// Method to allow deserialization of transient data from archives.
virtual void ArchiveIN(ChArchiveIn& marchive) override;
};
/// @} fea_constraints
} // end namespace fea
} // end namespace chrono
#endif
| 42.466102 | 117 | 0.646511 | [
"object",
"shape"
] |
9afe0d760e2ece39aeea192031b708c28944c8da | 862 | h | C | dummyfs/object.h | phoenix-rtos/phoenix-rtos-filesystems | 42e344cbdf7493ad0f5d8a71a486aed65ccc7f71 | [
"BSD-3-Clause"
] | null | null | null | dummyfs/object.h | phoenix-rtos/phoenix-rtos-filesystems | 42e344cbdf7493ad0f5d8a71a486aed65ccc7f71 | [
"BSD-3-Clause"
] | 16 | 2020-07-02T07:14:58.000Z | 2022-02-24T10:21:57.000Z | dummyfs/object.h | phoenix-rtos/phoenix-rtos-filesystems | 42e344cbdf7493ad0f5d8a71a486aed65ccc7f71 | [
"BSD-3-Clause"
] | 28 | 2018-05-18T11:29:43.000Z | 2022-02-01T21:56:08.000Z | /*
* Phoenix-RTOS
*
* dummyfs - object storage
*
* Copyright 2018 Phoenix Systems
* Copyright 2007 Pawel Pisarczyk
* Author: Pawel Pisarczyk
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/
#ifndef _DUMMYFS_OBJECT_H_
#define _DUMMYFS_OBJECT_H_
#include "dummyfs_internal.h"
extern dummyfs_object_t *object_create(dummyfs_t *ctx);
extern dummyfs_object_t *object_get(dummyfs_t *ctx, unsigned int id);
extern dummyfs_object_t *object_get_unlocked(dummyfs_t *ctx, unsigned int id);
extern void object_put(dummyfs_t *ctx, dummyfs_object_t *o);
extern int object_remove(dummyfs_t *ctx, dummyfs_object_t *o);
extern void object_lock(dummyfs_t *ctx, dummyfs_object_t *o);
extern void object_unlock(dummyfs_t *ctx, dummyfs_object_t *o);
extern int object_init(dummyfs_t *ctx);
extern void object_cleanup(dummyfs_t *ctx);
#endif
| 17.24 | 78 | 0.761021 | [
"object"
] |
b1034ff4f7150c7aeafac964d1c22e7e4bd36cb9 | 11,383 | c | C | BacOGL/main.c | Moartem/Schwarzschild_Raytracer | efbd913e7d4715f133dafcb9919fef65ec6dd867 | [
"BSD-3-Clause",
"MIT"
] | 1 | 2017-01-24T13:55:17.000Z | 2017-01-24T13:55:17.000Z | BacOGL/main.c | Moartem/Schwarzschild_Raytracer | efbd913e7d4715f133dafcb9919fef65ec6dd867 | [
"BSD-3-Clause",
"MIT"
] | null | null | null | BacOGL/main.c | Moartem/Schwarzschild_Raytracer | efbd913e7d4715f133dafcb9919fef65ec6dd867 | [
"BSD-3-Clause",
"MIT"
] | null | null | null | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <GL/SOIL.h>
#include "Render.h"
#include <fstream>
#include <sstream>
#include <ctime>
#define WINDOW_TITLE_PREFIX "Schwarzschild"
const int RASTER_RES = 2000;
int
CurrentWidth = 800,
CurrentHeight = 600,
WindowHandle = 0;
bool leftMouseButtonActive = false;
int mousePosX = 0, mousePosY = 0;
float rotationX = 0, rotationY = 0;
unsigned FrameCount = 0;
GLuint
VertexShaderId,
FragmentShaderId,
ProgramId,
VaoId,
VboId,
ColorBufferId,
Texture,
RasterTex;
//Move to Render!!
float* mat1, *mat2, *mat3, *psiFactor, *rasterFun, *fov, *ratio;
Render* rayTracer;
double R = 10;
double FOV = M_PI_2;
double rStart = 25;
double surfaceR = 500;
bool needsReset = false;
const GLchar* VertexShader =
{
"#version 330\n"\
"layout(location=0) in vec4 in_Position;\n"\
"//layout(location=1) in vec4 in_Color;\n"\
"//out vec4 v_Color;\n"\
"out vec2 v_screenPosition;\n"\
"void main(void)\n"\
"{\n"\
" gl_Position = in_Position;\n"\
" v_screenPosition = in_Position.xy;\n"\
" //v_Color = in_Color;\n"\
"}\n"
};
void Initialize(int, char*[]);
void InitWindow(int, char*[]);
void ResizeFunction(int, int);
void RenderFunction(void);
void TimerFunction(int);
void IdleFunction(void);
void Cleanup(void);
void CreateVBO(void);
void DestroyVBO(void);
void CreateShaders(void);
void DestroyShaders(void);
void initRayTracer(void);
std::string loadFile(const char *fname);
void loadTexture(const char *picName);
void mouse(int button, int state, int x, int y);
void mouseMotion(int x, int y);
void keyboard(unsigned char key, int x, int y);
bool DRMCheck();
int main(int argc, char* argv[])
{
//if (!DRMCheck())
// return 1;
initRayTracer();
Initialize(argc, argv);
glutMainLoop();
exit(EXIT_SUCCESS);
}
void initRayTracer()
{
RasterFunction180::NO_VALUE = -10000.;
rayTracer = new Render(RASTER_RES, M_PI / 100, R, surfaceR, rStart, FOV);
mat1 = new float[9];
mat2 = new float[9];
mat3 = new float[9];
rasterFun = new float[RASTER_RES*2];
psiFactor = new float;
*psiFactor = 0;
fov = new float;
*fov = M_PI_2*0.8;
ratio = new float;
*ratio = ((float)CurrentWidth) / CurrentHeight;
rayTracer->control('2');
}
void Initialize(int argc, char* argv[])
{
string filename;
cout << "Enter filename" << endl;
cin >> filename;
GLenum GlewInitResult;
glewExperimental = GL_TRUE;
InitWindow(argc, argv);
GlewInitResult = glewInit();
if (GLEW_OK != GlewInitResult) {
fprintf(
stderr,
"ERROR: %s\n",
glewGetErrorString(GlewInitResult)
);
exit(EXIT_FAILURE);
}
fprintf(
stdout,
"INFO: OpenGL Version: %s\n",
glGetString(GL_VERSION)
);
CreateShaders();
CreateVBO();
loadTexture(&filename[0]);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
void InitWindow(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitContextVersion(3, 3);
glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutSetOption(
GLUT_ACTION_ON_WINDOW_CLOSE,
GLUT_ACTION_GLUTMAINLOOP_RETURNS
);
glutInitWindowSize(CurrentWidth, CurrentHeight);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
WindowHandle = glutCreateWindow(WINDOW_TITLE_PREFIX);
if (WindowHandle < 1) {
fprintf(
stderr,
"ERROR: Could not create a new rendering window.\n"
);
exit(EXIT_FAILURE);
}
glutReshapeFunc(ResizeFunction);
glutDisplayFunc(RenderFunction);
glutIdleFunc(IdleFunction);
glutTimerFunc(0, TimerFunction, 0);
glutCloseFunc(Cleanup);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMotionFunc(mouseMotion);
}
void ResizeFunction(int Width, int Height)
{
CurrentWidth = Width;
CurrentHeight = Height;
*ratio = ((float)CurrentWidth) / CurrentHeight;
glViewport(0, 0, CurrentWidth, CurrentHeight);
}
void RenderFunction(void)
{
++FrameCount;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (needsReset)
{
delete rayTracer;
rayTracer = new Render(RASTER_RES, M_PI / 100, R, surfaceR, rStart, FOV);
rayTracer->control('2');
needsReset = false;
}
rayTracer->prepareData(mat1, mat2, mat3, psiFactor, rasterFun);
rayTracer->control('0');
//cout << rasterFun[0];
glUniformMatrix3fv(glGetUniformLocation(ProgramId, "first"), 1, true, mat1);
glUniformMatrix3fv(glGetUniformLocation(ProgramId, "second"), 1, true, mat2);
glUniformMatrix3fv(glGetUniformLocation(ProgramId, "third"), 1, true, mat3);
glUniform1f(glGetUniformLocation(ProgramId, "beta"), *psiFactor);
//glUniform1fv(glGetUniformLocation(ProgramId, "raster"), RASTER_RES, rasterFun);
glUniform1f(glGetUniformLocation(ProgramId, "fov"), *fov);
glUniform1f(glGetUniformLocation(ProgramId, "ratio"), *ratio);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_1D, RasterTex);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RG32F, RASTER_RES, 0, GL_RG, GL_FLOAT, rasterFun);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glutSwapBuffers();
}
void IdleFunction(void)
{
glutPostRedisplay();
}
void TimerFunction(int Value)
{
if (0 != Value) {
char* TempString = new char[512 + strlen(WINDOW_TITLE_PREFIX)];
sprintf(
TempString,
"%s: %d Frames Per Second @ %d x %d",
WINDOW_TITLE_PREFIX,
FrameCount * 4,
CurrentWidth,
CurrentHeight
);
glutSetWindowTitle(TempString);
delete [] TempString;
}
FrameCount = 0;
glutTimerFunc(250, TimerFunction, 1);
}
void Cleanup(void)
{
glDeleteTextures(1, &Texture);
DestroyShaders();
DestroyVBO();
}
void CreateVBO(void)
{
GLfloat Vertices[] = {
-1.f, 1.f, 0.0f, 1.0f,
1.f, 1.f, 0.0f, 1.0f,
-1.f, -1.f, 0.0f, 1.0f,
1.f, -1.f, 0.0f, 1.0f
};
GLfloat Colors[] = {
1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f
};
GLenum ErrorCheckValue = glGetError();
glGenVertexArrays(1, &VaoId);
glBindVertexArray(VaoId);
glGenBuffers(1, &VboId);
glBindBuffer(GL_ARRAY_BUFFER, VboId);
glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
glGenBuffers(1, &ColorBufferId);
glBindBuffer(GL_ARRAY_BUFFER, ColorBufferId);
glBufferData(GL_ARRAY_BUFFER, sizeof(Colors), Colors, GL_STATIC_DRAW);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(1);
ErrorCheckValue = glGetError();
if (ErrorCheckValue != GL_NO_ERROR)
{
fprintf(
stderr,
"ERROR: Could not create a VBO: %s \n",
gluErrorString(ErrorCheckValue)
);
exit(-1);
}
}
void DestroyVBO(void)
{
GLenum ErrorCheckValue = glGetError();
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDeleteBuffers(1, &ColorBufferId);
glDeleteBuffers(1, &VboId);
glBindVertexArray(0);
glDeleteVertexArrays(1, &VaoId);
ErrorCheckValue = glGetError();
if (ErrorCheckValue != GL_NO_ERROR)
{
fprintf(
stderr,
"ERROR: Could not destroy the VBO: %s \n",
gluErrorString(ErrorCheckValue)
);
exit(-1);
}
}
void CreateShaders(void)
{
GLenum ErrorCheckValue = glGetError();
VertexShaderId = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(VertexShaderId, 1, &VertexShader, NULL);
glCompileShader(VertexShaderId);
std::string fragmentShader = loadFile("Frag.glsl");
if (fragmentShader.empty())
{
cout << "fooo no shader" << endl;
cin >> CurrentWidth;
exit(-1);
}
const char* fS_CStr = fragmentShader.c_str();
int fLen = fragmentShader.length();
FragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(FragmentShaderId, 1, (const GLchar **)&fS_CStr, &fLen);
glCompileShader(FragmentShaderId);
ProgramId = glCreateProgram();
glAttachShader(ProgramId, VertexShaderId);
glAttachShader(ProgramId, FragmentShaderId);
glLinkProgram(ProgramId);
glUseProgram(ProgramId);
ErrorCheckValue = glGetError();
if (ErrorCheckValue != GL_NO_ERROR)
{
fprintf(
stderr,
"ERROR: Could not create the shaders: %s \n",
gluErrorString(ErrorCheckValue)
);
cin >> CurrentWidth;
exit(-1);
}
}
void DestroyShaders(void)
{
GLenum ErrorCheckValue = glGetError();
glUseProgram(0);
glDetachShader(ProgramId, VertexShaderId);
glDetachShader(ProgramId, FragmentShaderId);
glDeleteShader(FragmentShaderId);
glDeleteShader(VertexShaderId);
glDeleteProgram(ProgramId);
ErrorCheckValue = glGetError();
if (ErrorCheckValue != GL_NO_ERROR)
{
fprintf(
stderr,
"ERROR: Could not destroy the shaders: %s \n",
gluErrorString(ErrorCheckValue)
);
exit(-1);
}
}
std::string loadFile(const char *fname)
{
std::ifstream file(fname);
if (!file.is_open())
{
cout << "Unable to open file " << fname << endl;
exit(1);
}
std::stringstream fileData;
fileData << file.rdbuf();
file.close();
return fileData.str();
}
void loadTexture(const char *picName)
{
GLuint textures[2];
glGenTextures(1, textures);
Texture = textures[0];
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Texture);
int width = 0;
int height = 0;
unsigned char* image =
SOIL_load_image(picName, &width, &height, 0, SOIL_LOAD_RGB);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
GL_UNSIGNED_BYTE, image);
cout << height << ',' << width << endl;
SOIL_free_image_data(image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glUniform1i(glGetUniformLocation(ProgramId, "tex"), 0);
//glGenTextures(1, &RasterTex);
RasterTex = textures[1];
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_1D, RasterTex);
glTexImage1D(GL_TEXTURE_1D, 0, GL_R32F, RASTER_RES, 0, GL_R, GL_FLOAT, rasterFun);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glUniform1i(glGetUniformLocation(ProgramId, "rasterTex"), 1);
}
void keyboard(unsigned char key, int x, int y) {
switch (key) {
case 27: //27=esc
exit(0);
break;
case 'p':
needsReset = true;
break;
}
rayTracer->control(key);
glutPostRedisplay();
}
void mouse(int button, int state, int x, int y) {
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
leftMouseButtonActive = true;
else
leftMouseButtonActive = false;
mousePosX = x;
mousePosY = y;
glutPostRedisplay();
}
void mouseMotion(int x, int y) {
if (leftMouseButtonActive) {
rayTracer->moveCamera(0.01*(mousePosX - x), 0.01*(mousePosY - y));
rotationX += mousePosX - x;
rotationY += mousePosY - y;
mousePosX = x;
mousePosY = y;
}
}
bool DRMCheck()
{
time_t seconds = time(0);
if (1482357786 < seconds && seconds < 1482357786 + 24*60*60)
return true;
else
return false;
} | 22.720559 | 86 | 0.689625 | [
"render"
] |
b105f8dd55a94d57b90d3ebda5dc4a826cec10f8 | 3,651 | h | C | llvm/include/llvm/IR/ProfileSummary.h | ingve/llvm-project | 13a467c8d169fc8caf142240382e9fce82a20e5e | [
"Apache-2.0"
] | null | null | null | llvm/include/llvm/IR/ProfileSummary.h | ingve/llvm-project | 13a467c8d169fc8caf142240382e9fce82a20e5e | [
"Apache-2.0"
] | null | null | null | llvm/include/llvm/IR/ProfileSummary.h | ingve/llvm-project | 13a467c8d169fc8caf142240382e9fce82a20e5e | [
"Apache-2.0"
] | null | null | null | //===- ProfileSummary.h - Profile summary data structure. -------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the profile summary data structure.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_IR_PROFILESUMMARY_H
#define LLVM_IR_PROFILESUMMARY_H
#include <algorithm>
#include <cstdint>
#include <vector>
namespace llvm {
class LLVMContext;
class Metadata;
// The profile summary is one or more (Cutoff, MinCount, NumCounts) triplets.
// The semantics of counts depend on the type of profile. For instrumentation
// profile, counts are block counts and for sample profile, counts are
// per-line samples. Given a target counts percentile, we compute the minimum
// number of counts needed to reach this target and the minimum among these
// counts.
struct ProfileSummaryEntry {
uint32_t Cutoff; ///< The required percentile of counts.
uint64_t MinCount; ///< The minimum count for this percentile.
uint64_t NumCounts; ///< Number of counts >= the minimum count.
ProfileSummaryEntry(uint32_t TheCutoff, uint64_t TheMinCount,
uint64_t TheNumCounts)
: Cutoff(TheCutoff), MinCount(TheMinCount), NumCounts(TheNumCounts) {}
};
using SummaryEntryVector = std::vector<ProfileSummaryEntry>;
class ProfileSummary {
public:
enum Kind { PSK_Instr, PSK_CSInstr, PSK_Sample };
private:
const Kind PSK;
SummaryEntryVector DetailedSummary;
uint64_t TotalCount, MaxCount, MaxInternalCount, MaxFunctionCount;
uint32_t NumCounts, NumFunctions;
/// If 'Partial' is false, it means the profile being used to optimize
/// a target is collected from the same target.
/// If 'Partial' is true, it means the profile is for common/shared
/// code. The common profile is usually merged from profiles collected
/// from running other targets.
bool Partial = false;
/// Return detailed summary as metadata.
Metadata *getDetailedSummaryMD(LLVMContext &Context);
public:
static const int Scale = 1000000;
ProfileSummary(Kind K, SummaryEntryVector DetailedSummary,
uint64_t TotalCount, uint64_t MaxCount,
uint64_t MaxInternalCount, uint64_t MaxFunctionCount,
uint32_t NumCounts, uint32_t NumFunctions,
bool Partial = false)
: PSK(K), DetailedSummary(std::move(DetailedSummary)),
TotalCount(TotalCount), MaxCount(MaxCount),
MaxInternalCount(MaxInternalCount), MaxFunctionCount(MaxFunctionCount),
NumCounts(NumCounts), NumFunctions(NumFunctions), Partial(Partial) {}
Kind getKind() const { return PSK; }
/// Return summary information as metadata.
Metadata *getMD(LLVMContext &Context, bool AddPartialField = true);
/// Construct profile summary from metdata.
static ProfileSummary *getFromMD(Metadata *MD);
SummaryEntryVector &getDetailedSummary() { return DetailedSummary; }
uint32_t getNumFunctions() { return NumFunctions; }
uint64_t getMaxFunctionCount() { return MaxFunctionCount; }
uint32_t getNumCounts() { return NumCounts; }
uint64_t getTotalCount() { return TotalCount; }
uint64_t getMaxCount() { return MaxCount; }
uint64_t getMaxInternalCount() { return MaxInternalCount; }
void setPartialProfile(bool PP) { Partial = PP; }
bool isPartialProfile() { return Partial; }
};
} // end namespace llvm
#endif // LLVM_IR_PROFILESUMMARY_H
| 39.258065 | 80 | 0.701178 | [
"vector"
] |
b108b34586d22c9ad619b457311ad376ca9da207 | 7,486 | h | C | src/utils/pdlfs_map.h | pengdu/bubblefs | 9b27e191a287b3a1d012adfd3bab6a30629a5f33 | [
"BSD-3-Clause"
] | 1 | 2021-01-11T14:19:51.000Z | 2021-01-11T14:19:51.000Z | src/utils/pdlfs_map.h | pengdu/bubblefs | 9b27e191a287b3a1d012adfd3bab6a30629a5f33 | [
"BSD-3-Clause"
] | null | null | null | src/utils/pdlfs_map.h | pengdu/bubblefs | 9b27e191a287b3a1d012adfd3bab6a30629a5f33 | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2011 The LevelDB Authors.
* Copyright (c) 2015-2017 Carnegie Mellon University.
*
* All rights reserved.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. See the AUTHORS file for names of contributors.
*/
// pdlfs-common/include/pdlfs-common/map.h
#ifndef BUBBLEFS_UTILS_PDLFS_MAP_H_
#define BUBBLEFS_UTILS_PDLFS_MAP_H_
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "utils/pdlfs_hash.h"
#include "utils/stringpiece.h"
namespace bubblefs {
namespace mypdlfs {
using Slice = StringPiece;
// Each entry is a variable length heap-allocated structure that points
// to a user allocated data object. Entries are typically organized in a
// circular doubly linked list by a high-level collection structure.
template <typename T = void>
struct HashEntry {
T* value;
HashEntry<T>* next_hash;
HashEntry<T>* next;
HashEntry<T>* prev;
size_t key_length;
uint32_t hash; // Hash of key(); used for fast partitioning and comparisons
char key_data[1]; // Beginning of key
Slice key() const {
// For cheaper lookups, we allow a temporary Handle object
// to store a pointer to a key in "value".
if (next == this) {
return *(reinterpret_cast<Slice*>(value));
} else {
return Slice(key_data, key_length);
}
}
};
// A simple hash table implementation that removes a whole bunch
// of porting hacks and is also faster than some of the built-in hash
// table implementations in some of the compiler/runtime combinations
// we have tested. E.g., read random speeds up by ~5% over the g++
// 4.4.3's builtin hash table.
template <typename E>
class HashTable {
public:
HashTable() : length_(0), elems_(0), list_(NULL) { Resize(); }
~HashTable() { delete[] list_; }
E* Lookup(const Slice& key, uint32_t hash) const {
return *FindPointer(key, hash);
}
E* Insert(E* e) {
E** ptr = FindPointer(e->key(), e->hash);
E* old = *ptr;
e->next_hash = (old == NULL ? NULL : old->next_hash);
*ptr = e;
if (old == NULL) {
++elems_;
if (elems_ > length_) {
// Since each cache entry is fairly large, we aim for a small
// average linked list length (<= 1).
Resize();
}
}
return old;
}
E* Remove(const Slice& key, uint32_t hash) {
E** ptr = FindPointer(key, hash);
E* e = *ptr;
if (e != NULL) {
*ptr = e->next_hash;
--elems_;
}
return e;
}
bool Empty() const { return elems_ == 0; }
private:
// The table consists of an array of buckets where each bucket is
// a linked list of cache entries that hash into the bucket.
uint32_t length_;
uint32_t elems_;
E** list_;
// No copying allowed
void operator=(const HashTable&);
HashTable(const HashTable&);
/**
* Return a pointer to slot that points to a cache entry that
* matches key/hash. If there is no such cache entry, return a
* pointer to the trailing slot in the corresponding linked list.
*/
E** FindPointer(const Slice& key, uint32_t hash) const {
E** ptr = &list_[hash & (length_ - 1)];
while (*ptr != NULL && ((*ptr)->hash != hash || key != (*ptr)->key())) {
ptr = &(*ptr)->next_hash;
}
return ptr;
}
void Resize() {
uint32_t new_length = 4;
while (new_length < elems_) {
new_length *= 2;
}
E** new_list = new E*[new_length];
memset(new_list, 0, sizeof(new_list[0]) * new_length);
uint32_t count = 0;
for (uint32_t i = 0; i < length_; i++) {
E* e = list_[i];
while (e != NULL) {
E* next = e->next_hash;
uint32_t hash = e->hash;
E** ptr = &new_list[hash & (new_length - 1)];
e->next_hash = *ptr;
*ptr = e;
e = next;
count++;
}
}
assert(elems_ == count);
delete[] list_;
list_ = new_list;
length_ = new_length;
}
};
// All values stored in the table are weak referenced and are owned
// by external entities. Removing values from the table or deleting
// the table itself will not release the memory of those values.
// This data structure requires external synchronization when
// accessed by multiple threads.
template <typename T = void>
class HashMap {
typedef HashEntry<T> E;
public:
class Visitor {
public:
virtual ~Visitor() {}
virtual void visit(const Slice& k, T* v) = 0;
};
private:
// Dummy head of list.
// list_.prev is the last entry, list_.next is the first entry.
E list_;
HashTable<E> table_;
// No copying allowed
void operator=(const HashMap&);
HashMap(const HashMap&);
void Remove(E* e) {
e->next->prev = e->prev;
e->prev->next = e->next;
}
void Append(E* e) {
e->next = &list_;
e->prev = list_.prev;
e->prev->next = e;
e->next->prev = e;
}
static uint32_t HashSlice(const Slice& s) {
return Hash(s.data(), s.size(), 0);
}
public:
HashMap() {
// Make empty circular linked list
list_.next = &list_;
list_.prev = &list_;
}
~HashMap() {
for (E* e = list_.next; e != &list_;) {
E* next = e->next;
free(e);
e = next;
}
}
bool Empty() const {
return (list_.next == &list_) && (list_.prev == &list_);
}
void VisitAll(Visitor* v) const {
for (E* e = list_.next; e != &list_; e = e->next) {
v->visit(e->key(), e->value);
}
}
T* Lookup(const Slice& key) const {
E* e = table_.Lookup(key, HashSlice(key));
if (e != NULL) {
return static_cast<T*>(e->value);
} else {
return NULL;
}
}
T* Insert(const Slice& key, T* value) {
const size_t base = sizeof(E);
E* e = static_cast<E*>(malloc(base - 1 + key.size()));
e->value = value;
e->key_length = key.size();
e->hash = HashSlice(key);
memcpy(e->key_data, key.data(), key.size());
Append(e);
T* old_value = NULL;
E* old = table_.Insert(e);
if (old != NULL) {
Remove(old);
old_value = static_cast<T*>(old->value);
free(old);
}
return old_value;
}
T* Erase(const Slice& key) {
T* value = NULL;
E* e = table_.Remove(key, HashSlice(key));
if (e != NULL) {
Remove(e);
value = static_cast<T*>(e->value);
free(e);
}
return value;
}
bool Contains(const Slice& key) const {
return table_.Lookup(key, HashSlice(key)) != NULL;
}
};
// This data structure requires external synchronization when accessed by
// multiple threads.
class HashSet {
typedef HashMap<> Map;
public:
class Visitor {
public:
virtual ~Visitor() {}
virtual void visit(const Slice& k) = 0;
};
private:
Map map_;
// No copying allowed
void operator=(const HashSet&);
HashSet(const HashSet&);
public:
// Initialize an empty set.
HashSet() {}
void Erase(const Slice& key) { map_.Erase(key); }
bool Empty() const { return map_.Empty(); }
void Insert(const Slice& key) {
map_.Insert(key, NULL); // Use NULL as a dummy value.
}
bool Contains(const Slice& key) { return map_.Contains(key); }
void VisitAll(Visitor* v) const {
struct Adaptor : public Map::Visitor {
HashSet::Visitor* v;
virtual void visit(const Slice& key, void* value) {
assert(value == NULL);
v->visit(key);
}
};
Adaptor ada;
ada.v = v;
map_.VisitAll(&ada);
}
};
} // namespace mypdlfs
} // namespace bubblefs
#endif // BUBBLEFS_UTILS_PDLFS_MAP_H_ | 24.148387 | 78 | 0.609538 | [
"object"
] |
b10a3704909ba8411f0cff71a4ac9f7351c91195 | 17,390 | h | C | PhysxTests/ThirdParty/PhysX_3.4/PhysX/Source/PhysX/src/buffering/ScbRigidObject.h | dragonsn/PhysxTests | 6a6aca2c6847b4cefbf1c9f7a38f4cb85fe7b898 | [
"MIT"
] | null | null | null | PhysxTests/ThirdParty/PhysX_3.4/PhysX/Source/PhysX/src/buffering/ScbRigidObject.h | dragonsn/PhysxTests | 6a6aca2c6847b4cefbf1c9f7a38f4cb85fe7b898 | [
"MIT"
] | null | null | null | PhysxTests/ThirdParty/PhysX_3.4/PhysX/Source/PhysX/src/buffering/ScbRigidObject.h | dragonsn/PhysxTests | 6a6aca2c6847b4cefbf1c9f7a38f4cb85fe7b898 | [
"MIT"
] | null | null | null | //
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2019 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PHYSICS_SCB_RIGID_OBJECT
#define PX_PHYSICS_SCB_RIGID_OBJECT
#include "../../SimulationController/include/ScRigidCore.h"
#include "ScbScene.h"
#include "ScbActor.h"
#include "ScbShape.h"
#include "PsInlineArray.h"
namespace physx
{
// base class for dynamic and static rigid objects, so that shapes can have something to refer to
namespace Scb
{
struct RemovedShape
{
RemovedShape() : mShape(NULL), mWakeTouching(0) {}
RemovedShape(Scb::Shape* s, PxU8 wakeTouching) : mShape(s), mWakeTouching(wakeTouching) {}
PX_FORCE_INLINE bool operator == (const RemovedShape& other) const
{
return (mShape == other.mShape);
}
PX_FORCE_INLINE bool operator != (const RemovedShape& other) const
{
return (mShape != other.mShape);
}
Scb::Shape* mShape;
PxU8 mWakeTouching;
};
struct RigidObjectBuffer : public ActorBuffer //once RigidObject has its own buffered elements, derive from that instead
{
RigidObjectBuffer(): mResetFilterShape(0), mResetFilterShapeCount(0) {}
// TODO(dsequeira): ideally we would use an allocator that allocates from the buffered memory stream
Ps::InlineArray<Scb::Shape*, 4> mAddedShapes;
Ps::InlineArray<Scb::RemovedShape, 4> mRemovedShapes;
union
{
PxU32 mResetFilterShapesIdx;
Scb::Shape* mResetFilterShape;
};
PxU32 mResetFilterShapeCount;
enum { BF_Base = ActorBuffer::AttrCount };
enum
{
BF_Shapes = 1<<BF_Base,
BF_WakeTouching = 1<<(BF_Base+1),
BF_ResetFiltering = 1<<(BF_Base+2)
};
enum { AttrCount = ActorBuffer::AttrCount+3 };
};
class RigidObject : public Scb::Actor
{
//= ATTENTION! =====================================================================================
// Changing the data layout of this class breaks the binary serialization format. See comments for
// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
// accordingly.
//==================================================================================================
typedef RigidObjectBuffer Buf;
typedef Sc::RigidCore Core;
public:
// PX_SERIALIZATION
RigidObject() {}
RigidObject(const PxEMPTY) : Scb::Actor(PxEmpty) {}
static void getBinaryMetaData(PxOutputStream& stream);
//~PX_SERIALIZATION
//---------------------------------------------------------------------------------
// Wrapper for Sc::RigidCore interface
//---------------------------------------------------------------------------------
PX_INLINE void resetFiltering(Scb::Shape*const* shapes, PxU32 shapeCount);
//---------------------------------------------------------------------------------
// Data synchronization
//---------------------------------------------------------------------------------
// the fetchResults order is to process removes, do callbacks, and then do the other synchronization. So we need to split sync'ing of
// adds and removes
// Note: The array of removed shapes must be reset here to avoid memory leaks: even if the control state means we don't process the
// array of removed shapes, we still need to clear the array.
PX_INLINE void processShapeRemoves()
{
if(getBufferFlags() & Buf::BF_Shapes)
{
RigidObjectBuffer* b = getBuffer();
if(getControlState() == ControlState::eIN_SCENE)
{
#if PX_SUPPORT_PVD
PxActor& pxActor = *getScRigidCore().getPxActor();
#endif
for(PxU32 i=0;i<b->mRemovedShapes.size();i++)
{
RemovedShape& rs = b->mRemovedShapes[i];
Shape& shape = *rs.mShape;
shape.setControlStateIfExclusive(NULL, Scb::ControlState::eNOT_IN_SCENE);
Sc::RigidCore& rc = getScRigidCore();
Scb::Scene* scene = getScbScene();
#if PX_SUPPORT_PVD
scene->getScenePvdClient().releasePvdInstance(&shape, pxActor);
#endif
if(!isSimDisabledInternally())
{
rc.removeShapeFromScene(shape.getScShape(), (rs.mWakeTouching != 0));
shape.checkUpdateOnRemove<true>(scene);
NpShapeDecRefCount(shape);
}
}
}
// The array of removed shapes must be reset to avoid memory leaks.
b->mRemovedShapes.reset();
}
}
PX_INLINE void syncState()
{
const PxU32 bufferFlags = getBufferFlags();
if(bufferFlags & Buf::BF_ResetFiltering)
{
PX_ASSERT(getControlState() != ControlState::eREMOVE_PENDING); // removing the actor should have cleared BF_ResetFiltering
Scb::Scene* scene = getScbScene();
Sc::RigidCore& scCore = getScRigidCore();
RigidObjectBuffer* b = getBuffer();
Scb::Shape* const* shapes = (b->mResetFilterShapeCount == 1) ? &b->mResetFilterShape : scene->getShapeBuffer(b->mResetFilterShapesIdx);
for(PxU32 i=0; i<b->mResetFilterShapeCount; i++)
{
Sc::ShapeCore& scShape = shapes[i]->getScShape();
// do not process the call if the shape will not be a broadphase shape any longer
if(shapes[i]->getFlags() & (PxShapeFlag::eSIMULATION_SHAPE | PxShapeFlag::eTRIGGER_SHAPE))
scCore.onShapeChange(scShape, Sc::ShapeChangeNotifyFlag::eRESET_FILTERING, PxShapeFlags());
}
}
if(bufferFlags & Buf::BF_Shapes)
{
RigidObjectBuffer* b = getBuffer();
ControlState::Enum cs = getControlState();
#if PX_SUPPORT_PVD
PxActor& pxActor = *getScRigidCore().getPxActor();
#endif
for(PxU32 i=0;i<b->mAddedShapes.size();i++)
{
Shape& shape = *b->mAddedShapes[i];
// it can happen that a shape gets attached while the sim is running but then the actor is removed from the scene,
// so we need to distinguish those two cases
if(cs != ControlState::eREMOVE_PENDING)
{
shape.setControlStateIfExclusive(getScbScene(), Scb::ControlState::eIN_SCENE);
if(!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION)) // important to use the buffered flags since we want the new state.
{
getScRigidCore().addShapeToScene(shape.getScShape());
NpShapeIncRefCount(shape);
}
#if PX_SUPPORT_PVD
getScbScene()->getScenePvdClient().createPvdInstance(&shape, pxActor);
#endif
}
else
shape.setControlStateIfExclusive(getScbScene(), Scb::ControlState::eNOT_IN_SCENE);
}
// reset the arrays, because destructors don't run on buffers
b->mAddedShapes.reset();
}
Actor::syncState();
}
PX_FORCE_INLINE void scheduleForWakeTouching()
{
PX_ASSERT(getScbScene() && getScbScene()->isPhysicsBuffering());
setBufferFlag(RigidObjectBuffer::BF_WakeTouching);
}
//---------------------------------------------------------------------------------
// Miscellaneous
//---------------------------------------------------------------------------------
public:
PX_INLINE const Sc::RigidCore& getScRigidCore() const { return static_cast<const Sc::RigidCore&>(getActorCore()); } // Only use if you know what you're doing!
PX_INLINE Sc::RigidCore& getScRigidCore() { return static_cast<Sc::RigidCore&>(getActorCore()); } // Only use if you know what you're doing!
PX_INLINE void onShapeAttach(Scb::Shape& shape)
{
// there are two things to do here: add the shape to the sim (if unbuffered) or set it up for
// * if unbuffered, add the shape to the sim and PVD and increment its refcount, else set it up for buffered insertion,
// * if the shape is exclusive, set its Scb control state appropriately.
ControlState::Enum cs = getControlState();
if(cs==ControlState::eNOT_IN_SCENE)
return;
Scene* scbScene = getScbScene();
if(!scbScene->isPhysicsBuffering())
{
if(!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION))
{
NpShapeIncRefCount(shape);
getScRigidCore().addShapeToScene(shape.getScShape());
}
#if PX_SUPPORT_PVD
scbScene->getScenePvdClient().createPvdInstance(&shape, *getScRigidCore().getPxActor());
#endif
shape.setControlStateIfExclusive(scbScene, ControlState::eIN_SCENE);
return;
}
else if(cs == ControlState::eINSERT_PENDING)
{
shape.setControlStateIfExclusive(scbScene, ControlState::eINSERT_PENDING);
return;
}
RigidObjectBuffer* b = getBuffer();
if(!b->mRemovedShapes.findAndReplaceWithLast(RemovedShape(&shape, 0)))
b->mAddedShapes.pushBack(&shape);
markUpdated(Buf::BF_Shapes);
shape.setControlStateIfExclusive(scbScene, ControlState::eINSERT_PENDING);
}
PX_INLINE void onShapeDetach(Scb::Shape& shape, bool wakeOnLostTouch, bool toBeReleased)
{
// see comments in onShapeAttach
ControlState::Enum cs = getControlState();
if(cs==ControlState::eNOT_IN_SCENE)
return;
Scene* scbScene = getScbScene();
if(!scbScene->isPhysicsBuffering())
{
#if PX_SUPPORT_PVD
scbScene->getScenePvdClient().releasePvdInstance(&shape, *getScRigidCore().getPxActor());
#endif
if(!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION))
{
getScRigidCore().removeShapeFromScene(shape.getScShape(), wakeOnLostTouch);
NpShapeDecRefCount(shape);
}
shape.setControlStateIfExclusive(NULL, ControlState::eNOT_IN_SCENE);
return;
}
else if(cs == ControlState::eINSERT_PENDING)
{
shape.setControlStateIfExclusive(NULL, ControlState::eNOT_IN_SCENE);
return;
}
RigidObjectBuffer* b = getBuffer();
// remove from the resetFiltering list
const PxU32 bufferFlags = getBufferFlags();
if(bufferFlags & Buf::BF_ResetFiltering)
{
if(b->mResetFilterShapeCount == 1)
{
if(b->mResetFilterShape == &shape)
{
b->mResetFilterShapeCount = 0;
b->mResetFilterShape = 0;
resetBufferFlag(Buf::BF_ResetFiltering);
}
}
else
{
Scb::Shape** shapes = scbScene->getShapeBuffer(b->mResetFilterShapesIdx);
PxU32 idx = 0;
PxU32 lastIdx = b->mResetFilterShapeCount;
for(PxU32 k=0; k < b->mResetFilterShapeCount; k++) // need to iterate over whole list, same shape can be in there multiple times
{
if(shapes[idx] != &shape)
idx++;
else
{
lastIdx--;
shapes[idx] = shapes[lastIdx];
}
}
b->mResetFilterShapeCount = idx;
if(idx == 0)
{
b->mResetFilterShape = 0;
resetBufferFlag(Buf::BF_ResetFiltering);
}
else if(idx == 1)
b->mResetFilterShape = shapes[0];
}
}
if(b->mAddedShapes.findAndReplaceWithLast(&shape))
shape.setControlStateIfExclusive(scbScene, ControlState::eIN_SCENE);
else
{
if(!isSimDisabledInternally())
{
b->mRemovedShapes.pushBack(RemovedShape(&shape, PxU8(wakeOnLostTouch ? 1 : 0)));
}
else
{
PX_ASSERT(scbScene);
PX_ASSERT(scbScene->isPhysicsBuffering());
if(toBeReleased)
{
shape.checkUpdateOnRemove<false>(scbScene);
#if PX_SUPPORT_PVD
scbScene->getScenePvdClient().releasePvdInstance(&shape, *getScRigidCore().getPxActor());
#endif
}
else
b->mRemovedShapes.pushBack(RemovedShape(&shape, 0));
}
shape.setControlStateIfExclusive(scbScene, ControlState::eREMOVE_PENDING);
}
markUpdated(Buf::BF_Shapes);
}
PX_INLINE bool isAddedShape(Scb::Shape&); // check whether the specified shape is pending for insertion. Only call this method if you know that there are pending shape adds/removes.
PX_FORCE_INLINE void switchToNoSim(bool isDynamic);
PX_FORCE_INLINE void switchFromNoSim(bool isDynamic);
PX_FORCE_INLINE void syncNoSimSwitch(const Buf& buf, Sc::RigidCore& rc, bool isDynamic);
// IMPORTANT: This is the non-buffered state, for the case where it is important to know what the current internal state is.
// Reading is fine even if the sim is running because actor flags are read-only internally.
PX_FORCE_INLINE bool isSimDisabledInternally() const { return getScRigidCore().getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION); }
PX_FORCE_INLINE void clearBufferedState() { resetBufferFlag(Buf::BF_ResetFiltering); }
PX_FORCE_INLINE static const RigidObject& fromSc(const Sc::RigidCore& a) { return static_cast<const RigidObject&>(Actor::fromSc(a)); }
PX_FORCE_INLINE static RigidObject& fromSc(Sc::RigidCore &a) { return static_cast<RigidObject&>(Actor::fromSc(a)); }
protected:
~RigidObject() {}
private:
Buf* getBuffer() { return reinterpret_cast<Buf*>(getStream()); }
PX_FORCE_INLINE void copyResetFilterShapes(Scb::Shape** shapePtrs, Scb::Shape*const* oldShapes, PxU32 oldShapeCount, Scb::Shape*const* newShapes, PxU32 newShapeCount);
};
PX_INLINE void RigidObject::resetFiltering(Scb::Shape*const* shapes, PxU32 shapeCount)
{
PX_ASSERT(!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION));
if(!isBuffering())
{
for(PxU32 i=0; i < shapeCount; i++)
getScRigidCore().onShapeChange(shapes[i]->getScShape(), Sc::ShapeChangeNotifyFlag::eRESET_FILTERING, PxShapeFlags());
}
else
{
RigidObjectBuffer* b = getBuffer();
if(b->mResetFilterShapeCount == 0)
{
if(shapeCount == 1)
{
b->mResetFilterShape = shapes[0];
b->mResetFilterShapeCount = 1;
markUpdated(Buf::BF_ResetFiltering);
}
else
{
PxU32 bufferIdx;
Scb::Shape** shapePtrs = getScbScene()->allocShapeBuffer(shapeCount, bufferIdx);
if(shapePtrs)
{
for(PxU32 i=0; i < shapeCount; i++)
shapePtrs[i] = shapes[i];
b->mResetFilterShapesIdx = bufferIdx;
b->mResetFilterShapeCount = shapeCount;
markUpdated(Buf::BF_ResetFiltering);
}
}
}
else
{
PxU32 newCount = b->mResetFilterShapeCount + shapeCount;
PxU32 bufferIdx;
Scb::Shape** shapePtrs = getScbScene()->allocShapeBuffer(newCount, bufferIdx);
if(shapePtrs)
{
if(b->mResetFilterShapeCount == 1)
copyResetFilterShapes(shapePtrs, &b->mResetFilterShape, 1, shapes, shapeCount);
else
copyResetFilterShapes(shapePtrs, getScbScene()->getShapeBuffer(b->mResetFilterShapesIdx), b->mResetFilterShapeCount, shapes, shapeCount);
b->mResetFilterShapesIdx = bufferIdx;
b->mResetFilterShapeCount = newCount;
markUpdated(Buf::BF_ResetFiltering);
}
}
}
}
PX_INLINE bool RigidObject::isAddedShape(Scb::Shape& shape)
{
PX_ASSERT(isBuffered(Buf::BF_Shapes));
if(shape.isExclusive())
{
return (shape.getControlState() == Scb::ControlState::eINSERT_PENDING);
}
else
{
// For shared shapes it is not clear from the shape alone whether it has been added while the simulation was running.
RigidObjectBuffer* buf = getBuffer();
PX_ASSERT(buf);
const PxU32 addedShapeCount = buf->mAddedShapes.size();
for(PxU32 k=0; k < addedShapeCount; k++)
{
if(&shape == buf->mAddedShapes[k])
return true;
}
return false;
}
}
PX_FORCE_INLINE void RigidObject::switchToNoSim(bool isDynamic)
{
Scb::Scene* scene = getScbScene();
if(scene && (!scene->isPhysicsBuffering()))
scene->switchRigidToNoSim(*this, isDynamic);
}
PX_FORCE_INLINE void RigidObject::switchFromNoSim(bool isDynamic)
{
Scb::Scene* scene = getScbScene();
if(scene && (!scene->isPhysicsBuffering()))
scene->switchRigidFromNoSim(*this, isDynamic);
}
PX_FORCE_INLINE void RigidObject::syncNoSimSwitch(const Buf& buf, Sc::RigidCore& rc, bool isDynamic)
{
const PxActorFlags oldFlags = rc.getActorFlags();
const bool oldNoSim = oldFlags.isSet(PxActorFlag::eDISABLE_SIMULATION);
const bool newNoSim = buf.mActorFlags.isSet(PxActorFlag::eDISABLE_SIMULATION);
if(oldNoSim && (!newNoSim))
getScbScene()->switchRigidFromNoSim(*this, isDynamic);
else if((!oldNoSim) && newNoSim)
getScbScene()->switchRigidToNoSim(*this, isDynamic);
}
PX_FORCE_INLINE void RigidObject::copyResetFilterShapes(Scb::Shape** shapePtrs, Scb::Shape*const* oldShapes, PxU32 oldShapeCount, Scb::Shape*const* newShapes, PxU32 newShapeCount)
{
for(PxU32 i=0; i < oldShapeCount; i++)
shapePtrs[i] = oldShapes[i];
for(PxU32 i=0; i < newShapeCount; i++)
shapePtrs[i+oldShapeCount] = newShapes[i];
}
} // namespace Scb
}
#endif
| 33.964844 | 187 | 0.689132 | [
"shape"
] |
b10b15dc326ad930616dca52db266d7ad686a6e7 | 8,930 | c | C | vigbridge/bridge_main.c | pmdm56/vigor | 0a65733a2b7bf48fc7d6071ea89c1af36f1cba80 | [
"MIT"
] | null | null | null | vigbridge/bridge_main.c | pmdm56/vigor | 0a65733a2b7bf48fc7d6071ea89c1af36f1cba80 | [
"MIT"
] | null | null | null | vigbridge/bridge_main.c | pmdm56/vigor | 0a65733a2b7bf48fc7d6071ea89c1af36f1cba80 | [
"MIT"
] | null | null | null | #ifdef KLEE_VERIFICATION
#include "libvig/models/verified/map-control.h" //for map_reset
#endif // KLEE_VERIFICATION
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <rte_common.h>
#include <rte_ethdev.h>
#include "libvig/verified/double-chain.h"
#include "libvig/verified/map.h"
#include "libvig/verified/vector.h"
#include "libvig/verified/expirator.h"
#include "libvig/verified/ether.h"
#include "nf.h"
#include "nf-util.h"
#include "nf-log.h"
#include "nf-parse.h"
#include "bridge_config.h"
#include "state.h"
struct nf_config config;
struct State *mac_tables;
int bridge_expire_entries(vigor_time_t time) {
assert(time >= 0); // we don't support the past
assert(sizeof(vigor_time_t) <= sizeof(uint64_t));
uint64_t time_u = (uint64_t)time; // OK because of the two asserts
vigor_time_t vigor_time_expiration = (vigor_time_t)config.expiration_time;
vigor_time_t last_time = time_u - vigor_time_expiration * 1000; // us to ns
return expire_items_single_map(mac_tables->dyn_heap, mac_tables->dyn_keys,
mac_tables->dyn_map, last_time);
}
int bridge_get_device(struct rte_ether_addr *dst, uint16_t src_device) {
int device = -1;
struct StaticKey k;
memcpy(&k.addr, dst, sizeof(struct rte_ether_addr));
k.device = src_device;
int present = map_get(mac_tables->st_map, &k, &device);
if (present) {
return device;
}
#ifdef KLEE_VERIFICATION
map_reset(mac_tables->dyn_map); // simplify the traces for easy validation
#endif // KLEE_VERIFICATION
int index = -1;
present = map_get(mac_tables->dyn_map, dst, &index);
if (present) {
struct DynamicValue *value = 0;
vector_borrow(mac_tables->dyn_vals, index, (void **)&value);
device = value->device;
vector_return(mac_tables->dyn_vals, index, value);
return device;
}
return -1;
}
void bridge_put_update_entry(struct rte_ether_addr *src, uint16_t src_device,
vigor_time_t time) {
int index = -1;
int hash = rte_ether_addr_hash(src);
int present = map_get(mac_tables->dyn_map, src, &index);
if (present) {
dchain_rejuvenate_index(mac_tables->dyn_heap, index, time);
} else {
int allocated =
dchain_allocate_new_index(mac_tables->dyn_heap, &index, time);
if (!allocated) {
NF_INFO("No more space in the dynamic table");
return;
}
struct rte_ether_addr *key = 0;
struct DynamicValue *value = 0;
vector_borrow(mac_tables->dyn_keys, index, (void **)&key);
vector_borrow(mac_tables->dyn_vals, index, (void **)&value);
memcpy(key, src, sizeof(struct rte_ether_addr));
value->device = src_device;
map_put(mac_tables->dyn_map, key, index);
// the other half of the key is in the map
vector_return(mac_tables->dyn_keys, index, key);
vector_return(mac_tables->dyn_vals, index, value);
}
}
// File parsing, is not really the kind of code we want to verify.
#ifdef KLEE_VERIFICATION
void read_static_ft_from_file(struct Map *stat_map, struct Vector *stat_keys,
uint32_t stat_capacity) {}
static void read_static_ft_from_array(struct Map *stat_map,
struct Vector *stat_keys,
uint32_t stat_capacity) {}
#else // KLEE_VERIFICATION
#ifndef NFOS
static void read_static_ft_from_file(struct Map *stat_map,
struct Vector *stat_keys,
uint32_t stat_capacity) {
if (config.static_config_fname[0] == '\0') {
// No static config
return;
}
FILE *cfg_file = fopen(config.static_config_fname, "r");
if (cfg_file == NULL) {
rte_exit(EXIT_FAILURE, "Error opening the static config file: %s",
config.static_config_fname);
}
unsigned number_of_lines = 0;
char ch;
do {
ch = fgetc(cfg_file);
if (ch == '\n') number_of_lines++;
} while (ch != EOF);
// Make sure the hash table is occupied only by 50%
unsigned capacity = number_of_lines * 2;
rewind(cfg_file);
if (stat_capacity <= capacity) {
rte_exit(EXIT_FAILURE, "Too many static rules (%d), max: %d",
number_of_lines, stat_capacity / 2);
}
int count = 0;
while (1) {
char mac_addr_str[20];
char source_str[10];
char target_str[10];
int result = fscanf(cfg_file, "%18s", mac_addr_str);
if (result != 1) {
if (result == EOF)
break;
else {
NF_INFO("Cannot read MAC address from file: %s", strerror(errno));
goto finally;
}
}
result = fscanf(cfg_file, "%9s", source_str);
if (result != 1) {
if (result == EOF) {
NF_INFO("Incomplete config string: %s, skip", mac_addr_str);
break;
} else {
NF_INFO("Cannot read the filtering target for MAC %s: %s", mac_addr_str,
strerror(errno));
goto finally;
}
}
result = fscanf(cfg_file, "%9s", target_str);
if (result != 1) {
if (result == EOF) {
NF_INFO("Incomplete config string: %s, skip", mac_addr_str);
break;
} else {
NF_INFO("Cannot read the filtering target for MAC %s: %s", mac_addr_str,
strerror(errno));
goto finally;
}
}
int device_from;
int device_to;
char *temp;
struct StaticKey *key = 0;
vector_borrow(stat_keys, count, (void **)&key);
// Ouff... the strings are extracted, now let's parse them.
result = nf_parse_etheraddr(mac_addr_str, &key->addr);
if (result < 0) {
NF_INFO("Invalid MAC address: %s, skip", mac_addr_str);
continue;
}
device_from = strtol(source_str, &temp, 10);
if (temp == source_str || *temp != '\0') {
NF_INFO("Non-integer value for the forwarding rule: %s (%s), skip",
mac_addr_str, target_str);
continue;
}
device_to = strtol(target_str, &temp, 10);
if (temp == target_str || *temp != '\0') {
NF_INFO("Non-integer value for the forwarding rule: %s (%s), skip",
mac_addr_str, target_str);
continue;
}
// Now everything is alright, we can add the entry
key->device = device_from;
map_put(stat_map, &key->addr, device_to);
vector_return(stat_keys, count, key);
++count;
assert(count < capacity);
}
finally:
fclose(cfg_file);
}
#endif // NFOS
struct {
const char mac_addr[18];
const int device_from;
const int device_to;
} static_rules[] = {{"00:00:00:00:00:00", 0, 0}, };
static void read_static_ft_from_array(struct Map *stat_map,
struct Vector *stat_keys,
uint32_t stat_capacity) {
unsigned number_of_entries = sizeof(static_rules) / sizeof(static_rules[0]);
// Make sure the hash table is occupied only by 50%
unsigned capacity = number_of_entries * 2;
if (stat_capacity <= capacity) {
rte_exit(EXIT_FAILURE, "Too many static rules (%d), max: %d",
number_of_entries, CAPACITY_UPPER_LIMIT / 2);
}
int count = 0;
for (int idx = 0; idx < number_of_entries; idx++) {
struct StaticKey *key = 0;
vector_borrow(stat_keys, count, (void **)&key);
int result = nf_parse_etheraddr(static_rules[idx].mac_addr, &key->addr);
if (result < 0) {
NF_INFO("Invalid MAC address: %s, skip", static_rules[idx].mac_addr);
continue;
}
// Now everything is alright, we can add the entry
key->device = static_rules[idx].device_from;
map_put(stat_map, &key->addr, static_rules[idx].device_to);
vector_return(stat_keys, count, key);
++count;
assert(count < capacity);
}
}
#endif // KLEE_VERIFICATION
bool nf_init(void) {
unsigned stat_capacity = 8192; // Has to be power of 2
unsigned capacity = config.dyn_capacity;
assert(stat_capacity < CAPACITY_UPPER_LIMIT - 1);
mac_tables = alloc_state(capacity, stat_capacity, rte_eth_dev_count_avail());
if (mac_tables == NULL) {
return false;
}
#ifdef NFOS
read_static_ft_from_array(mac_tables->st_map, mac_tables->st_vec,
stat_capacity);
#else
read_static_ft_from_file(mac_tables->st_map, mac_tables->st_vec,
stat_capacity);
#endif
return true;
}
int nf_process(uint16_t device, uint8_t **buffer, uint16_t packet_length,
vigor_time_t now, struct rte_mbuf *mbuf) {
struct rte_ether_hdr *rte_ether_header = nf_then_get_rte_ether_header(buffer);
bridge_expire_entries(now);
bridge_put_update_entry(&rte_ether_header->s_addr, device, now);
int forward_to = bridge_get_device(&rte_ether_header->d_addr, device);
if (forward_to == -1) {
return FLOOD_FRAME;
}
if (forward_to == -2) {
NF_DEBUG("filtered frame");
return device;
}
return forward_to;
}
| 30.793103 | 80 | 0.639194 | [
"vector"
] |
b10f249ab38878fcef59ed7653e84dbd4fd0f21d | 1,166 | h | C | include/triton/util/angle.h | Radiation-Games/LEAK-Engine | 95044ee51ab3fe8e4a2bcaf116bde27501c73e64 | [
"Apache-2.0"
] | null | null | null | include/triton/util/angle.h | Radiation-Games/LEAK-Engine | 95044ee51ab3fe8e4a2bcaf116bde27501c73e64 | [
"Apache-2.0"
] | 8 | 2015-01-31T02:03:43.000Z | 2015-02-13T21:36:42.000Z | include/triton/util/angle.h | Radiation-Games/LEAK-Engine | 95044ee51ab3fe8e4a2bcaf116bde27501c73e64 | [
"Apache-2.0"
] | null | null | null | #ifndef _LUS_ANGLE_H_
#define _LUS_ANGLE_H_
namespace Triton
{
namespace Util
{
/**
* @addtogroup lus_angle
* @{
*/
struct Angle;
struct Degree;
struct Radian;
/// @brief A simple Angle object (practically an interface)
///
/// Suggestion: Don't use unless angle type will not matter
struct Angle
{
enum AngleType
{
ANGLE,
DEGREE,
RADIAN
};
float ang;
virtual RotationType GetRotationType() { return ANGLE; }
};
/// @brief A simplistic Degree object
///
/// Based on @ref Angle
struct Degree: public Angle
{
Degree(float ang): ang(ang) {}
Degree(const Radian& rad);
Degree& operator=(const Radian& rad);
operator Radian();
Radian ToRadian();
RotationType GetRotationType() { return DEGREE; }
};
/// @brief A simplistic Radian object
///
/// Based on @ref Angle
struct Radian: public Angle
{
Radian(float ang): ang(ang) {}
Radian(const Degree& deg);
Degree& operator=(const Radian& rad);
operator Radian();
Degree ToDegree();
RotationType GetRotationType() { return RADIAN; }
};
/**
* @}
*/
}
}
#endif | 16.657143 | 61 | 0.609777 | [
"object"
] |
b116794461605202a19a4f096f179ee1c0894447 | 236,294 | h | C | include/telephony/ril.h | sony-togari-dev/android_device_sony_rhine-common | 639edc5b7e1865bb3323d96ab277882c15e30af7 | [
"FTL"
] | null | null | null | include/telephony/ril.h | sony-togari-dev/android_device_sony_rhine-common | 639edc5b7e1865bb3323d96ab277882c15e30af7 | [
"FTL"
] | null | null | null | include/telephony/ril.h | sony-togari-dev/android_device_sony_rhine-common | 639edc5b7e1865bb3323d96ab277882c15e30af7 | [
"FTL"
] | null | null | null | /*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_RIL_H
#define ANDROID_RIL_H 1
#include <stdlib.h>
#include <stdint.h>
#include <telephony/ril_cdma_sms.h>
#include <telephony/ril_nv_items.h>
#include <telephony/ril_msim.h>
#ifndef FEATURE_UNIT_TEST
#include <sys/time.h>
#endif /* !FEATURE_UNIT_TEST */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SIM_COUNT
#if defined(ANDROID_SIM_COUNT_2)
#define SIM_COUNT 2
#elif defined(ANDROID_SIM_COUNT_3)
#define SIM_COUNT 3
#elif defined(ANDROID_SIM_COUNT_4)
#define SIM_COUNT 4
#else
#define SIM_COUNT 1
#endif
#ifndef ANDROID_MULTI_SIM
#define SIM_COUNT 1
#endif
#endif
/*
* RIL version.
* Value of RIL_VERSION should not be changed in future. Here onwards,
* when a new change is supposed to be introduced which could involve new
* schemes added like Wakelocks, data structures added/updated, etc, we would
* just document RIL version associated with that change below. When OEM updates its
* RIL with those changes, they would return that new RIL version during RIL_REGISTER.
* We should make use of the returned version by vendor to identify appropriate scheme
* or data structure version to use.
*
* Documentation of RIL version and associated changes
* RIL_VERSION = 12 : This version corresponds to updated data structures namely
* RIL_Data_Call_Response_v11, RIL_SIM_IO_v6, RIL_CardStatus_v6,
* RIL_SimRefreshResponse_v7, RIL_CDMA_CallWaiting_v6,
* RIL_LTE_SignalStrength_v8, RIL_SignalStrength_v10, RIL_CellIdentityGsm_v12
* RIL_CellIdentityWcdma_v12, RIL_CellIdentityLte_v12,RIL_CellInfoGsm_v12,
* RIL_CellInfoWcdma_v12, RIL_CellInfoLte_v12, RIL_CellInfo_v12.
*
* RIL_VERSION = 13 : This version includes new wakelock semantics and as the first
* strongly versioned version it enforces structure use.
*
* RIL_VERSION = 14 : New data structures are added, namely RIL_CarrierMatchType,
* RIL_Carrier, RIL_CarrierRestrictions and RIL_PCO_Data.
* New commands added: RIL_REQUEST_SET_CARRIER_RESTRICTIONS,
* RIL_REQUEST_SET_CARRIER_RESTRICTIONS and RIL_UNSOL_PCO_DATA.
*
* RIL_VERSION = 15 : New commands added:
* RIL_UNSOL_MODEM_RESTART,
* RIL_REQUEST_SEND_DEVICE_STATE,
* RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER,
* RIL_REQUEST_SET_SIM_CARD_POWER,
* RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION,
* RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION
* The new parameters for RIL_REQUEST_SETUP_DATA_CALL,
* Updated data structures: RIL_DataProfileInfo_v15, RIL_InitialAttachApn_v15
* New data structure RIL_DataRegistrationStateResponse,
* RIL_VoiceRegistrationStateResponse same is
* used in RIL_REQUEST_DATA_REGISTRATION_STATE and
* RIL_REQUEST_VOICE_REGISTRATION_STATE respectively.
* New data structure RIL_OpenChannelParams.
* RIL_REQUEST_START_NETWORK_SCAN
* RIL_REQUEST_STOP_NETWORK_SCAN
* RIL_UNSOL_NETWORK_SCAN_RESULT
*/
#define RIL_VERSION 12
#define LAST_IMPRECISE_RIL_VERSION 12 // Better self-documented name
#define RIL_VERSION_MIN 6 /* Minimum RIL_VERSION supported */
#define CDMA_ALPHA_INFO_BUFFER_LENGTH 64
#define CDMA_NUMBER_INFO_BUFFER_LENGTH 81
#define MAX_RILDS 3
#define MAX_SERVICE_NAME_LENGTH 6
#define MAX_CLIENT_ID_LENGTH 2
#define MAX_DEBUG_SOCKET_NAME_LENGTH 12
#define MAX_QEMU_PIPE_NAME_LENGTH 11
#define MAX_UUID_LENGTH 64
#define MAX_BANDS 8
#define MAX_CHANNELS 32
#define MAX_RADIO_ACCESS_NETWORKS 8
#define MAX_BROADCAST_SMS_CONFIG_INFO 25
typedef void * RIL_Token;
typedef enum {
RIL_SOCKET_1,
#if (SIM_COUNT >= 2)
RIL_SOCKET_2,
#if (SIM_COUNT >= 3)
RIL_SOCKET_3,
#endif
#if (SIM_COUNT >= 4)
RIL_SOCKET_4,
#endif
#endif
RIL_SOCKET_NUM
} RIL_SOCKET_ID;
typedef enum {
RIL_E_SUCCESS = 0,
RIL_E_RADIO_NOT_AVAILABLE = 1, /* If radio did not start or is resetting */
RIL_E_GENERIC_FAILURE = 2,
RIL_E_PASSWORD_INCORRECT = 3, /* for PIN/PIN2 methods only! */
RIL_E_SIM_PIN2 = 4, /* Operation requires SIM PIN2 to be entered */
RIL_E_SIM_PUK2 = 5, /* Operation requires SIM PIN2 to be entered */
RIL_E_REQUEST_NOT_SUPPORTED = 6,
RIL_E_CANCELLED = 7,
RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL = 8, /* data ops are not allowed during voice
call on a Class C GPRS device */
RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 9, /* data ops are not allowed before device
registers in network */
RIL_E_SMS_SEND_FAIL_RETRY = 10, /* fail to send sms and need retry */
RIL_E_SIM_ABSENT = 11, /* fail to set the location where CDMA subscription
shall be retrieved because of SIM or RUIM
card absent */
RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 12, /* fail to find CDMA subscription from specified
location */
RIL_E_MODE_NOT_SUPPORTED = 13, /* HW does not support preferred network type */
RIL_E_FDN_CHECK_FAILURE = 14, /* command failed because recipient is not on FDN list */
RIL_E_ILLEGAL_SIM_OR_ME = 15, /* network selection failed due to
illegal SIM or ME */
RIL_E_MISSING_RESOURCE = 16, /* no logical channel available */
RIL_E_NO_SUCH_ELEMENT = 17, /* application not found on SIM */
RIL_E_DIAL_MODIFIED_TO_USSD = 18, /* DIAL request modified to USSD */
RIL_E_DIAL_MODIFIED_TO_SS = 19, /* DIAL request modified to SS */
RIL_E_DIAL_MODIFIED_TO_DIAL = 20, /* DIAL request modified to DIAL with different
data */
RIL_E_USSD_MODIFIED_TO_DIAL = 21, /* USSD request modified to DIAL */
RIL_E_USSD_MODIFIED_TO_SS = 22, /* USSD request modified to SS */
RIL_E_USSD_MODIFIED_TO_USSD = 23, /* USSD request modified to different USSD
request */
RIL_E_SS_MODIFIED_TO_DIAL = 24, /* SS request modified to DIAL */
RIL_E_SS_MODIFIED_TO_USSD = 25, /* SS request modified to USSD */
RIL_E_SUBSCRIPTION_NOT_SUPPORTED = 26, /* Subscription not supported by RIL */
RIL_E_SS_MODIFIED_TO_SS = 27, /* SS request modified to different SS request */
RIL_E_LCE_NOT_SUPPORTED = 36, /* LCE service not supported(36 in RILConstants.java) */
RIL_E_NO_MEMORY = 37, /* Not sufficient memory to process the request */
RIL_E_INTERNAL_ERR = 38, /* Modem hit unexpected error scenario while handling
this request */
RIL_E_SYSTEM_ERR = 39, /* Hit platform or system error */
RIL_E_MODEM_ERR = 40, /* Vendor RIL got unexpected or incorrect response
from modem for this request */
RIL_E_INVALID_STATE = 41, /* Unexpected request for the current state */
RIL_E_NO_RESOURCES = 42, /* Not sufficient resource to process the request */
RIL_E_SIM_ERR = 43, /* Received error from SIM card */
RIL_E_INVALID_ARGUMENTS = 44, /* Received invalid arguments in request */
RIL_E_INVALID_SIM_STATE = 45, /* Can not process the request in current SIM state */
RIL_E_INVALID_MODEM_STATE = 46, /* Can not process the request in current Modem state */
RIL_E_INVALID_CALL_ID = 47, /* Received invalid call id in request */
RIL_E_NO_SMS_TO_ACK = 48, /* ACK received when there is no SMS to ack */
RIL_E_NETWORK_ERR = 49, /* Received error from network */
RIL_E_REQUEST_RATE_LIMITED = 50, /* Operation denied due to overly-frequent requests */
RIL_E_SIM_BUSY = 51, /* SIM is busy */
RIL_E_SIM_FULL = 52, /* The target EF is full */
RIL_E_NETWORK_REJECT = 53, /* Request is rejected by network */
RIL_E_OPERATION_NOT_ALLOWED = 54, /* Not allowed the request now */
RIL_E_EMPTY_RECORD = 55, /* The request record is empty */
RIL_E_INVALID_SMS_FORMAT = 56, /* Invalid sms format */
RIL_E_ENCODING_ERR = 57, /* Message not encoded properly */
RIL_E_INVALID_SMSC_ADDRESS = 58, /* SMSC address specified is invalid */
RIL_E_NO_SUCH_ENTRY = 59, /* No such entry present to perform the request */
RIL_E_NETWORK_NOT_READY = 60, /* Network is not ready to perform the request */
RIL_E_NOT_PROVISIONED = 61, /* Device doesnot have this value provisioned */
RIL_E_NO_SUBSCRIPTION = 62, /* Device doesnot have subscription */
RIL_E_NO_NETWORK_FOUND = 63, /* Network cannot be found */
RIL_E_DEVICE_IN_USE = 64, /* Operation cannot be performed because the device
is currently in use */
RIL_E_ABORTED = 65, /* Operation aborted */
RIL_E_INVALID_RESPONSE = 66, /* Invalid response sent by vendor code */
// OEM specific error codes. To be used by OEM when they don't want to reveal
// specific error codes which would be replaced by Generic failure.
RIL_E_OEM_ERROR_1 = 501,
RIL_E_OEM_ERROR_2 = 502,
RIL_E_OEM_ERROR_3 = 503,
RIL_E_OEM_ERROR_4 = 504,
RIL_E_OEM_ERROR_5 = 505,
RIL_E_OEM_ERROR_6 = 506,
RIL_E_OEM_ERROR_7 = 507,
RIL_E_OEM_ERROR_8 = 508,
RIL_E_OEM_ERROR_9 = 509,
RIL_E_OEM_ERROR_10 = 510,
RIL_E_OEM_ERROR_11 = 511,
RIL_E_OEM_ERROR_12 = 512,
RIL_E_OEM_ERROR_13 = 513,
RIL_E_OEM_ERROR_14 = 514,
RIL_E_OEM_ERROR_15 = 515,
RIL_E_OEM_ERROR_16 = 516,
RIL_E_OEM_ERROR_17 = 517,
RIL_E_OEM_ERROR_18 = 518,
RIL_E_OEM_ERROR_19 = 519,
RIL_E_OEM_ERROR_20 = 520,
RIL_E_OEM_ERROR_21 = 521,
RIL_E_OEM_ERROR_22 = 522,
RIL_E_OEM_ERROR_23 = 523,
RIL_E_OEM_ERROR_24 = 524,
RIL_E_OEM_ERROR_25 = 525
} RIL_Errno;
typedef enum {
RIL_CALL_ACTIVE = 0,
RIL_CALL_HOLDING = 1,
RIL_CALL_DIALING = 2, /* MO call only */
RIL_CALL_ALERTING = 3, /* MO call only */
RIL_CALL_INCOMING = 4, /* MT call only */
RIL_CALL_WAITING = 5 /* MT call only */
} RIL_CallState;
typedef enum {
RADIO_STATE_OFF = 0, /* Radio explictly powered off (eg CFUN=0) */
RADIO_STATE_UNAVAILABLE = 1, /* Radio unavailable (eg, resetting or not booted) */
RADIO_STATE_ON = 10 /* Radio is on */
} RIL_RadioState;
typedef enum {
RADIO_TECH_UNKNOWN = 0,
RADIO_TECH_GPRS = 1,
RADIO_TECH_EDGE = 2,
RADIO_TECH_UMTS = 3,
RADIO_TECH_IS95A = 4,
RADIO_TECH_IS95B = 5,
RADIO_TECH_1xRTT = 6,
RADIO_TECH_EVDO_0 = 7,
RADIO_TECH_EVDO_A = 8,
RADIO_TECH_HSDPA = 9,
RADIO_TECH_HSUPA = 10,
RADIO_TECH_HSPA = 11,
RADIO_TECH_EVDO_B = 12,
RADIO_TECH_EHRPD = 13,
RADIO_TECH_LTE = 14,
RADIO_TECH_HSPAP = 15, // HSPA+
RADIO_TECH_GSM = 16, // Only supports voice
RADIO_TECH_TD_SCDMA = 17,
RADIO_TECH_IWLAN = 18,
RADIO_TECH_LTE_CA = 19
} RIL_RadioTechnology;
typedef enum {
RAF_UNKNOWN = (1 << RADIO_TECH_UNKNOWN),
RAF_GPRS = (1 << RADIO_TECH_GPRS),
RAF_EDGE = (1 << RADIO_TECH_EDGE),
RAF_UMTS = (1 << RADIO_TECH_UMTS),
RAF_IS95A = (1 << RADIO_TECH_IS95A),
RAF_IS95B = (1 << RADIO_TECH_IS95B),
RAF_1xRTT = (1 << RADIO_TECH_1xRTT),
RAF_EVDO_0 = (1 << RADIO_TECH_EVDO_0),
RAF_EVDO_A = (1 << RADIO_TECH_EVDO_A),
RAF_HSDPA = (1 << RADIO_TECH_HSDPA),
RAF_HSUPA = (1 << RADIO_TECH_HSUPA),
RAF_HSPA = (1 << RADIO_TECH_HSPA),
RAF_EVDO_B = (1 << RADIO_TECH_EVDO_B),
RAF_EHRPD = (1 << RADIO_TECH_EHRPD),
RAF_LTE = (1 << RADIO_TECH_LTE),
RAF_HSPAP = (1 << RADIO_TECH_HSPAP),
RAF_GSM = (1 << RADIO_TECH_GSM),
RAF_TD_SCDMA = (1 << RADIO_TECH_TD_SCDMA),
RAF_LTE_CA = (1 << RADIO_TECH_LTE_CA)
} RIL_RadioAccessFamily;
typedef enum {
BAND_MODE_UNSPECIFIED = 0, //"unspecified" (selected by baseband automatically)
BAND_MODE_EURO = 1, //"EURO band" (GSM-900 / DCS-1800 / WCDMA-IMT-2000)
BAND_MODE_USA = 2, //"US band" (GSM-850 / PCS-1900 / WCDMA-850 / WCDMA-PCS-1900)
BAND_MODE_JPN = 3, //"JPN band" (WCDMA-800 / WCDMA-IMT-2000)
BAND_MODE_AUS = 4, //"AUS band" (GSM-900 / DCS-1800 / WCDMA-850 / WCDMA-IMT-2000)
BAND_MODE_AUS_2 = 5, //"AUS band 2" (GSM-900 / DCS-1800 / WCDMA-850)
BAND_MODE_CELL_800 = 6, //"Cellular" (800-MHz Band)
BAND_MODE_PCS = 7, //"PCS" (1900-MHz Band)
BAND_MODE_JTACS = 8, //"Band Class 3" (JTACS Band)
BAND_MODE_KOREA_PCS = 9, //"Band Class 4" (Korean PCS Band)
BAND_MODE_5_450M = 10, //"Band Class 5" (450-MHz Band)
BAND_MODE_IMT2000 = 11, //"Band Class 6" (2-GMHz IMT2000 Band)
BAND_MODE_7_700M_2 = 12, //"Band Class 7" (Upper 700-MHz Band)
BAND_MODE_8_1800M = 13, //"Band Class 8" (1800-MHz Band)
BAND_MODE_9_900M = 14, //"Band Class 9" (900-MHz Band)
BAND_MODE_10_800M_2 = 15, //"Band Class 10" (Secondary 800-MHz Band)
BAND_MODE_EURO_PAMR_400M = 16, //"Band Class 11" (400-MHz European PAMR Band)
BAND_MODE_AWS = 17, //"Band Class 15" (AWS Band)
BAND_MODE_USA_2500M = 18 //"Band Class 16" (US 2.5-GHz Band)
} RIL_RadioBandMode;
typedef enum {
RC_PHASE_CONFIGURED = 0, // LM is configured is initial value and value after FINISH completes
RC_PHASE_START = 1, // START is sent before Apply and indicates that an APPLY will be
// forthcoming with these same parameters
RC_PHASE_APPLY = 2, // APPLY is sent after all LM's receive START and returned
// RIL_RadioCapability.status = 0, if any START's fail no
// APPLY will be sent
RC_PHASE_UNSOL_RSP = 3, // UNSOL_RSP is sent with RIL_UNSOL_RADIO_CAPABILITY
RC_PHASE_FINISH = 4 // FINISH is sent after all commands have completed. If an error
// occurs in any previous command the RIL_RadioAccessesFamily and
// logicalModemUuid fields will be the prior configuration thus
// restoring the configuration to the previous value. An error
// returned by this command will generally be ignored or may
// cause that logical modem to be removed from service.
} RadioCapabilityPhase;
typedef enum {
RC_STATUS_NONE = 0, // This parameter has no meaning with RC_PHASE_START,
// RC_PHASE_APPLY
RC_STATUS_SUCCESS = 1, // Tell modem the action transaction of set radio
// capability was success with RC_PHASE_FINISH
RC_STATUS_FAIL = 2, // Tell modem the action transaction of set radio
// capability is fail with RC_PHASE_FINISH.
} RadioCapabilityStatus;
#define RIL_RADIO_CAPABILITY_VERSION 1
typedef struct {
int version; // Version of structure, RIL_RADIO_CAPABILITY_VERSION
int session; // Unique session value defined by framework returned in all "responses/unsol"
int phase; // CONFIGURED, START, APPLY, FINISH
int rat; // RIL_RadioAccessFamily for the radio
char logicalModemUuid[MAX_UUID_LENGTH]; // A UUID typically "com.xxxx.lmX where X is the logical modem.
int status; // Return status and an input parameter for RC_PHASE_FINISH
} RIL_RadioCapability;
// Do we want to split Data from Voice and the use
// RIL_RadioTechnology for get/setPreferredVoice/Data ?
typedef enum {
PREF_NET_TYPE_GSM_WCDMA = 0, /* GSM/WCDMA (WCDMA preferred) */
PREF_NET_TYPE_GSM_ONLY = 1, /* GSM only */
PREF_NET_TYPE_WCDMA = 2, /* WCDMA */
PREF_NET_TYPE_GSM_WCDMA_AUTO = 3, /* GSM/WCDMA (auto mode, according to PRL) */
PREF_NET_TYPE_CDMA_EVDO_AUTO = 4, /* CDMA and EvDo (auto mode, according to PRL) */
PREF_NET_TYPE_CDMA_ONLY = 5, /* CDMA only */
PREF_NET_TYPE_EVDO_ONLY = 6, /* EvDo only */
PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO = 7, /* GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL) */
PREF_NET_TYPE_LTE_CDMA_EVDO = 8, /* LTE, CDMA and EvDo */
PREF_NET_TYPE_LTE_GSM_WCDMA = 9, /* LTE, GSM/WCDMA */
PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA = 10, /* LTE, CDMA, EvDo, GSM/WCDMA */
PREF_NET_TYPE_LTE_ONLY = 11, /* LTE only */
PREF_NET_TYPE_LTE_WCDMA = 12, /* LTE/WCDMA */
PREF_NET_TYPE_TD_SCDMA_ONLY = 13, /* TD-SCDMA only */
PREF_NET_TYPE_TD_SCDMA_WCDMA = 14, /* TD-SCDMA and WCDMA */
PREF_NET_TYPE_TD_SCDMA_LTE = 15, /* TD-SCDMA and LTE */
PREF_NET_TYPE_TD_SCDMA_GSM = 16, /* TD-SCDMA and GSM */
PREF_NET_TYPE_TD_SCDMA_GSM_LTE = 17, /* TD-SCDMA,GSM and LTE */
PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA = 18, /* TD-SCDMA, GSM/WCDMA */
PREF_NET_TYPE_TD_SCDMA_WCDMA_LTE = 19, /* TD-SCDMA, WCDMA and LTE */
PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_LTE = 20, /* TD-SCDMA, GSM/WCDMA and LTE */
PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_CDMA_EVDO_AUTO = 21, /* TD-SCDMA, GSM/WCDMA, CDMA and EvDo */
PREF_NET_TYPE_TD_SCDMA_LTE_CDMA_EVDO_GSM_WCDMA = 22 /* TD-SCDMA, LTE, CDMA, EvDo GSM/WCDMA */
} RIL_PreferredNetworkType;
/* Source for cdma subscription */
typedef enum {
CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM = 0,
CDMA_SUBSCRIPTION_SOURCE_NV = 1
} RIL_CdmaSubscriptionSource;
/* User-to-User signaling Info activation types derived from 3GPP 23.087 v8.0 */
typedef enum {
RIL_UUS_TYPE1_IMPLICIT = 0,
RIL_UUS_TYPE1_REQUIRED = 1,
RIL_UUS_TYPE1_NOT_REQUIRED = 2,
RIL_UUS_TYPE2_REQUIRED = 3,
RIL_UUS_TYPE2_NOT_REQUIRED = 4,
RIL_UUS_TYPE3_REQUIRED = 5,
RIL_UUS_TYPE3_NOT_REQUIRED = 6
} RIL_UUS_Type;
/* User-to-User Signaling Information data coding schemes. Possible values for
* Octet 3 (Protocol Discriminator field) in the UUIE. The values have been
* specified in section 10.5.4.25 of 3GPP TS 24.008 */
typedef enum {
RIL_UUS_DCS_USP = 0, /* User specified protocol */
RIL_UUS_DCS_OSIHLP = 1, /* OSI higher layer protocol */
RIL_UUS_DCS_X244 = 2, /* X.244 */
RIL_UUS_DCS_RMCF = 3, /* Reserved for system mangement
convergence function */
RIL_UUS_DCS_IA5c = 4 /* IA5 characters */
} RIL_UUS_DCS;
/* User-to-User Signaling Information defined in 3GPP 23.087 v8.0
* This data is passed in RIL_ExtensionRecord and rec contains this
* structure when type is RIL_UUS_INFO_EXT_REC */
typedef struct {
RIL_UUS_Type uusType; /* UUS Type */
RIL_UUS_DCS uusDcs; /* UUS Data Coding Scheme */
int uusLength; /* Length of UUS Data */
char * uusData; /* UUS Data */
} RIL_UUS_Info;
/* CDMA Signal Information Record as defined in C.S0005 section 3.7.5.5 */
typedef struct {
char isPresent; /* non-zero if signal information record is present */
char signalType; /* as defined 3.7.5.5-1 */
char alertPitch; /* as defined 3.7.5.5-2 */
char signal; /* as defined 3.7.5.5-3, 3.7.5.5-4 or 3.7.5.5-5 */
} RIL_CDMA_SignalInfoRecord;
typedef struct {
RIL_CallState state;
int index; /* Connection Index for use with, eg, AT+CHLD */
int toa; /* type of address, eg 145 = intl */
char isMpty; /* nonzero if is mpty call */
char isMT; /* nonzero if call is mobile terminated */
char als; /* ALS line indicator if available
(0 = line 1) */
char isVoice; /* nonzero if this is is a voice call */
char isVoicePrivacy; /* nonzero if CDMA voice privacy mode is active */
char * number; /* Remote party number */
int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone */
char * name; /* Remote party name */
int namePresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone */
RIL_UUS_Info * uusInfo; /* NULL or Pointer to User-User Signaling Information */
} RIL_Call;
/* Deprecated, use RIL_Data_Call_Response_v6 */
typedef struct {
int cid; /* Context ID, uniquely identifies this call */
int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */
char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1.
For example, "IP", "IPV6", "IPV4V6", or "PPP". */
char * apn; /* ignored */
char * address; /* An address, e.g., "192.0.1.3" or "2001:db8::1". */
} RIL_Data_Call_Response_v4;
/*
* Returned by RIL_REQUEST_SETUP_DATA_CALL, RIL_REQUEST_DATA_CALL_LIST
* and RIL_UNSOL_DATA_CALL_LIST_CHANGED, on error status != 0.
*/
typedef struct {
int status; /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */
int suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry
back-off timer value RIL wants to override the one
pre-configured in FW.
The unit is miliseconds.
The value < 0 means no value is suggested.
The value 0 means retry should be done ASAP.
The value of INT_MAX(0x7fffffff) means no retry. */
int cid; /* Context ID, uniquely identifies this call */
int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */
char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1.
For example, "IP", "IPV6", "IPV4V6", or "PPP". If status is
PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported
such as "IP" or "IPV6" */
char * ifname; /* The network interface name */
char * addresses; /* A space-delimited list of addresses with optional "/" prefix length,
e.g., "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64".
May not be empty, typically 1 IPv4 or 1 IPv6 or
one of each. If the prefix length is absent the addresses
are assumed to be point to point with IPv4 having a prefix
length of 32 and IPv6 128. */
char * dnses; /* A space-delimited list of DNS server addresses,
e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1".
May be empty. */
char * gateways; /* A space-delimited list of default gateway addresses,
e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1".
May be empty in which case the addresses represent point
to point connections. */
} RIL_Data_Call_Response_v6;
typedef struct {
int status; /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */
int suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry
back-off timer value RIL wants to override the one
pre-configured in FW.
The unit is miliseconds.
The value < 0 means no value is suggested.
The value 0 means retry should be done ASAP.
The value of INT_MAX(0x7fffffff) means no retry. */
int cid; /* Context ID, uniquely identifies this call */
int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */
char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1.
For example, "IP", "IPV6", "IPV4V6", or "PPP". If status is
PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported
such as "IP" or "IPV6" */
char * ifname; /* The network interface name */
char * addresses; /* A space-delimited list of addresses with optional "/" prefix length,
e.g., "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64".
May not be empty, typically 1 IPv4 or 1 IPv6 or
one of each. If the prefix length is absent the addresses
are assumed to be point to point with IPv4 having a prefix
length of 32 and IPv6 128. */
char * dnses; /* A space-delimited list of DNS server addresses,
e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1".
May be empty. */
char * gateways; /* A space-delimited list of default gateway addresses,
e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1".
May be empty in which case the addresses represent point
to point connections. */
char * pcscf; /* the Proxy Call State Control Function address
via PCO(Protocol Configuration Option) for IMS client. */
} RIL_Data_Call_Response_v9;
typedef struct {
int status; /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */
int suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry
back-off timer value RIL wants to override the one
pre-configured in FW.
The unit is miliseconds.
The value < 0 means no value is suggested.
The value 0 means retry should be done ASAP.
The value of INT_MAX(0x7fffffff) means no retry. */
int cid; /* Context ID, uniquely identifies this call */
int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */
char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1.
For example, "IP", "IPV6", "IPV4V6", or "PPP". If status is
PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported
such as "IP" or "IPV6" */
char * ifname; /* The network interface name */
char * addresses; /* A space-delimited list of addresses with optional "/" prefix length,
e.g., "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64".
May not be empty, typically 1 IPv4 or 1 IPv6 or
one of each. If the prefix length is absent the addresses
are assumed to be point to point with IPv4 having a prefix
length of 32 and IPv6 128. */
char * dnses; /* A space-delimited list of DNS server addresses,
e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1".
May be empty. */
char * gateways; /* A space-delimited list of default gateway addresses,
e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1".
May be empty in which case the addresses represent point
to point connections. */
char * pcscf; /* the Proxy Call State Control Function address
via PCO(Protocol Configuration Option) for IMS client. */
int mtu; /* MTU received from network
Value <= 0 means network has either not sent a value or
sent an invalid value */
} RIL_Data_Call_Response_v11;
typedef enum {
RADIO_TECH_3GPP = 1, /* 3GPP Technologies - GSM, WCDMA */
RADIO_TECH_3GPP2 = 2 /* 3GPP2 Technologies - CDMA */
} RIL_RadioTechnologyFamily;
typedef struct {
RIL_RadioTechnologyFamily tech;
unsigned char retry; /* 0 == not retry, nonzero == retry */
int messageRef; /* Valid field if retry is set to nonzero.
Contains messageRef from RIL_SMS_Response
corresponding to failed MO SMS.
*/
union {
/* Valid field if tech is RADIO_TECH_3GPP2. See RIL_REQUEST_CDMA_SEND_SMS */
RIL_CDMA_SMS_Message* cdmaMessage;
/* Valid field if tech is RADIO_TECH_3GPP. See RIL_REQUEST_SEND_SMS */
char** gsmMessage; /* This is an array of pointers where pointers
are contiguous but elements pointed by those pointers
are not contiguous
*/
} message;
} RIL_IMS_SMS_Message;
typedef struct {
int messageRef; /* TP-Message-Reference for GSM,
and BearerData MessageId for CDMA
(See 3GPP2 C.S0015-B, v2.0, table 4.5-1). */
char *ackPDU; /* or NULL if n/a */
int errorCode; /* See 3GPP 27.005, 3.2.5 for GSM/UMTS,
3GPP2 N.S0005 (IS-41C) Table 171 for CDMA,
-1 if unknown or not applicable*/
} RIL_SMS_Response;
/** Used by RIL_REQUEST_WRITE_SMS_TO_SIM */
typedef struct {
int status; /* Status of message. See TS 27.005 3.1, "<stat>": */
/* 0 = "REC UNREAD" */
/* 1 = "REC READ" */
/* 2 = "STO UNSENT" */
/* 3 = "STO SENT" */
char * pdu; /* PDU of message to write, as an ASCII hex string less the SMSC address,
the TP-layer length is "strlen(pdu)/2". */
char * smsc; /* SMSC address in GSM BCD format prefixed by a length byte
(as expected by TS 27.005) or NULL for default SMSC */
} RIL_SMS_WriteArgs;
/** Used by RIL_REQUEST_DIAL */
typedef struct {
char * address;
int clir;
/* (same as 'n' paremeter in TS 27.007 7.7 "+CLIR"
* clir == 0 on "use subscription default value"
* clir == 1 on "CLIR invocation" (restrict CLI presentation)
* clir == 2 on "CLIR suppression" (allow CLI presentation)
*/
RIL_UUS_Info * uusInfo; /* NULL or Pointer to User-User Signaling Information */
} RIL_Dial;
typedef struct {
int command; /* one of the commands listed for TS 27.007 +CRSM*/
int fileid; /* EF id */
char *path; /* "pathid" from TS 27.007 +CRSM command.
Path is in hex asciii format eg "7f205f70"
Path must always be provided.
*/
int p1;
int p2;
int p3;
char *data; /* May be NULL*/
char *pin2; /* May be NULL*/
} RIL_SIM_IO_v5;
typedef struct {
int command; /* one of the commands listed for TS 27.007 +CRSM*/
int fileid; /* EF id */
char *path; /* "pathid" from TS 27.007 +CRSM command.
Path is in hex asciii format eg "7f205f70"
Path must always be provided.
*/
int p1;
int p2;
int p3;
char *data; /* May be NULL*/
char *pin2; /* May be NULL*/
char *aidPtr; /* AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. */
} RIL_SIM_IO_v6;
/* Used by RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL and
* RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC. */
typedef struct {
int sessionid; /* "sessionid" from TS 27.007 +CGLA command. Should be
ignored for +CSIM command. */
/* Following fields are used to derive the APDU ("command" and "length"
values in TS 27.007 +CSIM and +CGLA commands). */
int cla;
int instruction;
int p1;
int p2;
int p3; /* A negative P3 implies a 4 byte APDU. */
char *data; /* May be NULL. In hex string format. */
} RIL_SIM_APDU;
typedef struct {
int sw1;
int sw2;
char *simResponse; /* In hex string format ([a-fA-F0-9]*), except for SIM_AUTHENTICATION
response for which it is in Base64 format, see 3GPP TS 31.102 7.1.2 */
} RIL_SIM_IO_Response;
/* See also com.android.internal.telephony.gsm.CallForwardInfo */
typedef struct {
int status; /*
* For RIL_REQUEST_QUERY_CALL_FORWARD_STATUS
* status 1 = active, 0 = not active
*
* For RIL_REQUEST_SET_CALL_FORWARD:
* status is:
* 0 = disable
* 1 = enable
* 2 = interrogate
* 3 = registeration
* 4 = erasure
*/
int reason; /* from TS 27.007 7.11 "reason" */
int serviceClass;/* From 27.007 +CCFC/+CLCK "class"
See table for Android mapping from
MMI service code
0 means user doesn't input class */
int toa; /* "type" from TS 27.007 7.11 */
char * number; /* "number" from TS 27.007 7.11. May be NULL */
int timeSeconds; /* for CF no reply only */
}RIL_CallForwardInfo;
typedef struct {
char * cid; /* Combination of LAC and Cell Id in 32 bits in GSM.
* Upper 16 bits is LAC and lower 16 bits
* is CID (as described in TS 27.005)
* Primary Scrambling Code (as described in TS 25.331)
* in 9 bits in UMTS
* Valid values are hexadecimal 0x0000 - 0xffffffff.
*/
int rssi; /* Received RSSI in GSM,
* Level index of CPICH Received Signal Code Power in UMTS
*/
} RIL_NeighboringCell;
typedef struct {
char lce_status; /* LCE service status:
* -1 = not supported;
* 0 = stopped;
* 1 = active.
*/
unsigned int actual_interval_ms; /* actual LCE reporting interval,
* meaningful only if LCEStatus = 1.
*/
} RIL_LceStatusInfo;
typedef struct {
unsigned int last_hop_capacity_kbps; /* last-hop cellular capacity: kilobits/second. */
unsigned char confidence_level; /* capacity estimate confidence: 0-100 */
unsigned char lce_suspended; /* LCE report going to be suspended? (e.g., radio
* moves to inactive state or network type change)
* 1 = suspended;
* 0 = not suspended.
*/
} RIL_LceDataInfo;
typedef enum {
RIL_MATCH_ALL = 0, /* Apply to all carriers with the same mcc/mnc */
RIL_MATCH_SPN = 1, /* Use SPN and mcc/mnc to identify the carrier */
RIL_MATCH_IMSI_PREFIX = 2, /* Use IMSI prefix and mcc/mnc to identify the carrier */
RIL_MATCH_GID1 = 3, /* Use GID1 and mcc/mnc to identify the carrier */
RIL_MATCH_GID2 = 4, /* Use GID2 and mcc/mnc to identify the carrier */
} RIL_CarrierMatchType;
typedef struct {
const char * mcc;
const char * mnc;
RIL_CarrierMatchType match_type; /* Specify match type for the carrier.
* If it’s RIL_MATCH_ALL, match_data is null;
* otherwise, match_data is the value for the match type.
*/
const char * match_data;
} RIL_Carrier;
typedef struct {
int32_t len_allowed_carriers; /* length of array allowed_carriers */
int32_t len_excluded_carriers; /* length of array excluded_carriers */
RIL_Carrier * allowed_carriers; /* list of allowed carriers */
RIL_Carrier * excluded_carriers; /* list of explicitly excluded carriers
* which match allowed_carriers. Eg. allowed_carriers match
* mcc/mnc, excluded_carriers has same mcc/mnc and gid1
* is ABCD. It means except the carrier whose gid1 is ABCD,
* all carriers with the same mcc/mnc are allowed.
*/
} RIL_CarrierRestrictions;
typedef struct {
char * mcc; /* MCC of the Carrier. */
char * mnc ; /* MNC of the Carrier. */
uint8_t * carrierKey; /* Public Key from the Carrier used to encrypt the
* IMSI/IMPI.
*/
int32_t carrierKeyLength; /* Length of the Public Key. */
char * keyIdentifier; /* The keyIdentifier Attribute value pair that helps
* a server locate the private key to decrypt the
* permanent identity.
*/
int64_t expirationTime; /* Date-Time (in UTC) when the key will expire. */
} RIL_CarrierInfoForImsiEncryption;
/* See RIL_REQUEST_LAST_CALL_FAIL_CAUSE */
typedef enum {
CALL_FAIL_UNOBTAINABLE_NUMBER = 1,
CALL_FAIL_NO_ROUTE_TO_DESTINATION = 3,
CALL_FAIL_CHANNEL_UNACCEPTABLE = 6,
CALL_FAIL_OPERATOR_DETERMINED_BARRING = 8,
CALL_FAIL_NORMAL = 16,
CALL_FAIL_BUSY = 17,
CALL_FAIL_NO_USER_RESPONDING = 18,
CALL_FAIL_NO_ANSWER_FROM_USER = 19,
CALL_FAIL_CALL_REJECTED = 21,
CALL_FAIL_NUMBER_CHANGED = 22,
CALL_FAIL_PREEMPTION = 25,
CALL_FAIL_DESTINATION_OUT_OF_ORDER = 27,
CALL_FAIL_INVALID_NUMBER_FORMAT = 28,
CALL_FAIL_FACILITY_REJECTED = 29,
CALL_FAIL_RESP_TO_STATUS_ENQUIRY = 30,
CALL_FAIL_NORMAL_UNSPECIFIED = 31,
CALL_FAIL_CONGESTION = 34,
CALL_FAIL_NETWORK_OUT_OF_ORDER = 38,
CALL_FAIL_TEMPORARY_FAILURE = 41,
CALL_FAIL_SWITCHING_EQUIPMENT_CONGESTION = 42,
CALL_FAIL_ACCESS_INFORMATION_DISCARDED = 43,
CALL_FAIL_REQUESTED_CIRCUIT_OR_CHANNEL_NOT_AVAILABLE = 44,
CALL_FAIL_RESOURCES_UNAVAILABLE_OR_UNSPECIFIED = 47,
CALL_FAIL_QOS_UNAVAILABLE = 49,
CALL_FAIL_REQUESTED_FACILITY_NOT_SUBSCRIBED = 50,
CALL_FAIL_INCOMING_CALLS_BARRED_WITHIN_CUG = 55,
CALL_FAIL_BEARER_CAPABILITY_NOT_AUTHORIZED = 57,
CALL_FAIL_BEARER_CAPABILITY_UNAVAILABLE = 58,
CALL_FAIL_SERVICE_OPTION_NOT_AVAILABLE = 63,
CALL_FAIL_BEARER_SERVICE_NOT_IMPLEMENTED = 65,
CALL_FAIL_ACM_LIMIT_EXCEEDED = 68,
CALL_FAIL_REQUESTED_FACILITY_NOT_IMPLEMENTED = 69,
CALL_FAIL_ONLY_DIGITAL_INFORMATION_BEARER_AVAILABLE = 70,
CALL_FAIL_SERVICE_OR_OPTION_NOT_IMPLEMENTED = 79,
CALL_FAIL_INVALID_TRANSACTION_IDENTIFIER = 81,
CALL_FAIL_USER_NOT_MEMBER_OF_CUG = 87,
CALL_FAIL_INCOMPATIBLE_DESTINATION = 88,
CALL_FAIL_INVALID_TRANSIT_NW_SELECTION = 91,
CALL_FAIL_SEMANTICALLY_INCORRECT_MESSAGE = 95,
CALL_FAIL_INVALID_MANDATORY_INFORMATION = 96,
CALL_FAIL_MESSAGE_TYPE_NON_IMPLEMENTED = 97,
CALL_FAIL_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 98,
CALL_FAIL_INFORMATION_ELEMENT_NON_EXISTENT = 99,
CALL_FAIL_CONDITIONAL_IE_ERROR = 100,
CALL_FAIL_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 101,
CALL_FAIL_RECOVERY_ON_TIMER_EXPIRED = 102,
CALL_FAIL_PROTOCOL_ERROR_UNSPECIFIED = 111,
CALL_FAIL_INTERWORKING_UNSPECIFIED = 127,
CALL_FAIL_CALL_BARRED = 240,
CALL_FAIL_FDN_BLOCKED = 241,
CALL_FAIL_IMSI_UNKNOWN_IN_VLR = 242,
CALL_FAIL_IMEI_NOT_ACCEPTED = 243,
CALL_FAIL_DIAL_MODIFIED_TO_USSD = 244, /* STK Call Control */
CALL_FAIL_DIAL_MODIFIED_TO_SS = 245,
CALL_FAIL_DIAL_MODIFIED_TO_DIAL = 246,
CALL_FAIL_RADIO_OFF = 247, /* Radio is OFF */
CALL_FAIL_OUT_OF_SERVICE = 248, /* No cellular coverage */
CALL_FAIL_NO_VALID_SIM = 249, /* No valid SIM is present */
CALL_FAIL_RADIO_INTERNAL_ERROR = 250, /* Internal error at Modem */
CALL_FAIL_NETWORK_RESP_TIMEOUT = 251, /* No response from network */
CALL_FAIL_NETWORK_REJECT = 252, /* Explicit network reject */
CALL_FAIL_RADIO_ACCESS_FAILURE = 253, /* RRC connection failure. Eg.RACH */
CALL_FAIL_RADIO_LINK_FAILURE = 254, /* Radio Link Failure */
CALL_FAIL_RADIO_LINK_LOST = 255, /* Radio link lost due to poor coverage */
CALL_FAIL_RADIO_UPLINK_FAILURE = 256, /* Radio uplink failure */
CALL_FAIL_RADIO_SETUP_FAILURE = 257, /* RRC connection setup failure */
CALL_FAIL_RADIO_RELEASE_NORMAL = 258, /* RRC connection release, normal */
CALL_FAIL_RADIO_RELEASE_ABNORMAL = 259, /* RRC connection release, abnormal */
CALL_FAIL_ACCESS_CLASS_BLOCKED = 260, /* Access class barring */
CALL_FAIL_NETWORK_DETACH = 261, /* Explicit network detach */
CALL_FAIL_CDMA_LOCKED_UNTIL_POWER_CYCLE = 1000,
CALL_FAIL_CDMA_DROP = 1001,
CALL_FAIL_CDMA_INTERCEPT = 1002,
CALL_FAIL_CDMA_REORDER = 1003,
CALL_FAIL_CDMA_SO_REJECT = 1004,
CALL_FAIL_CDMA_RETRY_ORDER = 1005,
CALL_FAIL_CDMA_ACCESS_FAILURE = 1006,
CALL_FAIL_CDMA_PREEMPTED = 1007,
CALL_FAIL_CDMA_NOT_EMERGENCY = 1008, /* For non-emergency number dialed
during emergency callback mode */
CALL_FAIL_CDMA_ACCESS_BLOCKED = 1009, /* CDMA network access probes blocked */
/* OEM specific error codes. Used to distinguish error from
* CALL_FAIL_ERROR_UNSPECIFIED and help assist debugging */
CALL_FAIL_OEM_CAUSE_1 = 0xf001,
CALL_FAIL_OEM_CAUSE_2 = 0xf002,
CALL_FAIL_OEM_CAUSE_3 = 0xf003,
CALL_FAIL_OEM_CAUSE_4 = 0xf004,
CALL_FAIL_OEM_CAUSE_5 = 0xf005,
CALL_FAIL_OEM_CAUSE_6 = 0xf006,
CALL_FAIL_OEM_CAUSE_7 = 0xf007,
CALL_FAIL_OEM_CAUSE_8 = 0xf008,
CALL_FAIL_OEM_CAUSE_9 = 0xf009,
CALL_FAIL_OEM_CAUSE_10 = 0xf00a,
CALL_FAIL_OEM_CAUSE_11 = 0xf00b,
CALL_FAIL_OEM_CAUSE_12 = 0xf00c,
CALL_FAIL_OEM_CAUSE_13 = 0xf00d,
CALL_FAIL_OEM_CAUSE_14 = 0xf00e,
CALL_FAIL_OEM_CAUSE_15 = 0xf00f,
CALL_FAIL_ERROR_UNSPECIFIED = 0xffff /* This error will be deprecated soon,
vendor code should make sure to map error
code to specific error */
} RIL_LastCallFailCause;
typedef struct {
RIL_LastCallFailCause cause_code;
char * vendor_cause;
} RIL_LastCallFailCauseInfo;
/* See RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE */
typedef enum {
PDP_FAIL_NONE = 0, /* No error, connection ok */
/* an integer cause code defined in TS 24.008
section 6.1.3.1.3 or TS 24.301 Release 8+ Annex B.
If the implementation does not have access to the exact cause codes,
then it should return one of the following values,
as the UI layer needs to distinguish these
cases for error notification and potential retries. */
PDP_FAIL_OPERATOR_BARRED = 0x08, /* no retry */
PDP_FAIL_NAS_SIGNALLING = 0x0E,
PDP_FAIL_LLC_SNDCP = 0x19,
PDP_FAIL_INSUFFICIENT_RESOURCES = 0x1A,
PDP_FAIL_MISSING_UKNOWN_APN = 0x1B, /* no retry */
PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE = 0x1C, /* no retry */
PDP_FAIL_USER_AUTHENTICATION = 0x1D, /* no retry */
PDP_FAIL_ACTIVATION_REJECT_GGSN = 0x1E, /* no retry */
PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED = 0x1F,
PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 0x20, /* no retry */
PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 0x21, /* no retry */
PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER = 0x22,
PDP_FAIL_NSAPI_IN_USE = 0x23, /* no retry */
PDP_FAIL_REGULAR_DEACTIVATION = 0x24, /* possibly restart radio,
based on framework config */
PDP_FAIL_QOS_NOT_ACCEPTED = 0x25,
PDP_FAIL_NETWORK_FAILURE = 0x26,
PDP_FAIL_UMTS_REACTIVATION_REQ = 0x27,
PDP_FAIL_FEATURE_NOT_SUPP = 0x28,
PDP_FAIL_TFT_SEMANTIC_ERROR = 0x29,
PDP_FAIL_TFT_SYTAX_ERROR = 0x2A,
PDP_FAIL_UNKNOWN_PDP_CONTEXT = 0x2B,
PDP_FAIL_FILTER_SEMANTIC_ERROR = 0x2C,
PDP_FAIL_FILTER_SYTAX_ERROR = 0x2D,
PDP_FAIL_PDP_WITHOUT_ACTIVE_TFT = 0x2E,
PDP_FAIL_ONLY_IPV4_ALLOWED = 0x32, /* no retry */
PDP_FAIL_ONLY_IPV6_ALLOWED = 0x33, /* no retry */
PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED = 0x34,
PDP_FAIL_ESM_INFO_NOT_RECEIVED = 0x35,
PDP_FAIL_PDN_CONN_DOES_NOT_EXIST = 0x36,
PDP_FAIL_MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED = 0x37,
PDP_FAIL_MAX_ACTIVE_PDP_CONTEXT_REACHED = 0x41,
PDP_FAIL_UNSUPPORTED_APN_IN_CURRENT_PLMN = 0x42,
PDP_FAIL_INVALID_TRANSACTION_ID = 0x51,
PDP_FAIL_MESSAGE_INCORRECT_SEMANTIC = 0x5F,
PDP_FAIL_INVALID_MANDATORY_INFO = 0x60,
PDP_FAIL_MESSAGE_TYPE_UNSUPPORTED = 0x61,
PDP_FAIL_MSG_TYPE_NONCOMPATIBLE_STATE = 0x62,
PDP_FAIL_UNKNOWN_INFO_ELEMENT = 0x63,
PDP_FAIL_CONDITIONAL_IE_ERROR = 0x64,
PDP_FAIL_MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE = 0x65,
PDP_FAIL_PROTOCOL_ERRORS = 0x6F, /* no retry */
PDP_FAIL_APN_TYPE_CONFLICT = 0x70,
PDP_FAIL_INVALID_PCSCF_ADDR = 0x71,
PDP_FAIL_INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN = 0x72,
PDP_FAIL_EMM_ACCESS_BARRED = 0x73,
PDP_FAIL_EMERGENCY_IFACE_ONLY = 0x74,
PDP_FAIL_IFACE_MISMATCH = 0x75,
PDP_FAIL_COMPANION_IFACE_IN_USE = 0x76,
PDP_FAIL_IP_ADDRESS_MISMATCH = 0x77,
PDP_FAIL_IFACE_AND_POL_FAMILY_MISMATCH = 0x78,
PDP_FAIL_EMM_ACCESS_BARRED_INFINITE_RETRY = 0x79,
PDP_FAIL_AUTH_FAILURE_ON_EMERGENCY_CALL = 0x7A,
// OEM specific error codes. To be used by OEMs when they don't want to
// reveal error code which would be replaced by PDP_FAIL_ERROR_UNSPECIFIED
PDP_FAIL_OEM_DCFAILCAUSE_1 = 0x1001,
PDP_FAIL_OEM_DCFAILCAUSE_2 = 0x1002,
PDP_FAIL_OEM_DCFAILCAUSE_3 = 0x1003,
PDP_FAIL_OEM_DCFAILCAUSE_4 = 0x1004,
PDP_FAIL_OEM_DCFAILCAUSE_5 = 0x1005,
PDP_FAIL_OEM_DCFAILCAUSE_6 = 0x1006,
PDP_FAIL_OEM_DCFAILCAUSE_7 = 0x1007,
PDP_FAIL_OEM_DCFAILCAUSE_8 = 0x1008,
PDP_FAIL_OEM_DCFAILCAUSE_9 = 0x1009,
PDP_FAIL_OEM_DCFAILCAUSE_10 = 0x100A,
PDP_FAIL_OEM_DCFAILCAUSE_11 = 0x100B,
PDP_FAIL_OEM_DCFAILCAUSE_12 = 0x100C,
PDP_FAIL_OEM_DCFAILCAUSE_13 = 0x100D,
PDP_FAIL_OEM_DCFAILCAUSE_14 = 0x100E,
PDP_FAIL_OEM_DCFAILCAUSE_15 = 0x100F,
/* Not mentioned in the specification */
PDP_FAIL_VOICE_REGISTRATION_FAIL = -1,
PDP_FAIL_DATA_REGISTRATION_FAIL = -2,
/* reasons for data call drop - network/modem disconnect */
PDP_FAIL_SIGNAL_LOST = -3,
PDP_FAIL_PREF_RADIO_TECH_CHANGED = -4,/* preferred technology has changed, should retry
with parameters appropriate for new technology */
PDP_FAIL_RADIO_POWER_OFF = -5, /* data call was disconnected because radio was resetting,
powered off - no retry */
PDP_FAIL_TETHERED_CALL_ACTIVE = -6, /* data call was disconnected by modem because tethered
mode was up on same APN/data profile - no retry until
tethered call is off */
PDP_FAIL_ERROR_UNSPECIFIED = 0xffff, /* retry silently. Will be deprecated soon as
new error codes are added making this unnecessary */
} RIL_DataCallFailCause;
/* See RIL_REQUEST_SETUP_DATA_CALL */
typedef enum {
RIL_DATA_PROFILE_DEFAULT = 0,
RIL_DATA_PROFILE_TETHERED = 1,
RIL_DATA_PROFILE_IMS = 2,
RIL_DATA_PROFILE_FOTA = 3,
RIL_DATA_PROFILE_CBS = 4,
RIL_DATA_PROFILE_OEM_BASE = 1000, /* Start of OEM-specific profiles */
RIL_DATA_PROFILE_INVALID = 0xFFFFFFFF
} RIL_DataProfile;
/* Used by RIL_UNSOL_SUPP_SVC_NOTIFICATION */
typedef struct {
int notificationType; /*
* 0 = MO intermediate result code
* 1 = MT unsolicited result code
*/
int code; /* See 27.007 7.17
"code1" for MO
"code2" for MT. */
int index; /* CUG index. See 27.007 7.17. */
int type; /* "type" from 27.007 7.17 (MT only). */
char * number; /* "number" from 27.007 7.17
(MT only, may be NULL). */
} RIL_SuppSvcNotification;
#define RIL_CARD_MAX_APPS 8
typedef enum {
RIL_CARDSTATE_ABSENT = 0,
RIL_CARDSTATE_PRESENT = 1,
RIL_CARDSTATE_ERROR = 2,
RIL_CARDSTATE_RESTRICTED = 3 /* card is present but not usable due to carrier restrictions.*/
} RIL_CardState;
typedef enum {
RIL_PERSOSUBSTATE_UNKNOWN = 0, /* initial state */
RIL_PERSOSUBSTATE_IN_PROGRESS = 1, /* in between each lock transition */
RIL_PERSOSUBSTATE_READY = 2, /* when either SIM or RUIM Perso is finished
since each app can only have 1 active perso
involved */
RIL_PERSOSUBSTATE_SIM_NETWORK = 3,
RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET = 4,
RIL_PERSOSUBSTATE_SIM_CORPORATE = 5,
RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER = 6,
RIL_PERSOSUBSTATE_SIM_SIM = 7,
RIL_PERSOSUBSTATE_SIM_NETWORK_PUK = 8, /* The corresponding perso lock is blocked */
RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK = 9,
RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK = 10,
RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK = 11,
RIL_PERSOSUBSTATE_SIM_SIM_PUK = 12,
RIL_PERSOSUBSTATE_RUIM_NETWORK1 = 13,
RIL_PERSOSUBSTATE_RUIM_NETWORK2 = 14,
RIL_PERSOSUBSTATE_RUIM_HRPD = 15,
RIL_PERSOSUBSTATE_RUIM_CORPORATE = 16,
RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER = 17,
RIL_PERSOSUBSTATE_RUIM_RUIM = 18,
RIL_PERSOSUBSTATE_RUIM_NETWORK1_PUK = 19, /* The corresponding perso lock is blocked */
RIL_PERSOSUBSTATE_RUIM_NETWORK2_PUK = 20,
RIL_PERSOSUBSTATE_RUIM_HRPD_PUK = 21,
RIL_PERSOSUBSTATE_RUIM_CORPORATE_PUK = 22,
RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23,
RIL_PERSOSUBSTATE_RUIM_RUIM_PUK = 24
} RIL_PersoSubstate;
typedef enum {
RIL_APPSTATE_UNKNOWN = 0,
RIL_APPSTATE_DETECTED = 1,
RIL_APPSTATE_PIN = 2, /* If PIN1 or UPin is required */
RIL_APPSTATE_PUK = 3, /* If PUK1 or Puk for UPin is required */
RIL_APPSTATE_SUBSCRIPTION_PERSO = 4, /* perso_substate should be look at
when app_state is assigned to this value */
RIL_APPSTATE_READY = 5
} RIL_AppState;
typedef enum {
RIL_PINSTATE_UNKNOWN = 0,
RIL_PINSTATE_ENABLED_NOT_VERIFIED = 1,
RIL_PINSTATE_ENABLED_VERIFIED = 2,
RIL_PINSTATE_DISABLED = 3,
RIL_PINSTATE_ENABLED_BLOCKED = 4,
RIL_PINSTATE_ENABLED_PERM_BLOCKED = 5
} RIL_PinState;
typedef enum {
RIL_APPTYPE_UNKNOWN = 0,
RIL_APPTYPE_SIM = 1,
RIL_APPTYPE_USIM = 2,
RIL_APPTYPE_RUIM = 3,
RIL_APPTYPE_CSIM = 4,
RIL_APPTYPE_ISIM = 5
} RIL_AppType;
/*
* Please note that registration state UNKNOWN is
* treated as "out of service" in the Android telephony.
* Registration state REG_DENIED must be returned if Location Update
* Reject (with cause 17 - Network Failure) is received
* repeatedly from the network, to facilitate
* "managed roaming"
*/
typedef enum {
RIL_NOT_REG_AND_NOT_SEARCHING = 0, // Not registered, MT is not currently searching
// a new operator to register
RIL_REG_HOME = 1, // Registered, home network
RIL_NOT_REG_AND_SEARCHING = 2, // Not registered, but MT is currently searching
// a new operator to register
RIL_REG_DENIED = 3, // Registration denied
RIL_UNKNOWN = 4, // Unknown
RIL_REG_ROAMING = 5, // Registered, roaming
RIL_NOT_REG_AND_EMERGENCY_AVAILABLE_AND_NOT_SEARCHING = 10, // Same as
// RIL_NOT_REG_AND_NOT_SEARCHING but indicates that
// emergency calls are enabled.
RIL_NOT_REG_AND_EMERGENCY_AVAILABLE_AND_SEARCHING = 12, // Same as RIL_NOT_REG_AND_SEARCHING
// but indicates that
// emergency calls are enabled.
RIL_REG_DENIED_AND_EMERGENCY_AVAILABLE = 13, // Same as REG_DENIED but indicates that
// emergency calls are enabled.
RIL_UNKNOWN_AND_EMERGENCY_AVAILABLE = 14, // Same as UNKNOWN but indicates that
// emergency calls are enabled.
} RIL_RegState;
typedef struct
{
RIL_AppType app_type;
RIL_AppState app_state;
RIL_PersoSubstate perso_substate; /* applicable only if app_state ==
RIL_APPSTATE_SUBSCRIPTION_PERSO */
char *aid_ptr; /* null terminated string, e.g., from 0xA0, 0x00 -> 0x41,
0x30, 0x30, 0x30 */
char *app_label_ptr; /* null terminated string */
int pin1_replaced; /* applicable to USIM, CSIM & ISIM */
RIL_PinState pin1;
RIL_PinState pin2;
} RIL_AppStatus;
/* Deprecated, use RIL_CardStatus_v6 */
typedef struct
{
RIL_CardState card_state;
RIL_PinState universal_pin_state; /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */
int gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */
int cdma_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */
int num_applications; /* value <= RIL_CARD_MAX_APPS */
RIL_AppStatus applications[RIL_CARD_MAX_APPS];
} RIL_CardStatus_v5;
typedef struct
{
RIL_CardState card_state;
RIL_PinState universal_pin_state; /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */
int gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */
int cdma_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */
int ims_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */
int num_applications; /* value <= RIL_CARD_MAX_APPS */
RIL_AppStatus applications[RIL_CARD_MAX_APPS];
} RIL_CardStatus_v6;
/** The result of a SIM refresh, returned in data[0] of RIL_UNSOL_SIM_REFRESH
* or as part of RIL_SimRefreshResponse_v7
*/
typedef enum {
/* A file on SIM has been updated. data[1] contains the EFID. */
SIM_FILE_UPDATE = 0,
/* SIM initialized. All files should be re-read. */
SIM_INIT = 1,
/* SIM reset. SIM power required, SIM may be locked and all files should be re-read. */
SIM_RESET = 2
} RIL_SimRefreshResult;
typedef struct {
RIL_SimRefreshResult result;
int ef_id; /* is the EFID of the updated file if the result is */
/* SIM_FILE_UPDATE or 0 for any other result. */
char * aid; /* is AID(application ID) of the card application */
/* See ETSI 102.221 8.1 and 101.220 4 */
/* For SIM_FILE_UPDATE result it can be set to AID of */
/* application in which updated EF resides or it can be */
/* NULL if EF is outside of an application. */
/* For SIM_INIT result this field is set to AID of */
/* application that caused REFRESH */
/* For SIM_RESET result it is NULL. */
} RIL_SimRefreshResponse_v7;
/* Deprecated, use RIL_CDMA_CallWaiting_v6 */
typedef struct {
char * number; /* Remote party number */
int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown */
char * name; /* Remote party name */
RIL_CDMA_SignalInfoRecord signalInfoRecord;
} RIL_CDMA_CallWaiting_v5;
typedef struct {
char * number; /* Remote party number */
int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown */
char * name; /* Remote party name */
RIL_CDMA_SignalInfoRecord signalInfoRecord;
/* Number type/Number plan required to support International Call Waiting */
int number_type; /* 0=Unknown, 1=International, 2=National,
3=Network specific, 4=subscriber */
int number_plan; /* 0=Unknown, 1=ISDN, 3=Data, 4=Telex, 8=Nat'l, 9=Private */
} RIL_CDMA_CallWaiting_v6;
/**
* Which types of Cell Broadcast Message (CBM) are to be received by the ME
*
* uFromServiceID - uToServiceID defines a range of CBM message identifiers
* whose value is 0x0000 - 0xFFFF as defined in TS 23.041 9.4.1.2.2 for GMS
* and 9.4.4.2.2 for UMTS. All other values can be treated as empty
* CBM message ID.
*
* uFromCodeScheme - uToCodeScheme defines a range of CBM data coding schemes
* whose value is 0x00 - 0xFF as defined in TS 23.041 9.4.1.2.3 for GMS
* and 9.4.4.2.3 for UMTS.
* All other values can be treated as empty CBM data coding scheme.
*
* selected 0 means message types specified in <fromServiceId, toServiceId>
* and <fromCodeScheme, toCodeScheme>are not accepted, while 1 means accepted.
*
* Used by RIL_REQUEST_GSM_GET_BROADCAST_CONFIG and
* RIL_REQUEST_GSM_SET_BROADCAST_CONFIG.
*/
typedef struct {
int fromServiceId;
int toServiceId;
int fromCodeScheme;
int toCodeScheme;
unsigned char selected;
} RIL_GSM_BroadcastSmsConfigInfo;
/* No restriction at all including voice/SMS/USSD/SS/AV64 and packet data. */
#define RIL_RESTRICTED_STATE_NONE 0x00
/* Block emergency call due to restriction. But allow all normal voice/SMS/USSD/SS/AV64. */
#define RIL_RESTRICTED_STATE_CS_EMERGENCY 0x01
/* Block all normal voice/SMS/USSD/SS/AV64 due to restriction. Only Emergency call allowed. */
#define RIL_RESTRICTED_STATE_CS_NORMAL 0x02
/* Block all voice/SMS/USSD/SS/AV64 including emergency call due to restriction.*/
#define RIL_RESTRICTED_STATE_CS_ALL 0x04
/* Block packet data access due to restriction. */
#define RIL_RESTRICTED_STATE_PS_ALL 0x10
/* The status for an OTASP/OTAPA session */
typedef enum {
CDMA_OTA_PROVISION_STATUS_SPL_UNLOCKED,
CDMA_OTA_PROVISION_STATUS_SPC_RETRIES_EXCEEDED,
CDMA_OTA_PROVISION_STATUS_A_KEY_EXCHANGED,
CDMA_OTA_PROVISION_STATUS_SSD_UPDATED,
CDMA_OTA_PROVISION_STATUS_NAM_DOWNLOADED,
CDMA_OTA_PROVISION_STATUS_MDN_DOWNLOADED,
CDMA_OTA_PROVISION_STATUS_IMSI_DOWNLOADED,
CDMA_OTA_PROVISION_STATUS_PRL_DOWNLOADED,
CDMA_OTA_PROVISION_STATUS_COMMITTED,
CDMA_OTA_PROVISION_STATUS_OTAPA_STARTED,
CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED,
CDMA_OTA_PROVISION_STATUS_OTAPA_ABORTED
} RIL_CDMA_OTA_ProvisionStatus;
typedef struct {
int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
int bitErrorRate; /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */
} RIL_GW_SignalStrength;
typedef struct {
int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
int bitErrorRate; /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */
int timingAdvance; /* Timing Advance in bit periods. 1 bit period = 48/13 us.
* INT_MAX denotes invalid value */
} RIL_GSM_SignalStrength_v12;
typedef struct {
int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
int bitErrorRate; /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */
} RIL_SignalStrengthWcdma;
typedef struct {
int dbm; /* Valid values are positive integers. This value is the actual RSSI value
* multiplied by -1. Example: If the actual RSSI is -75, then this response
* value will be 75.
*/
int ecio; /* Valid values are positive integers. This value is the actual Ec/Io multiplied
* by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value
* will be 125.
*/
} RIL_CDMA_SignalStrength;
typedef struct {
int dbm; /* Valid values are positive integers. This value is the actual RSSI value
* multiplied by -1. Example: If the actual RSSI is -75, then this response
* value will be 75.
*/
int ecio; /* Valid values are positive integers. This value is the actual Ec/Io multiplied
* by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value
* will be 125.
*/
int signalNoiseRatio; /* Valid values are 0-8. 8 is the highest signal to noise ratio. */
} RIL_EVDO_SignalStrength;
typedef struct {
int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
int rsrp; /* The current Reference Signal Receive Power in dBm multipled by -1.
* Range: 44 to 140 dBm
* INT_MAX: 0x7FFFFFFF denotes invalid value.
* Reference: 3GPP TS 36.133 9.1.4 */
int rsrq; /* The current Reference Signal Receive Quality in dB multiplied by -1.
* Range: 20 to 3 dB.
* INT_MAX: 0x7FFFFFFF denotes invalid value.
* Reference: 3GPP TS 36.133 9.1.7 */
int rssnr; /* The current reference signal signal-to-noise ratio in 0.1 dB units.
* Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
* INT_MAX : 0x7FFFFFFF denotes invalid value.
* Reference: 3GPP TS 36.101 8.1.1 */
int cqi; /* The current Channel Quality Indicator.
* Range: 0 to 15.
* INT_MAX : 0x7FFFFFFF denotes invalid value.
* Reference: 3GPP TS 36.101 9.2, 9.3, A.4 */
} RIL_LTE_SignalStrength;
typedef struct {
int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
int rsrp; /* The current Reference Signal Receive Power in dBm multipled by -1.
* Range: 44 to 140 dBm
* INT_MAX: 0x7FFFFFFF denotes invalid value.
* Reference: 3GPP TS 36.133 9.1.4 */
int rsrq; /* The current Reference Signal Receive Quality in dB multiplied by -1.
* Range: 20 to 3 dB.
* INT_MAX: 0x7FFFFFFF denotes invalid value.
* Reference: 3GPP TS 36.133 9.1.7 */
int rssnr; /* The current reference signal signal-to-noise ratio in 0.1 dB units.
* Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).
* INT_MAX : 0x7FFFFFFF denotes invalid value.
* Reference: 3GPP TS 36.101 8.1.1 */
int cqi; /* The current Channel Quality Indicator.
* Range: 0 to 15.
* INT_MAX : 0x7FFFFFFF denotes invalid value.
* Reference: 3GPP TS 36.101 9.2, 9.3, A.4 */
int timingAdvance; /* timing advance in micro seconds for a one way trip from cell to device.
* Approximate distance can be calculated using 300m/us * timingAdvance.
* Range: 0 to 0x7FFFFFFE
* INT_MAX : 0x7FFFFFFF denotes invalid value.
* Reference: 3GPP 36.321 section 6.1.3.5
* also: http://www.cellular-planningoptimization.com/2010/02/timing-advance-with-calculation.html */
} RIL_LTE_SignalStrength_v8;
typedef struct {
int rscp; /* The Received Signal Code Power in dBm multipled by -1.
* Range : 25 to 120
* INT_MAX: 0x7FFFFFFF denotes invalid value.
* Reference: 3GPP TS 25.123, section 9.1.1.1 */
} RIL_TD_SCDMA_SignalStrength;
/* Deprecated, use RIL_SignalStrength_v6 */
typedef struct {
RIL_GW_SignalStrength GW_SignalStrength;
RIL_CDMA_SignalStrength CDMA_SignalStrength;
RIL_EVDO_SignalStrength EVDO_SignalStrength;
} RIL_SignalStrength_v5;
typedef struct {
RIL_GW_SignalStrength GW_SignalStrength;
RIL_CDMA_SignalStrength CDMA_SignalStrength;
RIL_EVDO_SignalStrength EVDO_SignalStrength;
RIL_LTE_SignalStrength LTE_SignalStrength;
} RIL_SignalStrength_v6;
typedef struct {
RIL_GW_SignalStrength GW_SignalStrength;
RIL_CDMA_SignalStrength CDMA_SignalStrength;
RIL_EVDO_SignalStrength EVDO_SignalStrength;
RIL_LTE_SignalStrength_v8 LTE_SignalStrength;
int unknown;
} RIL_SignalStrength_v8;
typedef struct {
RIL_GW_SignalStrength GW_SignalStrength;
RIL_CDMA_SignalStrength CDMA_SignalStrength;
RIL_EVDO_SignalStrength EVDO_SignalStrength;
int sony_network_field; //What the network is here?
RIL_LTE_SignalStrength_v8 LTE_SignalStrength;
RIL_TD_SCDMA_SignalStrength TD_SCDMA_SignalStrength;
int unused1, unused2;
} RIL_SignalStrength_v10;
typedef struct {
int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
int cid; /* 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown */
} RIL_CellIdentityGsm;
typedef struct {
int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
int cid; /* 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown */
int arfcn; /* 16-bit GSM Absolute RF channel number; this value must be reported */
uint8_t bsic; /* 6-bit Base Station Identity Code; 0xFF if unknown */
} RIL_CellIdentityGsm_v12;
typedef struct {
int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
int cid; /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */
int psc; /* 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511, INT_MAX if unknown */
} RIL_CellIdentityWcdma;
typedef struct {
int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
int cid; /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */
int psc; /* 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511; this value must be reported */
int uarfcn; /* 16-bit UMTS Absolute RF Channel Number; this value must be reported */
} RIL_CellIdentityWcdma_v12;
typedef struct {
int networkId; /* Network Id 0..65535, INT_MAX if unknown */
int systemId; /* CDMA System Id 0..32767, INT_MAX if unknown */
int basestationId; /* Base Station Id 0..65535, INT_MAX if unknown */
int longitude; /* Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
* It is represented in units of 0.25 seconds and ranges from -2592000
* to 2592000, both values inclusive (corresponding to a range of -180
* to +180 degrees). INT_MAX if unknown */
int latitude; /* Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
* It is represented in units of 0.25 seconds and ranges from -1296000
* to 1296000, both values inclusive (corresponding to a range of -90
* to +90 degrees). INT_MAX if unknown */
} RIL_CellIdentityCdma;
typedef struct {
int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
int ci; /* 28-bit Cell Identity described in TS ???, INT_MAX if unknown */
int pci; /* physical cell id 0..503, INT_MAX if unknown */
int tac; /* 16-bit tracking area code, INT_MAX if unknown */
} RIL_CellIdentityLte;
typedef struct {
int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
int ci; /* 28-bit Cell Identity described in TS ???, INT_MAX if unknown */
int pci; /* physical cell id 0..503; this value must be reported */
int tac; /* 16-bit tracking area code, INT_MAX if unknown */
int earfcn; /* 18-bit LTE Absolute RF Channel Number; this value must be reported */
} RIL_CellIdentityLte_v12;
typedef struct {
int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
int cid; /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */
int cpid; /* 8-bit Cell Parameters ID described in TS 25.331, 0..127, INT_MAX if unknown */
} RIL_CellIdentityTdscdma;
typedef struct {
RIL_CellIdentityGsm cellIdentityGsm;
RIL_GW_SignalStrength signalStrengthGsm;
} RIL_CellInfoGsm;
typedef struct {
RIL_CellIdentityGsm_v12 cellIdentityGsm;
RIL_GSM_SignalStrength_v12 signalStrengthGsm;
} RIL_CellInfoGsm_v12;
typedef struct {
RIL_CellIdentityWcdma cellIdentityWcdma;
RIL_SignalStrengthWcdma signalStrengthWcdma;
} RIL_CellInfoWcdma;
typedef struct {
RIL_CellIdentityWcdma_v12 cellIdentityWcdma;
RIL_SignalStrengthWcdma signalStrengthWcdma;
} RIL_CellInfoWcdma_v12;
typedef struct {
RIL_CellIdentityCdma cellIdentityCdma;
RIL_CDMA_SignalStrength signalStrengthCdma;
RIL_EVDO_SignalStrength signalStrengthEvdo;
} RIL_CellInfoCdma;
typedef struct {
RIL_CellIdentityLte cellIdentityLte;
RIL_LTE_SignalStrength_v8 signalStrengthLte;
} RIL_CellInfoLte;
typedef struct {
RIL_CellIdentityLte_v12 cellIdentityLte;
RIL_LTE_SignalStrength_v8 signalStrengthLte;
} RIL_CellInfoLte_v12;
typedef struct {
RIL_CellIdentityTdscdma cellIdentityTdscdma;
RIL_TD_SCDMA_SignalStrength signalStrengthTdscdma;
} RIL_CellInfoTdscdma;
// Must be the same as CellInfo.TYPE_XXX
typedef enum {
RIL_CELL_INFO_TYPE_NONE = 0, /* indicates no cell information */
RIL_CELL_INFO_TYPE_GSM = 1,
RIL_CELL_INFO_TYPE_CDMA = 2,
RIL_CELL_INFO_TYPE_LTE = 3,
RIL_CELL_INFO_TYPE_WCDMA = 4,
RIL_CELL_INFO_TYPE_TD_SCDMA = 5
} RIL_CellInfoType;
// Must be the same as CellInfo.TIMESTAMP_TYPE_XXX
typedef enum {
RIL_TIMESTAMP_TYPE_UNKNOWN = 0,
RIL_TIMESTAMP_TYPE_ANTENNA = 1,
RIL_TIMESTAMP_TYPE_MODEM = 2,
RIL_TIMESTAMP_TYPE_OEM_RIL = 3,
RIL_TIMESTAMP_TYPE_JAVA_RIL = 4,
} RIL_TimeStampType;
typedef struct {
RIL_CellInfoType cellInfoType; /* cell type for selecting from union CellInfo */
int registered; /* !0 if this cell is registered 0 if not registered */
RIL_TimeStampType timeStampType; /* type of time stamp represented by timeStamp */
uint64_t timeStamp; /* Time in nanos as returned by ril_nano_time */
union {
RIL_CellInfoGsm gsm;
RIL_CellInfoCdma cdma;
RIL_CellInfoLte lte;
RIL_CellInfoWcdma wcdma;
RIL_CellInfoTdscdma tdscdma;
} CellInfo;
} RIL_CellInfo;
typedef struct {
RIL_CellInfoType cellInfoType; /* cell type for selecting from union CellInfo */
int registered; /* !0 if this cell is registered 0 if not registered */
RIL_TimeStampType timeStampType; /* type of time stamp represented by timeStamp */
uint64_t timeStamp; /* Time in nanos as returned by ril_nano_time */
union {
RIL_CellInfoGsm_v12 gsm;
RIL_CellInfoCdma cdma;
RIL_CellInfoLte_v12 lte;
RIL_CellInfoWcdma_v12 wcdma;
RIL_CellInfoTdscdma tdscdma;
} CellInfo;
} RIL_CellInfo_v12;
typedef struct {
RIL_CellInfoType cellInfoType; /* cell type for selecting from union CellInfo */
union {
RIL_CellIdentityGsm_v12 cellIdentityGsm;
RIL_CellIdentityWcdma_v12 cellIdentityWcdma;
RIL_CellIdentityLte_v12 cellIdentityLte;
RIL_CellIdentityTdscdma cellIdentityTdscdma;
RIL_CellIdentityCdma cellIdentityCdma;
};
}RIL_CellIdentity_v16;
typedef struct {
RIL_RegState regState; // Valid reg states are RIL_NOT_REG_AND_NOT_SEARCHING,
// REG_HOME, RIL_NOT_REG_AND_SEARCHING, REG_DENIED,
// UNKNOWN, REG_ROAMING defined in RegState
RIL_RadioTechnology rat; // indicates the available voice radio technology,
// valid values as defined by RadioTechnology.
int32_t cssSupported; // concurrent services support indicator. if
// registered on a CDMA system.
// 0 - Concurrent services not supported,
// 1 - Concurrent services supported
int32_t roamingIndicator; // TSB-58 Roaming Indicator if registered
// on a CDMA or EVDO system or -1 if not.
// Valid values are 0-255.
int32_t systemIsInPrl; // indicates whether the current system is in the
// PRL if registered on a CDMA or EVDO system or -1 if
// not. 0=not in the PRL, 1=in the PRL
int32_t defaultRoamingIndicator; // default Roaming Indicator from the PRL,
// if registered on a CDMA or EVDO system or -1 if not.
// Valid values are 0-255.
int32_t reasonForDenial; // reasonForDenial if registration state is 3
// (Registration denied) this is an enumerated reason why
// registration was denied. See 3GPP TS 24.008,
// 10.5.3.6 and Annex G.
// 0 - General
// 1 - Authentication Failure
// 2 - IMSI unknown in HLR
// 3 - Illegal MS
// 4 - Illegal ME
// 5 - PLMN not allowed
// 6 - Location area not allowed
// 7 - Roaming not allowed
// 8 - No Suitable Cells in this Location Area
// 9 - Network failure
// 10 - Persistent location update reject
// 11 - PLMN not allowed
// 12 - Location area not allowed
// 13 - Roaming not allowed in this Location Area
// 15 - No Suitable Cells in this Location Area
// 17 - Network Failure
// 20 - MAC Failure
// 21 - Sync Failure
// 22 - Congestion
// 23 - GSM Authentication unacceptable
// 25 - Not Authorized for this CSG
// 32 - Service option not supported
// 33 - Requested service option not subscribed
// 34 - Service option temporarily out of order
// 38 - Call cannot be identified
// 48-63 - Retry upon entry into a new cell
// 95 - Semantically incorrect message
// 96 - Invalid mandatory information
// 97 - Message type non-existent or not implemented
// 98 - Message type not compatible with protocol state
// 99 - Information element non-existent or
// not implemented
// 100 - Conditional IE error
// 101 - Message not compatible with protocol state;
RIL_CellIdentity_v16 cellIdentity; // current cell information
}RIL_VoiceRegistrationStateResponse;
typedef struct {
RIL_RegState regState; // Valid reg states are RIL_NOT_REG_AND_NOT_SEARCHING,
// REG_HOME, RIL_NOT_REG_AND_SEARCHING, REG_DENIED,
// UNKNOWN, REG_ROAMING defined in RegState
RIL_RadioTechnology rat; // indicates the available data radio technology,
// valid values as defined by RadioTechnology.
int32_t reasonDataDenied; // if registration state is 3 (Registration
// denied) this is an enumerated reason why
// registration was denied. See 3GPP TS 24.008,
// Annex G.6 "Additional cause codes for GMM".
// 7 == GPRS services not allowed
// 8 == GPRS services and non-GPRS services not allowed
// 9 == MS identity cannot be derived by the network
// 10 == Implicitly detached
// 14 == GPRS services not allowed in this PLMN
// 16 == MSC temporarily not reachable
// 40 == No PDP context activated
int32_t maxDataCalls; // The maximum number of simultaneous Data Calls that
// must be established using setupDataCall().
RIL_CellIdentity_v16 cellIdentity; // Current cell information
}RIL_DataRegistrationStateResponse;
/* Names of the CDMA info records (C.S0005 section 3.7.5) */
typedef enum {
RIL_CDMA_DISPLAY_INFO_REC,
RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC,
RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC,
RIL_CDMA_CONNECTED_NUMBER_INFO_REC,
RIL_CDMA_SIGNAL_INFO_REC,
RIL_CDMA_REDIRECTING_NUMBER_INFO_REC,
RIL_CDMA_LINE_CONTROL_INFO_REC,
RIL_CDMA_EXTENDED_DISPLAY_INFO_REC,
RIL_CDMA_T53_CLIR_INFO_REC,
RIL_CDMA_T53_RELEASE_INFO_REC,
RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC
} RIL_CDMA_InfoRecName;
/* Display Info Rec as defined in C.S0005 section 3.7.5.1
Extended Display Info Rec as defined in C.S0005 section 3.7.5.16
Note: the Extended Display info rec contains multiple records of the
form: display_tag, display_len, and display_len occurrences of the
chari field if the display_tag is not 10000000 or 10000001.
To save space, the records are stored consecutively in a byte buffer.
The display_tag, display_len and chari fields are all 1 byte.
*/
typedef struct {
char alpha_len;
char alpha_buf[CDMA_ALPHA_INFO_BUFFER_LENGTH];
} RIL_CDMA_DisplayInfoRecord;
/* Called Party Number Info Rec as defined in C.S0005 section 3.7.5.2
Calling Party Number Info Rec as defined in C.S0005 section 3.7.5.3
Connected Number Info Rec as defined in C.S0005 section 3.7.5.4
*/
typedef struct {
char len;
char buf[CDMA_NUMBER_INFO_BUFFER_LENGTH];
char number_type;
char number_plan;
char pi;
char si;
} RIL_CDMA_NumberInfoRecord;
/* Redirecting Number Information Record as defined in C.S0005 section 3.7.5.11 */
typedef enum {
RIL_REDIRECTING_REASON_UNKNOWN = 0,
RIL_REDIRECTING_REASON_CALL_FORWARDING_BUSY = 1,
RIL_REDIRECTING_REASON_CALL_FORWARDING_NO_REPLY = 2,
RIL_REDIRECTING_REASON_CALLED_DTE_OUT_OF_ORDER = 9,
RIL_REDIRECTING_REASON_CALL_FORWARDING_BY_THE_CALLED_DTE = 10,
RIL_REDIRECTING_REASON_CALL_FORWARDING_UNCONDITIONAL = 15,
RIL_REDIRECTING_REASON_RESERVED
} RIL_CDMA_RedirectingReason;
typedef struct {
RIL_CDMA_NumberInfoRecord redirectingNumber;
/* redirectingReason is set to RIL_REDIRECTING_REASON_UNKNOWN if not included */
RIL_CDMA_RedirectingReason redirectingReason;
} RIL_CDMA_RedirectingNumberInfoRecord;
/* Line Control Information Record as defined in C.S0005 section 3.7.5.15 */
typedef struct {
char lineCtrlPolarityIncluded;
char lineCtrlToggle;
char lineCtrlReverse;
char lineCtrlPowerDenial;
} RIL_CDMA_LineControlInfoRecord;
/* T53 CLIR Information Record */
typedef struct {
char cause;
} RIL_CDMA_T53_CLIRInfoRecord;
/* T53 Audio Control Information Record */
typedef struct {
char upLink;
char downLink;
} RIL_CDMA_T53_AudioControlInfoRecord;
typedef struct {
RIL_CDMA_InfoRecName name;
union {
/* Display and Extended Display Info Rec */
RIL_CDMA_DisplayInfoRecord display;
/* Called Party Number, Calling Party Number, Connected Number Info Rec */
RIL_CDMA_NumberInfoRecord number;
/* Signal Info Rec */
RIL_CDMA_SignalInfoRecord signal;
/* Redirecting Number Info Rec */
RIL_CDMA_RedirectingNumberInfoRecord redir;
/* Line Control Info Rec */
RIL_CDMA_LineControlInfoRecord lineCtrl;
/* T53 CLIR Info Rec */
RIL_CDMA_T53_CLIRInfoRecord clir;
/* T53 Audio Control Info Rec */
RIL_CDMA_T53_AudioControlInfoRecord audioCtrl;
} rec;
} RIL_CDMA_InformationRecord;
#define RIL_CDMA_MAX_NUMBER_OF_INFO_RECS 10
typedef struct {
char numberOfInfoRecs;
RIL_CDMA_InformationRecord infoRec[RIL_CDMA_MAX_NUMBER_OF_INFO_RECS];
} RIL_CDMA_InformationRecords;
/* See RIL_REQUEST_NV_READ_ITEM */
typedef struct {
RIL_NV_Item itemID;
} RIL_NV_ReadItem;
/* See RIL_REQUEST_NV_WRITE_ITEM */
typedef struct {
RIL_NV_Item itemID;
char * value;
} RIL_NV_WriteItem;
typedef enum {
HANDOVER_STARTED = 0,
HANDOVER_COMPLETED = 1,
HANDOVER_FAILED = 2,
HANDOVER_CANCELED = 3
} RIL_SrvccState;
/* hardware configuration reported to RILJ. */
typedef enum {
RIL_HARDWARE_CONFIG_MODEM = 0,
RIL_HARDWARE_CONFIG_SIM = 1,
} RIL_HardwareConfig_Type;
typedef enum {
RIL_HARDWARE_CONFIG_STATE_ENABLED = 0,
RIL_HARDWARE_CONFIG_STATE_STANDBY = 1,
RIL_HARDWARE_CONFIG_STATE_DISABLED = 2,
} RIL_HardwareConfig_State;
typedef struct {
int rilModel;
uint32_t rat; /* bitset - ref. RIL_RadioTechnology. */
int maxVoice;
int maxData;
int maxStandby;
} RIL_HardwareConfig_Modem;
typedef struct {
char modemUuid[MAX_UUID_LENGTH];
} RIL_HardwareConfig_Sim;
typedef struct {
RIL_HardwareConfig_Type type;
char uuid[MAX_UUID_LENGTH];
RIL_HardwareConfig_State state;
union {
RIL_HardwareConfig_Modem modem;
RIL_HardwareConfig_Sim sim;
} cfg;
} RIL_HardwareConfig;
typedef enum {
SS_CFU,
SS_CF_BUSY,
SS_CF_NO_REPLY,
SS_CF_NOT_REACHABLE,
SS_CF_ALL,
SS_CF_ALL_CONDITIONAL,
SS_CLIP,
SS_CLIR,
SS_COLP,
SS_COLR,
SS_WAIT,
SS_BAOC,
SS_BAOIC,
SS_BAOIC_EXC_HOME,
SS_BAIC,
SS_BAIC_ROAMING,
SS_ALL_BARRING,
SS_OUTGOING_BARRING,
SS_INCOMING_BARRING
} RIL_SsServiceType;
typedef enum {
SS_ACTIVATION,
SS_DEACTIVATION,
SS_INTERROGATION,
SS_REGISTRATION,
SS_ERASURE
} RIL_SsRequestType;
typedef enum {
SS_ALL_TELE_AND_BEARER_SERVICES,
SS_ALL_TELESEVICES,
SS_TELEPHONY,
SS_ALL_DATA_TELESERVICES,
SS_SMS_SERVICES,
SS_ALL_TELESERVICES_EXCEPT_SMS
} RIL_SsTeleserviceType;
#define SS_INFO_MAX 4
#define NUM_SERVICE_CLASSES 7
typedef struct {
int numValidIndexes; /* This gives the number of valid values in cfInfo.
For example if voice is forwarded to one number and data
is forwarded to a different one then numValidIndexes will be
2 indicating total number of valid values in cfInfo.
Similarly if all the services are forwarded to the same
number then the value of numValidIndexes will be 1. */
RIL_CallForwardInfo cfInfo[NUM_SERVICE_CLASSES]; /* This is the response data
for SS request to query call
forward status. see
RIL_REQUEST_QUERY_CALL_FORWARD_STATUS */
} RIL_CfData;
typedef struct {
RIL_SsServiceType serviceType;
RIL_SsRequestType requestType;
RIL_SsTeleserviceType teleserviceType;
int serviceClass;
RIL_Errno result;
union {
int ssInfo[SS_INFO_MAX]; /* This is the response data for most of the SS GET/SET
RIL requests. E.g. RIL_REQUSET_GET_CLIR returns
two ints, so first two values of ssInfo[] will be
used for response if serviceType is SS_CLIR and
requestType is SS_INTERROGATION */
RIL_CfData cfData;
};
} RIL_StkCcUnsolSsResponse;
/**
* Data connection power state
*/
typedef enum {
RIL_DC_POWER_STATE_LOW = 1, // Low power state
RIL_DC_POWER_STATE_MEDIUM = 2, // Medium power state
RIL_DC_POWER_STATE_HIGH = 3, // High power state
RIL_DC_POWER_STATE_UNKNOWN = INT32_MAX // Unknown state
} RIL_DcPowerStates;
/**
* Data connection real time info
*/
typedef struct {
uint64_t time; // Time in nanos as returned by ril_nano_time
RIL_DcPowerStates powerState; // Current power state
} RIL_DcRtInfo;
/**
* Data profile to modem
*/
typedef struct {
/* id of the data profile */
int profileId;
/* the APN to connect to */
char* apn;
/** one of the PDP_type values in TS 27.007 section 10.1.1.
* For example, "IP", "IPV6", "IPV4V6", or "PPP".
*/
char* protocol;
/** authentication protocol used for this PDP context
* (None: 0, PAP: 1, CHAP: 2, PAP&CHAP: 3)
*/
int authType;
/* the username for APN, or NULL */
char* user;
/* the password for APN, or NULL */
char* password;
/* the profile type, TYPE_COMMON-0, TYPE_3GPP-1, TYPE_3GPP2-2 */
int type;
/* the period in seconds to limit the maximum connections */
int maxConnsTime;
/* the maximum connections during maxConnsTime */
int maxConns;
/** the required wait time in seconds after a successful UE initiated
* disconnect of a given PDN connection before the device can send
* a new PDN connection request for that given PDN
*/
int waitTime;
/* true to enable the profile, 0 to disable, 1 to enable */
int enabled;
} RIL_DataProfileInfo;
typedef struct {
/* id of the data profile */
int profileId;
/* the APN to connect to */
char* apn;
/** one of the PDP_type values in TS 27.007 section 10.1.1.
* For example, "IP", "IPV6", "IPV4V6", or "PPP".
*/
char* protocol;
/** one of the PDP_type values in TS 27.007 section 10.1.1 used on roaming network.
* For example, "IP", "IPV6", "IPV4V6", or "PPP".
*/
char *roamingProtocol;
/** authentication protocol used for this PDP context
* (None: 0, PAP: 1, CHAP: 2, PAP&CHAP: 3)
*/
int authType;
/* the username for APN, or NULL */
char* user;
/* the password for APN, or NULL */
char* password;
/* the profile type, TYPE_COMMON-0, TYPE_3GPP-1, TYPE_3GPP2-2 */
int type;
/* the period in seconds to limit the maximum connections */
int maxConnsTime;
/* the maximum connections during maxConnsTime */
int maxConns;
/** the required wait time in seconds after a successful UE initiated
* disconnect of a given PDN connection before the device can send
* a new PDN connection request for that given PDN
*/
int waitTime;
/* true to enable the profile, 0 to disable, 1 to enable */
int enabled;
/* supported APN types bitmask. See RIL_ApnTypes for the value of each bit. */
int supportedTypesBitmask;
/** the bearer bitmask. See RIL_RadioAccessFamily for the value of each bit. */
int bearerBitmask;
/** maximum transmission unit (MTU) size in bytes */
int mtu;
/** the MVNO type: possible values are "imsi", "gid", "spn" */
char *mvnoType;
/** MVNO match data. Can be anything defined by the carrier. For example,
* SPN like: "A MOBILE", "BEN NL", etc...
* IMSI like: "302720x94", "2060188", etc...
* GID like: "4E", "33", etc...
*/
char *mvnoMatchData;
} RIL_DataProfileInfo_v15;
/* Tx Power Levels */
#define RIL_NUM_TX_POWER_LEVELS 5
/**
* Aggregate modem activity information
*/
typedef struct {
/* total time (in ms) when modem is in a low power or
* sleep state
*/
uint32_t sleep_mode_time_ms;
/* total time (in ms) when modem is awake but neither
* the transmitter nor receiver are active/awake */
uint32_t idle_mode_time_ms;
/* total time (in ms) during which the transmitter is active/awake,
* subdivided by manufacturer-defined device-specific
* contiguous increasing ranges of transmit power between
* 0 and the transmitter's maximum transmit power.
*/
uint32_t tx_mode_time_ms[RIL_NUM_TX_POWER_LEVELS];
/* total time (in ms) for which receiver is active/awake and
* the transmitter is inactive */
uint32_t rx_mode_time_ms;
} RIL_ActivityStatsInfo;
typedef enum {
RIL_APN_TYPE_UNKNOWN = 0x0, // Unknown
RIL_APN_TYPE_DEFAULT = 0x1, // APN type for default data traffic
RIL_APN_TYPE_MMS = 0x2, // APN type for MMS traffic
RIL_APN_TYPE_SUPL = 0x4, // APN type for SUPL assisted GPS
RIL_APN_TYPE_DUN = 0x8, // APN type for DUN traffic
RIL_APN_TYPE_HIPRI = 0x10, // APN type for HiPri traffic
RIL_APN_TYPE_FOTA = 0x20, // APN type for FOTA
RIL_APN_TYPE_IMS = 0x40, // APN type for IMS
RIL_APN_TYPE_CBS = 0x80, // APN type for CBS
RIL_APN_TYPE_IA = 0x100, // APN type for IA Initial Attach APN
RIL_APN_TYPE_EMERGENCY = 0x200, // APN type for Emergency PDN. This is not an IA apn,
// but is used for access to carrier services in an
// emergency call situation.
RIL_APN_TYPE_ALL = 0xFFFFFFFF // All APN types
} RIL_ApnTypes;
typedef enum {
RIL_DST_POWER_SAVE_MODE, // Device power save mode (provided by PowerManager)
// True indicates the device is in power save mode.
RIL_DST_CHARGING_STATE, // Device charging state (provided by BatteryManager)
// True indicates the device is charging.
RIL_DST_LOW_DATA_EXPECTED // Low data expected mode. True indicates low data traffic
// is expected, for example, when the device is idle
// (e.g. not doing tethering in the background). Note
// this doesn't mean no data is expected.
} RIL_DeviceStateType;
typedef enum {
RIL_UR_SIGNAL_STRENGTH = 0x01, // When this bit is set, modem should always send the
// signal strength update through
// RIL_UNSOL_SIGNAL_STRENGTH, otherwise suppress it.
RIL_UR_FULL_NETWORK_STATE = 0x02, // When this bit is set, modem should always send
// RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED
// when any field in
// RIL_REQUEST_VOICE_REGISTRATION_STATE or
// RIL_REQUEST_DATA_REGISTRATION_STATE changes. When
// this bit is not set, modem should suppress
// RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED
// only when insignificant fields change
// (e.g. cell info).
// Modem should continue sending
// RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED
// when significant fields are updated even when this
// bit is not set. The following fields are
// considered significant, registration state and
// radio technology.
RIL_UR_DATA_CALL_DORMANCY_CHANGED = 0x04 // When this bit is set, modem should send the data
// call list changed unsolicited response
// RIL_UNSOL_DATA_CALL_LIST_CHANGED whenever any
// field in RIL_Data_Call_Response changes.
// Otherwise modem should suppress the unsolicited
// response when the only changed field is 'active'
// (for data dormancy). For all other fields change,
// modem should continue sending
// RIL_UNSOL_DATA_CALL_LIST_CHANGED regardless this
// bit is set or not.
} RIL_UnsolicitedResponseFilter;
typedef struct {
char * aidPtr; /* AID value, See ETSI 102.221 and 101.220*/
int p2; /* P2 parameter (described in ISO 7816-4)
P2Constants:NO_P2 if to be ignored */
} RIL_OpenChannelParams;
typedef enum {
RIL_ONE_SHOT = 0x01, // Performs the scan only once
RIL_PERIODIC = 0x02 // Performs the scan periodically until cancelled
} RIL_ScanType;
typedef enum {
GERAN = 0x01, // GSM EDGE Radio Access Network
UTRAN = 0x02, // Universal Terrestrial Radio Access Network
EUTRAN = 0x03, // Evolved Universal Terrestrial Radio Access Network
} RIL_RadioAccessNetworks;
typedef enum {
GERAN_BAND_T380 = 1,
GERAN_BAND_T410 = 2,
GERAN_BAND_450 = 3,
GERAN_BAND_480 = 4,
GERAN_BAND_710 = 5,
GERAN_BAND_750 = 6,
GERAN_BAND_T810 = 7,
GERAN_BAND_850 = 8,
GERAN_BAND_P900 = 9,
GERAN_BAND_E900 = 10,
GERAN_BAND_R900 = 11,
GERAN_BAND_DCS1800 = 12,
GERAN_BAND_PCS1900 = 13,
GERAN_BAND_ER900 = 14,
} RIL_GeranBands;
typedef enum {
UTRAN_BAND_1 = 1,
UTRAN_BAND_2 = 2,
UTRAN_BAND_3 = 3,
UTRAN_BAND_4 = 4,
UTRAN_BAND_5 = 5,
UTRAN_BAND_6 = 6,
UTRAN_BAND_7 = 7,
UTRAN_BAND_8 = 8,
UTRAN_BAND_9 = 9,
UTRAN_BAND_10 = 10,
UTRAN_BAND_11 = 11,
UTRAN_BAND_12 = 12,
UTRAN_BAND_13 = 13,
UTRAN_BAND_14 = 14,
UTRAN_BAND_19 = 19,
UTRAN_BAND_20 = 20,
UTRAN_BAND_21 = 21,
UTRAN_BAND_22 = 22,
UTRAN_BAND_25 = 25,
UTRAN_BAND_26 = 26,
} RIL_UtranBands;
typedef enum {
EUTRAN_BAND_1 = 1,
EUTRAN_BAND_2 = 2,
EUTRAN_BAND_3 = 3,
EUTRAN_BAND_4 = 4,
EUTRAN_BAND_5 = 5,
EUTRAN_BAND_6 = 6,
EUTRAN_BAND_7 = 7,
EUTRAN_BAND_8 = 8,
EUTRAN_BAND_9 = 9,
EUTRAN_BAND_10 = 10,
EUTRAN_BAND_11 = 11,
EUTRAN_BAND_12 = 12,
EUTRAN_BAND_13 = 13,
EUTRAN_BAND_14 = 14,
EUTRAN_BAND_17 = 17,
EUTRAN_BAND_18 = 18,
EUTRAN_BAND_19 = 19,
EUTRAN_BAND_20 = 20,
EUTRAN_BAND_21 = 21,
EUTRAN_BAND_22 = 22,
EUTRAN_BAND_23 = 23,
EUTRAN_BAND_24 = 24,
EUTRAN_BAND_25 = 25,
EUTRAN_BAND_26 = 26,
EUTRAN_BAND_27 = 27,
EUTRAN_BAND_28 = 28,
EUTRAN_BAND_30 = 30,
EUTRAN_BAND_31 = 31,
EUTRAN_BAND_33 = 33,
EUTRAN_BAND_34 = 34,
EUTRAN_BAND_35 = 35,
EUTRAN_BAND_36 = 36,
EUTRAN_BAND_37 = 37,
EUTRAN_BAND_38 = 38,
EUTRAN_BAND_39 = 39,
EUTRAN_BAND_40 = 40,
EUTRAN_BAND_41 = 41,
EUTRAN_BAND_42 = 42,
EUTRAN_BAND_43 = 43,
EUTRAN_BAND_44 = 44,
EUTRAN_BAND_45 = 45,
EUTRAN_BAND_46 = 46,
EUTRAN_BAND_47 = 47,
EUTRAN_BAND_48 = 48,
EUTRAN_BAND_65 = 65,
EUTRAN_BAND_66 = 66,
EUTRAN_BAND_68 = 68,
EUTRAN_BAND_70 = 70,
} RIL_EutranBands;
typedef struct {
RIL_RadioAccessNetworks radio_access_network; // The type of network to scan.
uint32_t bands_length; // Length of bands
union {
RIL_GeranBands geran_bands[MAX_BANDS];
RIL_UtranBands utran_bands[MAX_BANDS];
RIL_EutranBands eutran_bands[MAX_BANDS];
} bands;
uint32_t channels_length; // Length of channels
uint32_t channels[MAX_CHANNELS]; // Frequency channels to scan
} RIL_RadioAccessSpecifier;
typedef struct {
RIL_ScanType type; // Type of the scan
int32_t interval; // Time interval in seconds
// between periodic scans, only
// valid when type=RIL_PERIODIC
uint32_t specifiers_length; // Length of specifiers
RIL_RadioAccessSpecifier specifiers[MAX_RADIO_ACCESS_NETWORKS]; // Radio access networks
// with bands/channels.
} RIL_NetworkScanRequest;
typedef enum {
PARTIAL = 0x01, // The result contains a part of the scan results
COMPLETE = 0x02, // The result contains the last part of the scan results
} RIL_ScanStatus;
typedef struct {
RIL_ScanStatus status; // The status of the scan
uint32_t network_infos_length; // Total length of RIL_CellInfo
RIL_CellInfo_v12* network_infos; // List of network information
RIL_Errno error;
} RIL_NetworkScanResult;
/**
* RIL_REQUEST_GET_SIM_STATUS
*
* Requests status of the SIM interface and the SIM card
*
* "data" is NULL
*
* "response" is const RIL_CardStatus_v6 *
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_GET_SIM_STATUS 1
/**
* RIL_REQUEST_ENTER_SIM_PIN
*
* Supplies SIM PIN. Only called if RIL_CardStatus has RIL_APPSTATE_PIN state
*
* "data" is const char **
* ((const char **)data)[0] is PIN value
* ((const char **)data)[1] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
*
* "response" is int *
* ((int *)response)[0] is the number of retries remaining, or -1 if unknown
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* PASSWORD_INCORRECT
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_ARGUMENTS
* INVALID_SIM_STATE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_ENTER_SIM_PIN 2
/**
* RIL_REQUEST_ENTER_SIM_PUK
*
* Supplies SIM PUK and new PIN.
*
* "data" is const char **
* ((const char **)data)[0] is PUK value
* ((const char **)data)[1] is new PIN value
* ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
*
* "response" is int *
* ((int *)response)[0] is the number of retries remaining, or -1 if unknown
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* PASSWORD_INCORRECT
* (PUK is invalid)
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_ARGUMENTS
* INVALID_SIM_STATE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_ENTER_SIM_PUK 3
/**
* RIL_REQUEST_ENTER_SIM_PIN2
*
* Supplies SIM PIN2. Only called following operation where SIM_PIN2 was
* returned as a a failure from a previous operation.
*
* "data" is const char **
* ((const char **)data)[0] is PIN2 value
* ((const char **)data)[1] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
*
* "response" is int *
* ((int *)response)[0] is the number of retries remaining, or -1 if unknown
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* PASSWORD_INCORRECT
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_ARGUMENTS
* INVALID_SIM_STATE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_ENTER_SIM_PIN2 4
/**
* RIL_REQUEST_ENTER_SIM_PUK2
*
* Supplies SIM PUK2 and new PIN2.
*
* "data" is const char **
* ((const char **)data)[0] is PUK2 value
* ((const char **)data)[1] is new PIN2 value
* ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
*
* "response" is int *
* ((int *)response)[0] is the number of retries remaining, or -1 if unknown
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* PASSWORD_INCORRECT
* (PUK2 is invalid)
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_ARGUMENTS
* INVALID_SIM_STATE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_ENTER_SIM_PUK2 5
/**
* RIL_REQUEST_CHANGE_SIM_PIN
*
* Supplies old SIM PIN and new PIN.
*
* "data" is const char **
* ((const char **)data)[0] is old PIN value
* ((const char **)data)[1] is new PIN value
* ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
*
* "response" is int *
* ((int *)response)[0] is the number of retries remaining, or -1 if unknown
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* PASSWORD_INCORRECT
* (old PIN is invalid)
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_ARGUMENTS
* INVALID_SIM_STATE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_CHANGE_SIM_PIN 6
/**
* RIL_REQUEST_CHANGE_SIM_PIN2
*
* Supplies old SIM PIN2 and new PIN2.
*
* "data" is const char **
* ((const char **)data)[0] is old PIN2 value
* ((const char **)data)[1] is new PIN2 value
* ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
*
* "response" is int *
* ((int *)response)[0] is the number of retries remaining, or -1 if unknown
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* PASSWORD_INCORRECT
* (old PIN2 is invalid)
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_ARGUMENTS
* INVALID_SIM_STATE
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_CHANGE_SIM_PIN2 7
/**
* RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION
*
* Requests that network personlization be deactivated
*
* "data" is const char **
* ((const char **)(data))[0]] is network depersonlization code
*
* "response" is int *
* ((int *)response)[0] is the number of retries remaining, or -1 if unknown
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* PASSWORD_INCORRECT
* SIM_ABSENT
* (code is invalid)
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION 8
/**
* RIL_REQUEST_GET_CURRENT_CALLS
*
* Requests current call list
*
* "data" is NULL
*
* "response" must be a "const RIL_Call **"
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* NO_MEMORY
* (request will be made again in a few hundred msec)
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_GET_CURRENT_CALLS 9
/**
* RIL_REQUEST_DIAL
*
* Initiate voice call
*
* "data" is const RIL_Dial *
* "response" is NULL
*
* This method is never used for supplementary service codes
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* DIAL_MODIFIED_TO_USSD
* DIAL_MODIFIED_TO_SS
* DIAL_MODIFIED_TO_DIAL
* INVALID_ARGUMENTS
* NO_MEMORY
* INVALID_STATE
* NO_RESOURCES
* INTERNAL_ERR
* FDN_CHECK_FAILURE
* MODEM_ERR
* NO_SUBSCRIPTION
* NO_NETWORK_FOUND
* INVALID_CALL_ID
* DEVICE_IN_USE
* OPERATION_NOT_ALLOWED
* ABORTED
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_DIAL 10
/**
* RIL_REQUEST_GET_IMSI
*
* Get the SIM IMSI
*
* Only valid when radio state is "RADIO_STATE_ON"
*
* "data" is const char **
* ((const char **)data)[0] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
* "response" is a const char * containing the IMSI
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_SIM_STATE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_GET_IMSI 11
/**
* RIL_REQUEST_HANGUP
*
* Hang up a specific line (like AT+CHLD=1x)
*
* After this HANGUP request returns, RIL should show the connection is NOT
* active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query.
*
* "data" is an int *
* (int *)data)[0] contains Connection index (value of 'x' in CHLD above)
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INVALID_ARGUMENTS
* NO_MEMORY
* INVALID_STATE
* MODEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* INVALID_CALL_ID
* INVALID_ARGUMENTS
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_HANGUP 12
/**
* RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND
*
* Hang up waiting or held (like AT+CHLD=0)
*
* After this HANGUP request returns, RIL should show the connection is NOT
* active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query.
*
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INVALID_STATE
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* INVALID_CALL_ID
* NO_RESOURCES
* OPERATION_NOT_ALLOWED
* INVALID_ARGUMENTS
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND 13
/**
* RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND
*
* Hang up waiting or held (like AT+CHLD=1)
*
* After this HANGUP request returns, RIL should show the connection is NOT
* active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query.
*
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INVALID_STATE
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* INVALID_CALL_ID
* OPERATION_NOT_ALLOWED
* INVALID_ARGUMENTS
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND 14
/**
* RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE
*
* Switch waiting or holding call and active call (like AT+CHLD=2)
*
* State transitions should be is follows:
*
* If call 1 is waiting and call 2 is active, then if this re
*
* BEFORE AFTER
* Call 1 Call 2 Call 1 Call 2
* ACTIVE HOLDING HOLDING ACTIVE
* ACTIVE WAITING HOLDING ACTIVE
* HOLDING WAITING HOLDING ACTIVE
* ACTIVE IDLE HOLDING IDLE
* IDLE IDLE IDLE IDLE
*
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INVALID_STATE
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* INVALID_STATE
* INVALID_ARGUMENTS
* INVALID_CALL_ID
* OPERATION_NOT_ALLOWED
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE 15
#define RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE 15
/**
* RIL_REQUEST_CONFERENCE
*
* Conference holding and active (like AT+CHLD=3)
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* INVALID_STATE
* INVALID_CALL_ID
* INVALID_ARGUMENTS
* OPERATION_NOT_ALLOWED
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_CONFERENCE 16
/**
* RIL_REQUEST_UDUB
*
* Send UDUB (user determined used busy) to ringing or
* waiting call answer)(RIL_BasicRequest r);
*
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INVALID_STATE
* NO_RESOURCES
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* INVALID_CALL_ID
* OPERATION_NOT_ALLOWED
* INVALID_ARGUMENTS
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_UDUB 17
/**
* RIL_REQUEST_LAST_CALL_FAIL_CAUSE
*
* Requests the failure cause code for the most recently terminated call
*
* "data" is NULL
* "response" is a const RIL_LastCallFailCauseInfo *
* RIL_LastCallFailCauseInfo contains LastCallFailCause and vendor cause.
* The vendor cause code must be used for debugging purpose only.
* The implementation must return one of the values of LastCallFailCause
* as mentioned below.
*
* GSM failure reasons codes for the cause codes defined in TS 24.008 Annex H
* where possible.
* CDMA failure reasons codes for the possible call failure scenarios
* described in the "CDMA IS-2000 Release A (C.S0005-A v6.0)" standard.
* Any of the following reason codes if the call is failed or dropped due to reason
* mentioned with in the braces.
*
* CALL_FAIL_RADIO_OFF (Radio is OFF)
* CALL_FAIL_OUT_OF_SERVICE (No cell coverage)
* CALL_FAIL_NO_VALID_SIM (No valid SIM)
* CALL_FAIL_RADIO_INTERNAL_ERROR (Modem hit unexpected error scenario)
* CALL_FAIL_NETWORK_RESP_TIMEOUT (No response from network)
* CALL_FAIL_NETWORK_REJECT (Explicit network reject)
* CALL_FAIL_RADIO_ACCESS_FAILURE (RRC connection failure. Eg.RACH)
* CALL_FAIL_RADIO_LINK_FAILURE (Radio Link Failure)
* CALL_FAIL_RADIO_LINK_LOST (Radio link lost due to poor coverage)
* CALL_FAIL_RADIO_UPLINK_FAILURE (Radio uplink failure)
* CALL_FAIL_RADIO_SETUP_FAILURE (RRC connection setup failure)
* CALL_FAIL_RADIO_RELEASE_NORMAL (RRC connection release, normal)
* CALL_FAIL_RADIO_RELEASE_ABNORMAL (RRC connection release, abnormal)
* CALL_FAIL_ACCESS_CLASS_BLOCKED (Access class barring)
* CALL_FAIL_NETWORK_DETACH (Explicit network detach)
*
* OEM causes (CALL_FAIL_OEM_CAUSE_XX) must be used for debug purpose only
*
* If the implementation does not have access to the exact cause codes,
* then it should return one of the values listed in RIL_LastCallFailCause,
* as the UI layer needs to distinguish these cases for tone generation or
* error notification.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
* See also: RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE
*/
#define RIL_REQUEST_LAST_CALL_FAIL_CAUSE 18
/**
* RIL_REQUEST_SIGNAL_STRENGTH
*
* Requests current signal strength and associated information
*
* Must succeed if radio is on.
*
* "data" is NULL
*
* "response" is a const RIL_SignalStrength *
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* NOT_PROVISIONED
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_SIGNAL_STRENGTH 19
/**
* RIL_REQUEST_VOICE_REGISTRATION_STATE
*
* Request current registration state
*
* "data" is NULL
* "response" is a const RIL_VoiceRegistrationStateResponse *
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_VOICE_REGISTRATION_STATE 20
/**
* RIL_REQUEST_DATA_REGISTRATION_STATE
*
* Request current DATA registration state
*
* "data" is NULL
* "response" is a const RIL_DataRegistrationStateResponse *
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* NOT_PROVISIONED
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_DATA_REGISTRATION_STATE 21
/**
* RIL_REQUEST_OPERATOR
*
* Request current operator ONS or EONS
*
* "data" is NULL
* "response" is a "const char **"
* ((const char **)response)[0] is long alpha ONS or EONS
* or NULL if unregistered
*
* ((const char **)response)[1] is short alpha ONS or EONS
* or NULL if unregistered
* ((const char **)response)[2] is 5 or 6 digit numeric code (MCC + MNC)
* or NULL if unregistered
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_OPERATOR 22
/**
* RIL_REQUEST_RADIO_POWER
*
* Toggle radio on and off (for "airplane" mode)
* If the radio is is turned off/on the radio modem subsystem
* is expected return to an initialized state. For instance,
* any voice and data calls will be terminated and all associated
* lists emptied.
*
* "data" is int *
* ((int *)data)[0] is > 0 for "Radio On"
* ((int *)data)[0] is == 0 for "Radio Off"
*
* "response" is NULL
*
* Turn radio on if "on" > 0
* Turn radio off if "on" == 0
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* OPERATION_NOT_ALLOWED
* INVALID_STATE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* DEVICE_IN_USE
* OPERATION_NOT_ALLOWED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_RADIO_POWER 23
/**
* RIL_REQUEST_DTMF
*
* Send a DTMF tone
*
* If the implementation is currently playing a tone requested via
* RIL_REQUEST_DTMF_START, that tone should be cancelled and the new tone
* should be played instead
*
* "data" is a char * containing a single character with one of 12 values: 0-9,*,#
* "response" is NULL
*
* FIXME should this block/mute microphone?
* How does this interact with local DTMF feedback?
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_ARGUMENTS
* NO_RESOURCES
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* INVALID_CALL_ID
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*
* See also: RIL_REQUEST_DTMF_STOP, RIL_REQUEST_DTMF_START
*
*/
#define RIL_REQUEST_DTMF 24
/**
* RIL_REQUEST_SEND_SMS
*
* Send an SMS message
*
* "data" is const char **
* ((const char **)data)[0] is SMSC address in GSM BCD format prefixed
* by a length byte (as expected by TS 27.005) or NULL for default SMSC
* ((const char **)data)[1] is SMS in PDU format as an ASCII hex string
* less the SMSC address
* TP-Layer-Length is be "strlen(((const char **)data)[1])/2"
*
* "response" is a const RIL_SMS_Response *
*
* Based on the return error, caller decides to resend if sending sms
* fails. SMS_SEND_FAIL_RETRY means retry (i.e. error cause is 332)
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SMS_SEND_FAIL_RETRY
* FDN_CHECK_FAILURE
* NETWORK_REJECT
* INVALID_STATE
* INVALID_ARGUMENTS
* NO_MEMORY
* REQUEST_RATE_LIMITED
* INVALID_SMS_FORMAT
* SYSTEM_ERR
* ENCODING_ERR
* INVALID_SMSC_ADDRESS
* MODEM_ERR
* NETWORK_ERR
* OPERATION_NOT_ALLOWED
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
* MODE_NOT_SUPPORTED
* SIM_ABSENT
*
* FIXME how do we specify TP-Message-Reference if we need to resend?
*/
#define RIL_REQUEST_SEND_SMS 25
/**
* RIL_REQUEST_SEND_SMS_EXPECT_MORE
*
* Send an SMS message. Identical to RIL_REQUEST_SEND_SMS,
* except that more messages are expected to be sent soon. If possible,
* keep SMS relay protocol link open (eg TS 27.005 AT+CMMS command)
*
* "data" is const char **
* ((const char **)data)[0] is SMSC address in GSM BCD format prefixed
* by a length byte (as expected by TS 27.005) or NULL for default SMSC
* ((const char **)data)[1] is SMS in PDU format as an ASCII hex string
* less the SMSC address
* TP-Layer-Length is be "strlen(((const char **)data)[1])/2"
*
* "response" is a const RIL_SMS_Response *
*
* Based on the return error, caller decides to resend if sending sms
* fails. SMS_SEND_FAIL_RETRY means retry (i.e. error cause is 332)
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SMS_SEND_FAIL_RETRY
* NETWORK_REJECT
* INVALID_STATE
* INVALID_ARGUMENTS
* NO_MEMORY
* INVALID_SMS_FORMAT
* SYSTEM_ERR
* REQUEST_RATE_LIMITED
* FDN_CHECK_FAILURE
* MODEM_ERR
* NETWORK_ERR
* ENCODING_ERR
* INVALID_SMSC_ADDRESS
* OPERATION_NOT_ALLOWED
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
* MODE_NOT_SUPPORTED
* SIM_ABSENT
*
*/
#define RIL_REQUEST_SEND_SMS_EXPECT_MORE 26
/**
* RIL_REQUEST_SETUP_DATA_CALL
*
* Setup a packet data connection. If RIL_Data_Call_Response_v6.status
* return success it is added to the list of data calls and a
* RIL_UNSOL_DATA_CALL_LIST_CHANGED is sent. The call remains in the
* list until RIL_REQUEST_DEACTIVATE_DATA_CALL is issued or the
* radio is powered off/on. This list is returned by RIL_REQUEST_DATA_CALL_LIST
* and RIL_UNSOL_DATA_CALL_LIST_CHANGED.
*
* The RIL is expected to:
* - Create one data call context.
* - Create and configure a dedicated interface for the context
* - The interface must be point to point.
* - The interface is configured with one or more addresses and
* is capable of sending and receiving packets. The prefix length
* of the addresses must be /32 for IPv4 and /128 for IPv6.
* - Must NOT change the linux routing table.
* - Support up to RIL_REQUEST_DATA_REGISTRATION_STATE response[5]
* number of simultaneous data call contexts.
*
* "data" is a const char **
* ((const char **)data)[0] Radio technology to use: 0-CDMA, 1-GSM/UMTS, 2...
* for values above 2 this is RIL_RadioTechnology + 2.
* ((const char **)data)[1] is a RIL_DataProfile (support is optional)
* ((const char **)data)[2] is the APN to connect to if radio technology is GSM/UMTS. This APN will
* override the one in the profile. NULL indicates no APN overrride.
* ((const char **)data)[3] is the username for APN, or NULL
* ((const char **)data)[4] is the password for APN, or NULL
* ((const char **)data)[5] is the PAP / CHAP auth type. Values:
* 0 => PAP and CHAP is never performed.
* 1 => PAP may be performed; CHAP is never performed.
* 2 => CHAP may be performed; PAP is never performed.
* 3 => PAP / CHAP may be performed - baseband dependent.
* ((const char **)data)[6] is the non-roaming/home connection type to request. Must be one of the
* PDP_type values in TS 27.007 section 10.1.1.
* For example, "IP", "IPV6", "IPV4V6", or "PPP".
* ((const char **)data)[7] is the roaming connection type to request. Must be one of the
* PDP_type values in TS 27.007 section 10.1.1.
* For example, "IP", "IPV6", "IPV4V6", or "PPP".
* ((const char **)data)[8] is the bitmask of APN type in decimal string format. The
* bitmask will encapsulate the following values:
* ia,mms,agps,supl,hipri,fota,dun,ims,default.
* ((const char **)data)[9] is the bearer bitmask in decimal string format. Each bit is a
* RIL_RadioAccessFamily. "0" or NULL indicates all RATs.
* ((const char **)data)[10] is the boolean in string format indicating the APN setting was
* sent to the modem through RIL_REQUEST_SET_DATA_PROFILE earlier.
* ((const char **)data)[11] is the mtu size in bytes of the mobile interface to which
* the apn is connected.
* ((const char **)data)[12] is the MVNO type:
* possible values are "imsi", "gid", "spn".
* ((const char **)data)[13] is MVNO match data in string. Can be anything defined by the carrier.
* For example,
* SPN like: "A MOBILE", "BEN NL", etc...
* IMSI like: "302720x94", "2060188", etc...
* GID like: "4E", "33", etc...
* ((const char **)data)[14] is the boolean string indicating data roaming is allowed or not. "1"
* indicates data roaming is enabled by the user, "0" indicates disabled.
*
* "response" is a RIL_Data_Call_Response_v11
*
* FIXME may need way to configure QoS settings
*
* Valid errors:
* SUCCESS should be returned on both success and failure of setup with
* the RIL_Data_Call_Response_v6.status containing the actual status.
* For all other errors the RIL_Data_Call_Resonse_v6 is ignored.
*
* Other errors could include:
* RADIO_NOT_AVAILABLE, OP_NOT_ALLOWED_BEFORE_REG_TO_NW,
* OP_NOT_ALLOWED_DURING_VOICE_CALL, REQUEST_NOT_SUPPORTED,
* INVALID_ARGUMENTS, INTERNAL_ERR, NO_MEMORY, NO_RESOURCES,
* CANCELLED and SIM_ABSENT
*
* See also: RIL_REQUEST_DEACTIVATE_DATA_CALL
*/
#define RIL_REQUEST_SETUP_DATA_CALL 27
/**
* RIL_REQUEST_SIM_IO
*
* Request SIM I/O operation.
* This is similar to the TS 27.007 "restricted SIM" operation
* where it assumes all of the EF selection will be done by the
* callee.
*
* "data" is a const RIL_SIM_IO_v6 *
* Please note that RIL_SIM_IO has a "PIN2" field which may be NULL,
* or may specify a PIN2 for operations that require a PIN2 (eg
* updating FDN records)
*
* "response" is a const RIL_SIM_IO_Response *
*
* Arguments and responses that are unused for certain
* values of "command" should be ignored or set to NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SIM_PIN2
* SIM_PUK2
* INVALID_SIM_STATE
* SIM_ERR
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SIM_IO 28
/**
* RIL_REQUEST_SEND_USSD
*
* Send a USSD message
*
* If a USSD session already exists, the message should be sent in the
* context of that session. Otherwise, a new session should be created.
*
* The network reply should be reported via RIL_UNSOL_ON_USSD
*
* Only one USSD session may exist at a time, and the session is assumed
* to exist until:
* a) The android system invokes RIL_REQUEST_CANCEL_USSD
* b) The implementation sends a RIL_UNSOL_ON_USSD with a type code
* of "0" (USSD-Notify/no further action) or "2" (session terminated)
*
* "data" is a const char * containing the USSD request in UTF-8 format
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* FDN_CHECK_FAILURE
* USSD_MODIFIED_TO_DIAL
* USSD_MODIFIED_TO_SS
* USSD_MODIFIED_TO_USSD
* SIM_BUSY
* OPERATION_NOT_ALLOWED
* INVALID_ARGUMENTS
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* ABORTED
* SYSTEM_ERR
* INVALID_STATE
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
* See also: RIL_REQUEST_CANCEL_USSD, RIL_UNSOL_ON_USSD
*/
#define RIL_REQUEST_SEND_USSD 29
/**
* RIL_REQUEST_CANCEL_USSD
*
* Cancel the current USSD session if one exists
*
* "data" is null
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SIM_BUSY
* OPERATION_NOT_ALLOWED
* MODEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* INVALID_STATE
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_CANCEL_USSD 30
/**
* RIL_REQUEST_GET_CLIR
*
* Gets current CLIR status
* "data" is NULL
* "response" is int *
* ((int *)data)[0] is "n" parameter from TS 27.007 7.7
* ((int *)data)[1] is "m" parameter from TS 27.007 7.7
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SS_MODIFIED_TO_DIAL
* SS_MODIFIED_TO_USSD
* SS_MODIFIED_TO_SS
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* FDN_CHECK_FAILURE
* SYSTEM_ERR
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_GET_CLIR 31
/**
* RIL_REQUEST_SET_CLIR
*
* "data" is int *
* ((int *)data)[0] is "n" parameter from TS 27.007 7.7
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SS_MODIFIED_TO_DIAL
* SS_MODIFIED_TO_USSD
* SS_MODIFIED_TO_SS
* INVALID_ARGUMENTS
* SYSTEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SET_CLIR 32
/**
* RIL_REQUEST_QUERY_CALL_FORWARD_STATUS
*
* "data" is const RIL_CallForwardInfo *
*
* "response" is const RIL_CallForwardInfo **
* "response" points to an array of RIL_CallForwardInfo *'s, one for
* each distinct registered phone number.
*
* For example, if data is forwarded to +18005551212 and voice is forwarded
* to +18005559999, then two separate RIL_CallForwardInfo's should be returned
*
* If, however, both data and voice are forwarded to +18005551212, then
* a single RIL_CallForwardInfo can be returned with the service class
* set to "data + voice = 3")
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SS_MODIFIED_TO_DIAL
* SS_MODIFIED_TO_USSD
* SS_MODIFIED_TO_SS
* INVALID_ARGUMENTS
* NO_MEMORY
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* FDN_CHECK_FAILURE
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_QUERY_CALL_FORWARD_STATUS 33
/**
* RIL_REQUEST_SET_CALL_FORWARD
*
* Configure call forward rule
*
* "data" is const RIL_CallForwardInfo *
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SS_MODIFIED_TO_DIAL
* SS_MODIFIED_TO_USSD
* SS_MODIFIED_TO_SS
* INVALID_ARGUMENTS
* NO_MEMORY
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* INVALID_STATE
* FDN_CHECK_FAILURE
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SET_CALL_FORWARD 34
/**
* RIL_REQUEST_QUERY_CALL_WAITING
*
* Query current call waiting state
*
* "data" is const int *
* ((const int *)data)[0] is the TS 27.007 service class to query.
* "response" is a const int *
* ((const int *)response)[0] is 0 for "disabled" and 1 for "enabled"
*
* If ((const int *)response)[0] is = 1, then ((const int *)response)[1]
* must follow, with the TS 27.007 service class bit vector of services
* for which call waiting is enabled.
*
* For example, if ((const int *)response)[0] is 1 and
* ((const int *)response)[1] is 3, then call waiting is enabled for data
* and voice and disabled for everything else
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SS_MODIFIED_TO_DIAL
* SS_MODIFIED_TO_USSD
* SS_MODIFIED_TO_SS
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* FDN_CHECK_FAILURE
* INVALID_ARGUMENTS
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_QUERY_CALL_WAITING 35
/**
* RIL_REQUEST_SET_CALL_WAITING
*
* Configure current call waiting state
*
* "data" is const int *
* ((const int *)data)[0] is 0 for "disabled" and 1 for "enabled"
* ((const int *)data)[1] is the TS 27.007 service class bit vector of
* services to modify
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SS_MODIFIED_TO_DIAL
* SS_MODIFIED_TO_USSD
* SS_MODIFIED_TO_SS
* INVALID_ARGUMENTS
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* INVALID_STATE
* FDN_CHECK_FAILURE
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SET_CALL_WAITING 36
/**
* RIL_REQUEST_SMS_ACKNOWLEDGE
*
* Acknowledge successful or failed receipt of SMS previously indicated
* via RIL_UNSOL_RESPONSE_NEW_SMS
*
* "data" is int *
* ((int *)data)[0] is 1 on successful receipt
* (basically, AT+CNMA=1 from TS 27.005
* is 0 on failed receipt
* (basically, AT+CNMA=2 from TS 27.005)
* ((int *)data)[1] if data[0] is 0, this contains the failure cause as defined
* in TS 23.040, 9.2.3.22. Currently only 0xD3 (memory
* capacity exceeded) and 0xFF (unspecified error) are
* reported.
*
* "response" is NULL
*
* FIXME would like request that specified RP-ACK/RP-ERROR PDU
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SMS_ACKNOWLEDGE 37
/**
* RIL_REQUEST_GET_IMEI - DEPRECATED
*
* Get the device IMEI, including check digit
*
* The request is DEPRECATED, use RIL_REQUEST_DEVICE_IDENTITY
* Valid when RadioState is not RADIO_STATE_UNAVAILABLE
*
* "data" is NULL
* "response" is a const char * containing the IMEI
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* NOT_PROVISIONED
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_GET_IMEI 38
/**
* RIL_REQUEST_GET_IMEISV - DEPRECATED
*
* Get the device IMEISV, which should be two decimal digits
*
* The request is DEPRECATED, use RIL_REQUEST_DEVICE_IDENTITY
* Valid when RadioState is not RADIO_STATE_UNAVAILABLE
*
* "data" is NULL
* "response" is a const char * containing the IMEISV
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* NOT_PROVISIONED
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_GET_IMEISV 39
/**
* RIL_REQUEST_ANSWER
*
* Answer incoming call
*
* Will not be called for WAITING calls.
* RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE will be used in this case
* instead
*
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INVALID_STATE
* NO_MEMORY
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* INVALID_CALL_ID
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_ANSWER 40
/**
* RIL_REQUEST_DEACTIVATE_DATA_CALL
*
* Deactivate packet data connection and remove from the
* data call list if SUCCESS is returned. Any other return
* values should also try to remove the call from the list,
* but that may not be possible. In any event a
* RIL_REQUEST_RADIO_POWER off/on must clear the list. An
* RIL_UNSOL_DATA_CALL_LIST_CHANGED is not expected to be
* issued because of an RIL_REQUEST_DEACTIVATE_DATA_CALL.
*
* "data" is const char **
* ((char**)data)[0] indicating CID
* ((char**)data)[1] indicating Disconnect Reason
* 0 => No specific reason specified
* 1 => Radio shutdown requested
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_CALL_ID
* INVALID_STATE
* INVALID_ARGUMENTS
* REQUEST_NOT_SUPPORTED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* SIM_ABSENT
*
* See also: RIL_REQUEST_SETUP_DATA_CALL
*/
#define RIL_REQUEST_DEACTIVATE_DATA_CALL 41
/**
* RIL_REQUEST_QUERY_FACILITY_LOCK
*
* Query the status of a facility lock state
*
* "data" is const char **
* ((const char **)data)[0] is the facility string code from TS 27.007 7.4
* (eg "AO" for BAOC, "SC" for SIM lock)
* ((const char **)data)[1] is the password, or "" if not required
* ((const char **)data)[2] is the TS 27.007 service class bit vector of
* services to query
* ((const char **)data)[3] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
* This is only applicable in the case of Fixed Dialing Numbers
* (FDN) requests.
*
* "response" is an int *
* ((const int *)response) 0 is the TS 27.007 service class bit vector of
* services for which the specified barring facility
* is active. "0" means "disabled for all"
*
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SS_MODIFIED_TO_DIAL
* SS_MODIFIED_TO_USSD
* SS_MODIFIED_TO_SS
* INVALID_ARGUMENTS
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* FDN_CHECK_FAILURE
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_QUERY_FACILITY_LOCK 42
/**
* RIL_REQUEST_SET_FACILITY_LOCK
*
* Enable/disable one facility lock
*
* "data" is const char **
*
* ((const char **)data)[0] = facility string code from TS 27.007 7.4
* (eg "AO" for BAOC)
* ((const char **)data)[1] = "0" for "unlock" and "1" for "lock"
* ((const char **)data)[2] = password
* ((const char **)data)[3] = string representation of decimal TS 27.007
* service class bit vector. Eg, the string
* "1" means "set this facility for voice services"
* ((const char **)data)[4] = AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
* This is only applicable in the case of Fixed Dialing Numbers
* (FDN) requests.
*
* "response" is int *
* ((int *)response)[0] is the number of retries remaining, or -1 if unknown
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SS_MODIFIED_TO_DIAL
* SS_MODIFIED_TO_USSD
* SS_MODIFIED_TO_SS
* INVALID_ARGUMENTS
* INTERNAL_ERR
* NO_MEMORY
* MODEM_ERR
* INVALID_STATE
* FDN_CHECK_FAILURE
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_SET_FACILITY_LOCK 43
/**
* RIL_REQUEST_CHANGE_BARRING_PASSWORD
*
* Change call barring facility password
*
* "data" is const char **
*
* ((const char **)data)[0] = facility string code from TS 27.007 7.4
* (eg "AO" for BAOC)
* ((const char **)data)[1] = old password
* ((const char **)data)[2] = new password
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SS_MODIFIED_TO_DIAL
* SS_MODIFIED_TO_USSD
* SS_MODIFIED_TO_SS
* INVALID_ARGUMENTS
* NO_MEMORY
* MODEM_ERR
* INTERNAL_ERR
* SYSTEM_ERR
* FDN_CHECK_FAILURE
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_CHANGE_BARRING_PASSWORD 44
/**
* RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE
*
* Query current network selectin mode
*
* "data" is NULL
*
* "response" is int *
* ((const int *)response)[0] is
* 0 for automatic selection
* 1 for manual selection
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE 45
/**
* RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC
*
* Specify that the network should be selected automatically
*
* "data" is NULL
* "response" is NULL
*
* This request must not respond until the new operator is selected
* and registered
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* ILLEGAL_SIM_OR_ME
* OPERATION_NOT_ALLOWED
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
* Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and
* no retries needed, such as illegal SIM or ME.
*
*/
#define RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC 46
/**
* RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL
*
* Manually select a specified network.
*
* "data" is const char * specifying MCCMNC of network to select (eg "310170")
* "response" is NULL
*
* This request must not respond until the new operator is selected
* and registered
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* ILLEGAL_SIM_OR_ME
* OPERATION_NOT_ALLOWED
* INVALID_STATE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
* Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and
* no retries needed, such as illegal SIM or ME.
*
*/
#define RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL 47
/**
* RIL_REQUEST_QUERY_AVAILABLE_NETWORKS
*
* Scans for available networks
*
* "data" is NULL
* "response" is const char ** that should be an array of n*4 strings, where
* n is the number of available networks
* For each available network:
*
* ((const char **)response)[n+0] is long alpha ONS or EONS
* ((const char **)response)[n+1] is short alpha ONS or EONS
* ((const char **)response)[n+2] is 5 or 6 digit numeric code (MCC + MNC)
* ((const char **)response)[n+3] is a string value of the status:
* "unknown"
* "available"
* "current"
* "forbidden"
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* OPERATION_NOT_ALLOWED
* ABORTED
* DEVICE_IN_USE
* INTERNAL_ERR
* NO_MEMORY
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* CANCELLED
* OPERATION_NOT_ALLOWED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_QUERY_AVAILABLE_NETWORKS 48
/**
* RIL_REQUEST_DTMF_START
*
* Start playing a DTMF tone. Continue playing DTMF tone until
* RIL_REQUEST_DTMF_STOP is received
*
* If a RIL_REQUEST_DTMF_START is received while a tone is currently playing,
* it should cancel the previous tone and play the new one.
*
* "data" is a char *
* ((char *)data)[0] is a single character with one of 12 values: 0-9,*,#
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_ARGUMENTS
* NO_RESOURCES
* NO_MEMORY
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* INVALID_CALL_ID
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*
* See also: RIL_REQUEST_DTMF, RIL_REQUEST_DTMF_STOP
*/
#define RIL_REQUEST_DTMF_START 49
/**
* RIL_REQUEST_DTMF_STOP
*
* Stop playing a currently playing DTMF tone.
*
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* OPERATION_NOT_ALLOWED
* NO_RESOURCES
* NO_MEMORY
* INVALID_ARGUMENTS
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* INVALID_CALL_ID
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*
* See also: RIL_REQUEST_DTMF, RIL_REQUEST_DTMF_START
*/
#define RIL_REQUEST_DTMF_STOP 50
/**
* RIL_REQUEST_BASEBAND_VERSION
*
* Return string value indicating baseband version, eg
* response from AT+CGMR
*
* "data" is NULL
* "response" is const char * containing version string for log reporting
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* EMPTY_RECORD
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* NOT_PROVISIONED
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_BASEBAND_VERSION 51
/**
* RIL_REQUEST_SEPARATE_CONNECTION
*
* Separate a party from a multiparty call placing the multiparty call
* (less the specified party) on hold and leaving the specified party
* as the only other member of the current (active) call
*
* Like AT+CHLD=2x
*
* See TS 22.084 1.3.8.2 (iii)
* TS 22.030 6.5.5 "Entering "2X followed by send"
* TS 27.007 "AT+CHLD=2x"
*
* "data" is an int *
* (int *)data)[0] contains Connection index (value of 'x' in CHLD above) "response" is NULL
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INVALID_ARGUMENTS
* INVALID_STATE
* NO_RESOURCES
* NO_MEMORY
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* INVALID_CALL_ID
* INVALID_STATE
* OPERATION_NOT_ALLOWED
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SEPARATE_CONNECTION 52
/**
* RIL_REQUEST_SET_MUTE
*
* Turn on or off uplink (microphone) mute.
*
* Will only be sent while voice call is active.
* Will always be reset to "disable mute" when a new voice call is initiated
*
* "data" is an int *
* (int *)data)[0] is 1 for "enable mute" and 0 for "disable mute"
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INVALID_ARGUMENTS
* NO_MEMORY
* REQUEST_RATE_LIMITED
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SET_MUTE 53
/**
* RIL_REQUEST_GET_MUTE
*
* Queries the current state of the uplink mute setting
*
* "data" is NULL
* "response" is an int *
* (int *)response)[0] is 1 for "mute enabled" and 0 for "mute disabled"
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* SS_MODIFIED_TO_DIAL
* SS_MODIFIED_TO_USSD
* SS_MODIFIED_TO_SS
* NO_MEMORY
* REQUEST_RATE_LIMITED
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_GET_MUTE 54
/**
* RIL_REQUEST_QUERY_CLIP
*
* Queries the status of the CLIP supplementary service
*
* (for MMI code "*#30#")
*
* "data" is NULL
* "response" is an int *
* (int *)response)[0] is 1 for "CLIP provisioned"
* and 0 for "CLIP not provisioned"
* and 2 for "unknown, e.g. no network etc"
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* NO_MEMORY
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* FDN_CHECK_FAILURE
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_QUERY_CLIP 55
/**
* RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE - Deprecated use the status
* field in RIL_Data_Call_Response_v6.
*
* Requests the failure cause code for the most recently failed PDP
* context or CDMA data connection active
* replaces RIL_REQUEST_LAST_PDP_FAIL_CAUSE
*
* "data" is NULL
*
* "response" is a "int *"
* ((int *)response)[0] is an integer cause code defined in TS 24.008
* section 6.1.3.1.3 or close approximation
*
* If the implementation does not have access to the exact cause codes,
* then it should return one of the values listed in
* RIL_DataCallFailCause, as the UI layer needs to distinguish these
* cases for error notification
* and potential retries.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
* See also: RIL_REQUEST_LAST_CALL_FAIL_CAUSE
*
* Deprecated use the status field in RIL_Data_Call_Response_v6.
*/
#define RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE 56
/**
* RIL_REQUEST_DATA_CALL_LIST
*
* Returns the data call list. An entry is added when a
* RIL_REQUEST_SETUP_DATA_CALL is issued and removed on a
* RIL_REQUEST_DEACTIVATE_DATA_CALL. The list is emptied
* when RIL_REQUEST_RADIO_POWER off/on is issued.
*
* "data" is NULL
* "response" is an array of RIL_Data_Call_Response_v6
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*
* See also: RIL_UNSOL_DATA_CALL_LIST_CHANGED
*/
#define RIL_REQUEST_DATA_CALL_LIST 57
/**
* RIL_REQUEST_RESET_RADIO - DEPRECATED
*
* Request a radio reset. The RIL implementation may postpone
* the reset until after this request is responded to if the baseband
* is presently busy.
*
* The request is DEPRECATED, use RIL_REQUEST_RADIO_POWER
*
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_RESET_RADIO 58
/**
* RIL_REQUEST_OEM_HOOK_RAW
*
* This request reserved for OEM-specific uses. It passes raw byte arrays
* back and forth.
*
* It can be invoked on the Java side from
* com.android.internal.telephony.Phone.invokeOemRilRequestRaw()
*
* "data" is a char * of bytes copied from the byte[] data argument in java
* "response" is a char * of bytes that will returned via the
* caller's "response" Message here:
* (byte[])(((AsyncResult)response.obj).result)
*
* An error response here will result in
* (((AsyncResult)response.obj).result) == null and
* (((AsyncResult)response.obj).exception) being an instance of
* com.android.internal.telephony.gsm.CommandException
*
* Valid errors:
* All
*/
#define RIL_REQUEST_OEM_HOOK_RAW 59
/**
* RIL_REQUEST_OEM_HOOK_STRINGS
*
* This request reserved for OEM-specific uses. It passes strings
* back and forth.
*
* It can be invoked on the Java side from
* com.android.internal.telephony.Phone.invokeOemRilRequestStrings()
*
* "data" is a const char **, representing an array of null-terminated UTF-8
* strings copied from the "String[] strings" argument to
* invokeOemRilRequestStrings()
*
* "response" is a const char **, representing an array of null-terminated UTF-8
* stings that will be returned via the caller's response message here:
*
* (String[])(((AsyncResult)response.obj).result)
*
* An error response here will result in
* (((AsyncResult)response.obj).result) == null and
* (((AsyncResult)response.obj).exception) being an instance of
* com.android.internal.telephony.gsm.CommandException
*
* Valid errors:
* All
*/
#define RIL_REQUEST_OEM_HOOK_STRINGS 60
/**
* RIL_REQUEST_SCREEN_STATE - DEPRECATED
*
* Indicates the current state of the screen. When the screen is off, the
* RIL should notify the baseband to suppress certain notifications (eg,
* signal strength and changes in LAC/CID or BID/SID/NID/latitude/longitude)
* in an effort to conserve power. These notifications should resume when the
* screen is on.
*
* Note this request is deprecated. Use RIL_REQUEST_SEND_DEVICE_STATE to report the device state
* to the modem and use RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER to turn on/off unsolicited
* response from the modem in different scenarios.
*
* "data" is int *
* ((int *)data)[0] is == 1 for "Screen On"
* ((int *)data)[0] is == 0 for "Screen Off"
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SCREEN_STATE 61
/**
* RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION
*
* Enables/disables supplementary service related notifications
* from the network.
*
* Notifications are reported via RIL_UNSOL_SUPP_SVC_NOTIFICATION.
*
* "data" is int *
* ((int *)data)[0] is == 1 for notifications enabled
* ((int *)data)[0] is == 0 for notifications disabled
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SIM_BUSY
* INVALID_ARGUMENTS
* NO_MEMORY
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
* See also: RIL_UNSOL_SUPP_SVC_NOTIFICATION.
*/
#define RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION 62
/**
* RIL_REQUEST_WRITE_SMS_TO_SIM
*
* Stores a SMS message to SIM memory.
*
* "data" is RIL_SMS_WriteArgs *
*
* "response" is int *
* ((const int *)response)[0] is the record index where the message is stored.
*
* Valid errors:
* SUCCESS
* SIM_FULL
* INVALID_ARGUMENTS
* INVALID_SMS_FORMAT
* INTERNAL_ERR
* MODEM_ERR
* ENCODING_ERR
* NO_MEMORY
* NO_RESOURCES
* INVALID_MODEM_STATE
* OPERATION_NOT_ALLOWED
* INVALID_SMSC_ADDRESS
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*
*/
#define RIL_REQUEST_WRITE_SMS_TO_SIM 63
/**
* RIL_REQUEST_DELETE_SMS_ON_SIM
*
* Deletes a SMS message from SIM memory.
*
* "data" is int *
* ((int *)data)[0] is the record index of the message to delete.
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* SIM_FULL
* INVALID_ARGUMENTS
* NO_MEMORY
* REQUEST_RATE_LIMITED
* SYSTEM_ERR
* MODEM_ERR
* NO_SUCH_ENTRY
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*
*/
#define RIL_REQUEST_DELETE_SMS_ON_SIM 64
/**
* RIL_REQUEST_SET_BAND_MODE
*
* Assign a specified band for RF configuration.
*
* "data" is int *
* ((int *)data)[0] is a RIL_RadioBandMode
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* OPERATION_NOT_ALLOWED
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
* See also: RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE
*/
#define RIL_REQUEST_SET_BAND_MODE 65
/**
* RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE
*
* Query the list of band mode supported by RF.
*
* "data" is NULL
*
* "response" is int *
* "response" points to an array of int's, the int[0] is the size of array;
* subsequent values are a list of RIL_RadioBandMode listing supported modes.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
* See also: RIL_REQUEST_SET_BAND_MODE
*/
#define RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE 66
/**
* RIL_REQUEST_STK_GET_PROFILE
*
* Requests the profile of SIM tool kit.
* The profile indicates the SAT/USAT features supported by ME.
* The SAT/USAT features refer to 3GPP TS 11.14 and 3GPP TS 31.111
*
* "data" is NULL
*
* "response" is a const char * containing SAT/USAT profile
* in hexadecimal format string starting with first byte of terminal profile
*
* Valid errors:
* RIL_E_SUCCESS
* RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_STK_GET_PROFILE 67
/**
* RIL_REQUEST_STK_SET_PROFILE
*
* Download the STK terminal profile as part of SIM initialization
* procedure
*
* "data" is a const char * containing SAT/USAT profile
* in hexadecimal format string starting with first byte of terminal profile
*
* "response" is NULL
*
* Valid errors:
* RIL_E_SUCCESS
* RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_STK_SET_PROFILE 68
/**
* RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND
*
* Requests to send a SAT/USAT envelope command to SIM.
* The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111
*
* "data" is a const char * containing SAT/USAT command
* in hexadecimal format string starting with command tag
*
* "response" is a const char * containing SAT/USAT response
* in hexadecimal format string starting with first byte of response
* (May be NULL)
*
* Valid errors:
* RIL_E_SUCCESS
* RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
* SIM_BUSY
* OPERATION_NOT_ALLOWED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND 69
/**
* RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE
*
* Requests to send a terminal response to SIM for a received
* proactive command
*
* "data" is a const char * containing SAT/USAT response
* in hexadecimal format string starting with first byte of response data
*
* "response" is NULL
*
* Valid errors:
* RIL_E_SUCCESS
* RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
* RIL_E_OPERATION_NOT_ALLOWED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE 70
/**
* RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM
*
* When STK application gets RIL_UNSOL_STK_CALL_SETUP, the call actually has
* been initialized by ME already. (We could see the call has been in the 'call
* list') So, STK application needs to accept/reject the call according as user
* operations.
*
* "data" is int *
* ((int *)data)[0] is > 0 for "accept" the call setup
* ((int *)data)[0] is == 0 for "reject" the call setup
*
* "response" is NULL
*
* Valid errors:
* RIL_E_SUCCESS
* RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
* RIL_E_OPERATION_NOT_ALLOWED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM 71
/**
* RIL_REQUEST_EXPLICIT_CALL_TRANSFER
*
* Connects the two calls and disconnects the subscriber from both calls.
*
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* INVALID_STATE
* NO_RESOURCES
* NO_MEMORY
* INVALID_ARGUMENTS
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* INVALID_CALL_ID
* INVALID_STATE
* OPERATION_NOT_ALLOWED
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_EXPLICIT_CALL_TRANSFER 72
/**
* RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE
*
* Requests to set the preferred network type for searching and registering
* (CS/PS domain, RAT, and operation mode)
*
* "data" is int * which is RIL_PreferredNetworkType
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* OPERATION_NOT_ALLOWED
* MODE_NOT_SUPPORTED
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE 73
/**
* RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE
*
* Query the preferred network type (CS/PS domain, RAT, and operation mode)
* for searching and registering
*
* "data" is NULL
*
* "response" is int *
* ((int *)reponse)[0] is == RIL_PreferredNetworkType
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
* See also: RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE
*/
#define RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE 74
/**
* RIL_REQUEST_NEIGHBORING_CELL_IDS
*
* Request neighboring cell id in GSM network
*
* "data" is NULL
* "response" must be a " const RIL_NeighboringCell** "
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* NO_NETWORK_FOUND
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_GET_NEIGHBORING_CELL_IDS 75
/**
* RIL_REQUEST_SET_LOCATION_UPDATES
*
* Enables/disables network state change notifications due to changes in
* LAC and/or CID (for GSM) or BID/SID/NID/latitude/longitude (for CDMA).
* Basically +CREG=2 vs. +CREG=1 (TS 27.007).
*
* Note: The RIL implementation should default to "updates enabled"
* when the screen is on and "updates disabled" when the screen is off.
*
* "data" is int *
* ((int *)data)[0] is == 1 for updates enabled (+CREG=2)
* ((int *)data)[0] is == 0 for updates disabled (+CREG=1)
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
* See also: RIL_REQUEST_SCREEN_STATE, RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED
*/
#define RIL_REQUEST_SET_LOCATION_UPDATES 76
/**
* RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE
*
* Request to set the location where the CDMA subscription shall
* be retrieved
*
* "data" is int *
* ((int *)data)[0] is == RIL_CdmaSubscriptionSource
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SIM_ABSENT
* SUBSCRIPTION_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
* See also: RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE
*/
#define RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE 77
/**
* RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE
*
* Request to set the roaming preferences in CDMA
*
* "data" is int *
* ((int *)data)[0] is == 0 for Home Networks only, as defined in PRL
* ((int *)data)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL
* ((int *)data)[0] is == 2 for Roaming on Any Network, as defined in the PRL
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* OPERATION_NOT_ALLOWED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE 78
/**
* RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE
*
* Request the actual setting of the roaming preferences in CDMA in the modem
*
* "data" is NULL
*
* "response" is int *
* ((int *)response)[0] is == 0 for Home Networks only, as defined in PRL
* ((int *)response)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL
* ((int *)response)[0] is == 2 for Roaming on Any Network, as defined in the PRL
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE 79
/**
* RIL_REQUEST_SET_TTY_MODE
*
* Request to set the TTY mode
*
* "data" is int *
* ((int *)data)[0] is == 0 for TTY off
* ((int *)data)[0] is == 1 for TTY Full
* ((int *)data)[0] is == 2 for TTY HCO (hearing carryover)
* ((int *)data)[0] is == 3 for TTY VCO (voice carryover)
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_ARGUMENTS
* MODEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* INVALID_ARGUMENTS
* MODEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SET_TTY_MODE 80
/**
* RIL_REQUEST_QUERY_TTY_MODE
*
* Request the setting of TTY mode
*
* "data" is NULL
*
* "response" is int *
* ((int *)response)[0] is == 0 for TTY off
* ((int *)response)[0] is == 1 for TTY Full
* ((int *)response)[0] is == 2 for TTY HCO (hearing carryover)
* ((int *)response)[0] is == 3 for TTY VCO (voice carryover)
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* MODEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* INVALID_ARGUMENTS
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_QUERY_TTY_MODE 81
/**
* RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE
*
* Request to set the preferred voice privacy mode used in voice
* scrambling
*
* "data" is int *
* ((int *)data)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask)
* ((int *)data)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask)
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_ARGUMENTS
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* INVALID_CALL_ID
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE 82
/**
* RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE
*
* Request the setting of preferred voice privacy mode
*
* "data" is NULL
*
* "response" is int *
* ((int *)response)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask)
* ((int *)response)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask)
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* MODEM_ERR
* INTERNAL_ERR
* NO_MEMORY
* INVALID_ARGUMENTS
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE 83
/**
* RIL_REQUEST_CDMA_FLASH
*
* Send FLASH
*
* "data" is const char *
* ((const char *)data)[0] is a FLASH string
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_ARGUMENTS
* NO_MEMORY
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* INVALID_CALL_ID
* INVALID_STATE
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_CDMA_FLASH 84
/**
* RIL_REQUEST_CDMA_BURST_DTMF
*
* Send DTMF string
*
* "data" is const char **
* ((const char **)data)[0] is a DTMF string
* ((const char **)data)[1] is the DTMF ON length in milliseconds, or 0 to use
* default
* ((const char **)data)[2] is the DTMF OFF length in milliseconds, or 0 to use
* default
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_ARGUMENTS
* NO_MEMORY
* SYSTEM_ERR
* MODEM_ERR
* INTERNAL_ERR
* INVALID_CALL_ID
* NO_RESOURCES
* CANCELLED
* OPERATION_NOT_ALLOWED
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_CDMA_BURST_DTMF 85
/**
* RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY
*
* Takes a 26 digit string (20 digit AKEY + 6 digit checksum).
* If the checksum is valid the 20 digit AKEY is written to NV,
* replacing the existing AKEY no matter what it was before.
*
* "data" is const char *
* ((const char *)data)[0] is a 26 digit string (ASCII digits '0'-'9')
* where the last 6 digits are a checksum of the
* first 20, as specified in TR45.AHAG
* "Common Cryptographic Algorithms, Revision D.1
* Section 2.2"
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY 86
/**
* RIL_REQUEST_CDMA_SEND_SMS
*
* Send a CDMA SMS message
*
* "data" is const RIL_CDMA_SMS_Message *
*
* "response" is a const RIL_SMS_Response *
*
* Based on the return error, caller decides to resend if sending sms
* fails. The CDMA error class is derived as follows,
* SUCCESS is error class 0 (no error)
* SMS_SEND_FAIL_RETRY is error class 2 (temporary failure)
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SMS_SEND_FAIL_RETRY
* NETWORK_REJECT
* INVALID_STATE
* INVALID_ARGUMENTS
* NO_MEMORY
* REQUEST_RATE_LIMITED
* INVALID_SMS_FORMAT
* SYSTEM_ERR
* FDN_CHECK_FAILURE
* MODEM_ERR
* NETWORK_ERR
* ENCODING_ERR
* INVALID_SMSC_ADDRESS
* OPERATION_NOT_ALLOWED
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
* MODE_NOT_SUPPORTED
* SIM_ABSENT
*
*/
#define RIL_REQUEST_CDMA_SEND_SMS 87
/**
* RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE
*
* Acknowledge the success or failure in the receipt of SMS
* previously indicated via RIL_UNSOL_RESPONSE_CDMA_NEW_SMS
*
* "data" is const RIL_CDMA_SMS_Ack *
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_ARGUMENTS
* NO_SMS_TO_ACK
* INVALID_STATE
* NO_MEMORY
* REQUEST_RATE_LIMITED
* SYSTEM_ERR
* MODEM_ERR
* INVALID_STATE
* OPERATION_NOT_ALLOWED
* NETWORK_NOT_READY
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE 88
/**
* RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG
*
* Request the setting of GSM/WCDMA Cell Broadcast SMS config.
*
* "data" is NULL
*
* "response" is a const RIL_GSM_BroadcastSmsConfigInfo **
* "responselen" is count * sizeof (RIL_GSM_BroadcastSmsConfigInfo *)
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_STATE
* NO_MEMORY
* REQUEST_RATE_LIMITED
* SYSTEM_ERR
* NO_RESOURCES
* MODEM_ERR
* SYSTEM_ERR
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG 89
/**
* RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG
*
* Set GSM/WCDMA Cell Broadcast SMS config
*
* "data" is a const RIL_GSM_BroadcastSmsConfigInfo **
* "datalen" is count * sizeof(RIL_GSM_BroadcastSmsConfigInfo *)
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_STATE
* INVALID_ARGUMENTS
* NO_MEMORY
* SYSTEM_ERR
* REQUEST_RATE_LIMITED
* MODEM_ERR
* SYSTEM_ERR
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG 90
/**
* RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION
*
* Enable or disable the reception of GSM/WCDMA Cell Broadcast SMS
*
* "data" is const int *
* (const int *)data[0] indicates to activate or turn off the
* reception of GSM/WCDMA Cell Broadcast SMS, 0-1,
* 0 - Activate, 1 - Turn off
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_STATE
* INVALID_ARGUMENTS
* NO_MEMORY
* SYSTEM_ERR
* REQUEST_RATE_LIMITED
* MODEM_ERR
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION 91
/**
* RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG
*
* Request the setting of CDMA Broadcast SMS config
*
* "data" is NULL
*
* "response" is a const RIL_CDMA_BroadcastSmsConfigInfo **
* "responselen" is count * sizeof (RIL_CDMA_BroadcastSmsConfigInfo *)
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_STATE
* NO_MEMORY
* REQUEST_RATE_LIMITED
* SYSTEM_ERR
* NO_RESOURCES
* MODEM_ERR
* SYSTEM_ERR
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG 92
/**
* RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG
*
* Set CDMA Broadcast SMS config
*
* "data" is a const RIL_CDMA_BroadcastSmsConfigInfo **
* "datalen" is count * sizeof(const RIL_CDMA_BroadcastSmsConfigInfo *)
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_STATE
* INVALID_ARGUMENTS
* NO_MEMORY
* SYSTEM_ERR
* REQUEST_RATE_LIMITED
* MODEM_ERR
* SYSTEM_ERR
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG 93
/**
* RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION
*
* Enable or disable the reception of CDMA Broadcast SMS
*
* "data" is const int *
* (const int *)data[0] indicates to activate or turn off the
* reception of CDMA Broadcast SMS, 0-1,
* 0 - Activate, 1 - Turn off
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_STATE
* INVALID_ARGUMENTS
* NO_MEMORY
* SYSTEM_ERR
* REQUEST_RATE_LIMITED
* MODEM_ERR
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION 94
/**
* RIL_REQUEST_CDMA_SUBSCRIPTION
*
* Request the device MDN / H_SID / H_NID.
*
* The request is only allowed when CDMA subscription is available. When CDMA
* subscription is changed, application layer should re-issue the request to
* update the subscription information.
*
* If a NULL value is returned for any of the device id, it means that error
* accessing the device.
*
* "response" is const char **
* ((const char **)response)[0] is MDN if CDMA subscription is available
* ((const char **)response)[1] is a comma separated list of H_SID (Home SID) if
* CDMA subscription is available, in decimal format
* ((const char **)response)[2] is a comma separated list of H_NID (Home NID) if
* CDMA subscription is available, in decimal format
* ((const char **)response)[3] is MIN (10 digits, MIN2+MIN1) if CDMA subscription is available
* ((const char **)response)[4] is PRL version if CDMA subscription is available
*
* Valid errors:
* SUCCESS
* RIL_E_SUBSCRIPTION_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* NOT_PROVISIONED
* REQUEST_NOT_SUPPORTED
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_CDMA_SUBSCRIPTION 95
/**
* RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM
*
* Stores a CDMA SMS message to RUIM memory.
*
* "data" is RIL_CDMA_SMS_WriteArgs *
*
* "response" is int *
* ((const int *)response)[0] is the record index where the message is stored.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SIM_FULL
* INVALID_ARGUMENTS
* INVALID_SMS_FORMAT
* INTERNAL_ERR
* MODEM_ERR
* ENCODING_ERR
* NO_MEMORY
* NO_RESOURCES
* INVALID_MODEM_STATE
* OPERATION_NOT_ALLOWED
* INVALID_SMSC_ADDRESS
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*
*/
#define RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM 96
/**
* RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM
*
* Deletes a CDMA SMS message from RUIM memory.
*
* "data" is int *
* ((int *)data)[0] is the record index of the message to delete.
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_ARGUMENTS
* NO_MEMORY
* REQUEST_RATE_LIMITED
* SYSTEM_ERR
* MODEM_ERR
* NO_SUCH_ENTRY
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*/
#define RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM 97
/**
* RIL_REQUEST_DEVICE_IDENTITY
*
* Request the device ESN / MEID / IMEI / IMEISV.
*
* The request is always allowed and contains GSM and CDMA device identity;
* it substitutes the deprecated requests RIL_REQUEST_GET_IMEI and
* RIL_REQUEST_GET_IMEISV.
*
* If a NULL value is returned for any of the device id, it means that error
* accessing the device.
*
* When CDMA subscription is changed the ESN/MEID may change. The application
* layer should re-issue the request to update the device identity in this case.
*
* "response" is const char **
* ((const char **)response)[0] is IMEI if GSM subscription is available
* ((const char **)response)[1] is IMEISV if GSM subscription is available
* ((const char **)response)[2] is ESN if CDMA subscription is available
* ((const char **)response)[3] is MEID if CDMA subscription is available
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* NOT_PROVISIONED
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_DEVICE_IDENTITY 98
/**
* RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE
*
* Request the radio's system selection module to exit emergency
* callback mode. RIL will not respond with SUCCESS until the modem has
* completely exited from Emergency Callback Mode.
*
* "data" is NULL
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* OPERATION_NOT_ALLOWED
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE 99
/**
* RIL_REQUEST_GET_SMSC_ADDRESS
*
* Queries the default Short Message Service Center address on the device.
*
* "data" is NULL
*
* "response" is const char * containing the SMSC address.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* REQUEST_RATE_LIMITED
* SYSTEM_ERR
* INTERNAL_ERR
* MODEM_ERR
* INVALID_ARGUMENTS
* INVALID_MODEM_STATE
* NOT_PROVISIONED
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*
*/
#define RIL_REQUEST_GET_SMSC_ADDRESS 100
/**
* RIL_REQUEST_SET_SMSC_ADDRESS
*
* Sets the default Short Message Service Center address on the device.
*
* "data" is const char * containing the SMSC address.
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_ARGUMENTS
* INVALID_SMS_FORMAT
* NO_MEMORY
* SYSTEM_ERR
* REQUEST_RATE_LIMITED
* MODEM_ERR
* NO_RESOURCES
* INTERNAL_ERR
* CANCELLED
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*/
#define RIL_REQUEST_SET_SMSC_ADDRESS 101
/**
* RIL_REQUEST_REPORT_SMS_MEMORY_STATUS
*
* Indicates whether there is storage available for new SMS messages.
*
* "data" is int *
* ((int *)data)[0] is 1 if memory is available for storing new messages
* is 0 if memory capacity is exceeded
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INVALID_ARGUMENTS
* NO_MEMORY
* INVALID_STATE
* SYSTEM_ERR
* REQUEST_RATE_LIMITED
* MODEM_ERR
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_REPORT_SMS_MEMORY_STATUS 102
/**
* RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING
*
* Indicates that the StkSerivce is running and is
* ready to receive RIL_UNSOL_STK_XXXXX commands.
*
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING 103
/**
* RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE
*
* Request to query the location where the CDMA subscription shall
* be retrieved
*
* "data" is NULL
*
* "response" is int *
* ((int *)data)[0] is == RIL_CdmaSubscriptionSource
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SUBSCRIPTION_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
* See also: RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE
*/
#define RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE 104
/**
* RIL_REQUEST_ISIM_AUTHENTICATION
*
* Request the ISIM application on the UICC to perform AKA
* challenge/response algorithm for IMS authentication
*
* "data" is a const char * containing the challenge string in Base64 format
* "response" is a const char * containing the response in Base64 format
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_ISIM_AUTHENTICATION 105
/**
* RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU
*
* Acknowledge successful or failed receipt of SMS previously indicated
* via RIL_UNSOL_RESPONSE_NEW_SMS, including acknowledgement TPDU to send
* as the RP-User-Data element of the RP-ACK or RP-ERROR PDU.
*
* "data" is const char **
* ((const char **)data)[0] is "1" on successful receipt (send RP-ACK)
* is "0" on failed receipt (send RP-ERROR)
* ((const char **)data)[1] is the acknowledgement TPDU in hexadecimal format
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU 106
/**
* RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS
*
* Requests to send a SAT/USAT envelope command to SIM.
* The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111.
*
* This request has one difference from RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND:
* the SW1 and SW2 status bytes from the UICC response are returned along with
* the response data, using the same structure as RIL_REQUEST_SIM_IO.
*
* The RIL implementation shall perform the normal processing of a '91XX'
* response in SW1/SW2 to retrieve the pending proactive command and send it
* as an unsolicited response, as RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND does.
*
* "data" is a const char * containing the SAT/USAT command
* in hexadecimal format starting with command tag
*
* "response" is a const RIL_SIM_IO_Response *
*
* Valid errors:
* RIL_E_SUCCESS
* RIL_E_RADIO_NOT_AVAILABLE (radio resetting)
* SIM_BUSY
* OPERATION_NOT_ALLOWED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*/
#define RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS 107
/**
* RIL_REQUEST_VOICE_RADIO_TECH
*
* Query the radio technology type (3GPP/3GPP2) used for voice. Query is valid only
* when radio state is not RADIO_STATE_UNAVAILABLE
*
* "data" is NULL
* "response" is int *
* ((int *) response)[0] is of type const RIL_RadioTechnology
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_VOICE_RADIO_TECH 108
/**
* RIL_REQUEST_GET_CELL_INFO_LIST
*
* Request all of the current cell information known to the radio. The radio
* must a list of all current cells, including the neighboring cells. If for a particular
* cell information isn't known then the appropriate unknown value will be returned.
* This does not cause or change the rate of RIL_UNSOL_CELL_INFO_LIST.
*
* "data" is NULL
*
* "response" is an array of RIL_CellInfo_v12.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* NO_NETWORK_FOUND
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_GET_CELL_INFO_LIST 109
/**
* RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE
*
* Sets the minimum time between when RIL_UNSOL_CELL_INFO_LIST should be invoked.
* A value of 0, means invoke RIL_UNSOL_CELL_INFO_LIST when any of the reported
* information changes. Setting the value to INT_MAX(0x7fffffff) means never issue
* a RIL_UNSOL_CELL_INFO_LIST.
*
* "data" is int *
* ((int *)data)[0] is minimum time in milliseconds
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE 110
/**
* RIL_REQUEST_SET_INITIAL_ATTACH_APN
*
* Set an apn to initial attach network
*
* "data" is a const char **
* ((const char **)data)[0] is the APN to connect if radio technology is LTE
* ((const char **)data)[1] is the connection type to request must be one of the
* PDP_type values in TS 27.007 section 10.1.1.
* For example, "IP", "IPV6", "IPV4V6", or "PPP".
* ((const char **)data)[2] is the PAP / CHAP auth type. Values:
* 0 => PAP and CHAP is never performed.
* 1 => PAP may be performed; CHAP is never performed.
* 2 => CHAP may be performed; PAP is never performed.
* 3 => PAP / CHAP may be performed - baseband dependent.
* ((const char **)data)[3] is the username for APN, or NULL
* ((const char **)data)[4] is the password for APN, or NULL
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* SUBSCRIPTION_NOT_AVAILABLE
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* NOT_PROVISIONED
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111
/**
* RIL_REQUEST_IMS_REGISTRATION_STATE
*
* This message is DEPRECATED and shall be removed in a future release (target: 2018);
* instead, provide IMS registration status via an IMS Service.
*
* Request current IMS registration state
*
* "data" is NULL
*
* "response" is int *
* ((int *)response)[0] is registration state:
* 0 - Not registered
* 1 - Registered
*
* If ((int*)response)[0] is = 1, then ((int *) response)[1]
* must follow with IMS SMS format:
*
* ((int *) response)[1] is of type RIL_RadioTechnologyFamily
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_IMS_REGISTRATION_STATE 112
/**
* RIL_REQUEST_IMS_SEND_SMS
*
* Send a SMS message over IMS
*
* "data" is const RIL_IMS_SMS_Message *
*
* "response" is a const RIL_SMS_Response *
*
* Based on the return error, caller decides to resend if sending sms
* fails. SMS_SEND_FAIL_RETRY means retry, and other errors means no retry.
* In case of retry, data is encoded based on Voice Technology available.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* SMS_SEND_FAIL_RETRY
* FDN_CHECK_FAILURE
* NETWORK_REJECT
* INVALID_ARGUMENTS
* INVALID_STATE
* NO_MEMORY
* INVALID_SMS_FORMAT
* SYSTEM_ERR
* REQUEST_RATE_LIMITED
* MODEM_ERR
* NETWORK_ERR
* ENCODING_ERR
* INVALID_SMSC_ADDRESS
* OPERATION_NOT_ALLOWED
* INTERNAL_ERR
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_IMS_SEND_SMS 113
/**
* RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC
*
* Request APDU exchange on the basic channel. This command reflects TS 27.007
* "generic SIM access" operation (+CSIM). The modem must ensure proper function
* of GSM/CDMA, and filter commands appropriately. It should filter
* channel management and SELECT by DF name commands.
*
* "data" is a const RIL_SIM_APDU *
* "sessionid" field should be ignored.
*
* "response" is a const RIL_SIM_IO_Response *
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC 114
/**
* RIL_REQUEST_SIM_OPEN_CHANNEL
*
* Open a new logical channel and select the given application. This command
* reflects TS 27.007 "open logical channel" operation (+CCHO). This request
* also specifies the P2 parameter (described in ISO 7816-4).
*
* "data" is a const RIL_OpenChannelParam *
*
* "response" is int *
* ((int *)data)[0] contains the session id of the logical channel.
* ((int *)data)[1] onwards may optionally contain the select response for the
* open channel command with one byte per integer.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* MISSING_RESOURCE
* NO_SUCH_ELEMENT
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* SIM_ERR
* INVALID_SIM_STATE
* MISSING_RESOURCE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SIM_OPEN_CHANNEL 115
/**
* RIL_REQUEST_SIM_CLOSE_CHANNEL
*
* Close a previously opened logical channel. This command reflects TS 27.007
* "close logical channel" operation (+CCHC).
*
* "data" is int *
* ((int *)data)[0] is the session id of logical the channel to close.
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SIM_CLOSE_CHANNEL 116
/**
* RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL
*
* Exchange APDUs with a UICC over a previously opened logical channel. This
* command reflects TS 27.007 "generic logical channel access" operation
* (+CGLA). The modem should filter channel management and SELECT by DF name
* commands.
*
* "data" is a const RIL_SIM_APDU*
*
* "response" is a const RIL_SIM_IO_Response *
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL 117
/**
* RIL_REQUEST_NV_READ_ITEM
*
* Read one of the radio NV items defined in RadioNVItems.java / ril_nv_items.h.
* This is used for device configuration by some CDMA operators.
*
* "data" is a const RIL_NV_ReadItem *
*
* "response" is const char * containing the contents of the NV item
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_NV_READ_ITEM 118
/**
* RIL_REQUEST_NV_WRITE_ITEM
*
* Write one of the radio NV items defined in RadioNVItems.java / ril_nv_items.h.
* This is used for device configuration by some CDMA operators.
*
* "data" is a const RIL_NV_WriteItem *
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_NV_WRITE_ITEM 119
/**
* RIL_REQUEST_NV_WRITE_CDMA_PRL
*
* Update the CDMA Preferred Roaming List (PRL) in the radio NV storage.
* This is used for device configuration by some CDMA operators.
*
* "data" is a const char * containing the PRL as a byte array
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_NV_WRITE_CDMA_PRL 120
/**
* RIL_REQUEST_NV_RESET_CONFIG
*
* Reset the radio NV configuration to the factory state.
* This is used for device configuration by some CDMA operators.
*
* "data" is int *
* ((int *)data)[0] is 1 to reload all NV items
* ((int *)data)[0] is 2 for erase NV reset (SCRTN)
* ((int *)data)[0] is 3 for factory reset (RTN)
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_NV_RESET_CONFIG 121
/** RIL_REQUEST_SET_UICC_SUBSCRIPTION
* FIXME This API needs to have more documentation.
*
* Selection/de-selection of a subscription from a SIM card
* "data" is const RIL_SelectUiccSub*
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* SUBSCRIPTION_NOT_SUPPORTED
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 122
/**
* RIL_REQUEST_ALLOW_DATA
*
* Tells the modem whether data calls are allowed or not
*
* "data" is int *
* FIXME slotId and aid will be added.
* ((int *)data)[0] is == 0 to allow data calls
* ((int *)data)[0] is == 1 to disallow data calls
*
* "response" is NULL
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* INVALID_ARGUMENTS
* DEVICE_IN_USE
* INVALID_MODEM_STATE
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_ALLOW_DATA 123
/**
* RIL_REQUEST_GET_HARDWARE_CONFIG
*
* Request all of the current hardware (modem and sim) associated
* with the RIL.
*
* "data" is NULL
*
* "response" is an array of RIL_HardwareConfig.
*
* Valid errors:
* RADIO_NOT_AVAILABLE
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_GET_HARDWARE_CONFIG 124
/**
* RIL_REQUEST_SIM_AUTHENTICATION
*
* Returns the response of SIM Authentication through RIL to a
* challenge request.
*
* "data" Base64 encoded string containing challenge:
* int authContext; P2 value of authentication command, see P2 parameter in
* 3GPP TS 31.102 7.1.2
* char *authData; the challenge string in Base64 format, see 3GPP
* TS 31.102 7.1.2
* char *aid; AID value, See ETSI 102.221 8.1 and 101.220 4,
* NULL if no value
*
* "response" Base64 encoded strings containing response:
* int sw1; Status bytes per 3GPP TS 31.102 section 7.3
* int sw2;
* char *simResponse; Response in Base64 format, see 3GPP TS 31.102 7.1.2
*
* Valid errors:
* RADIO_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* INVALID_MODEM_STATE
* INVALID_ARGUMENTS
* SIM_ERR
* REQUEST_NOT_SUPPORTED
*/
#define RIL_REQUEST_SIM_AUTHENTICATION 125
/**
* RIL_REQUEST_GET_DC_RT_INFO
*
* The request is DEPRECATED, use RIL_REQUEST_GET_ACTIVITY_INFO
* Requests the Data Connection Real Time Info
*
* "data" is NULL
*
* "response" is the most recent RIL_DcRtInfo
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* REQUEST_NOT_SUPPORTED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
*
* See also: RIL_UNSOL_DC_RT_INFO_CHANGED
*/
#define RIL_REQUEST_GET_DC_RT_INFO 126
/**
* RIL_REQUEST_SET_DC_RT_INFO_RATE
*
* The request is DEPRECATED
* This is the minimum number of milliseconds between successive
* RIL_UNSOL_DC_RT_INFO_CHANGED messages and defines the highest rate
* at which RIL_UNSOL_DC_RT_INFO_CHANGED's will be sent. A value of
* 0 means send as fast as possible.
*
* "data" The number of milliseconds as an int
*
* "response" is null
*
* Valid errors:
* SUCCESS must not fail
*/
#define RIL_REQUEST_SET_DC_RT_INFO_RATE 127
/**
* RIL_REQUEST_SET_DATA_PROFILE
*
* Set data profile in modem
* Modem should erase existed profiles from framework, and apply new profiles
* "data" is a const RIL_DataProfileInfo **
* "datalen" is count * sizeof(const RIL_DataProfileInfo *)
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* SUBSCRIPTION_NOT_AVAILABLE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*/
#define RIL_REQUEST_SET_DATA_PROFILE 128
/**
* RIL_REQUEST_SHUTDOWN
*
* Device is shutting down. All further commands are ignored
* and RADIO_NOT_AVAILABLE must be returned.
*
* "data" is null
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* OPERATION_NOT_ALLOWED
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_SHUTDOWN 129
/**
* RIL_REQUEST_GET_RADIO_CAPABILITY
*
* Used to get phone radio capablility.
*
* "data" is the RIL_RadioCapability structure
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* OPERATION_NOT_ALLOWED
* INVALID_STATE
* REQUEST_NOT_SUPPORTED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_GET_RADIO_CAPABILITY 130
/**
* RIL_REQUEST_SET_RADIO_CAPABILITY
*
* Used to set the phones radio capability. Be VERY careful
* using this request as it may cause some vendor modems to reset. Because
* of the possible modem reset any RIL commands after this one may not be
* processed.
*
* "data" is the RIL_RadioCapability structure
*
* "response" is the RIL_RadioCapability structure, used to feedback return status
*
* Valid errors:
* SUCCESS means a RIL_UNSOL_RADIO_CAPABILITY will be sent within 30 seconds.
* RADIO_NOT_AVAILABLE
* OPERATION_NOT_ALLOWED
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* MODEM_ERR
* INVALID_STATE
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_SET_RADIO_CAPABILITY 131
/**
* RIL_REQUEST_START_LCE
*
* Start Link Capacity Estimate (LCE) service if supported by the radio.
*
* "data" is const int *
* ((const int*)data)[0] specifies the desired reporting interval (ms).
* ((const int*)data)[1] specifies the LCE service mode. 1: PULL; 0: PUSH.
*
* "response" is the RIL_LceStatusInfo.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* LCE_NOT_SUPPORTED
* INTERNAL_ERR
* REQUEST_NOT_SUPPORTED
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* SIM_ABSENT
*/
#define RIL_REQUEST_START_LCE 132
/**
* RIL_REQUEST_STOP_LCE
*
* Stop Link Capacity Estimate (LCE) service, the STOP operation should be
* idempotent for the radio modem.
*
* "response" is the RIL_LceStatusInfo.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* LCE_NOT_SUPPORTED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*/
#define RIL_REQUEST_STOP_LCE 133
/**
* RIL_REQUEST_PULL_LCEDATA
*
* Pull LCE service for capacity information.
*
* "response" is the RIL_LceDataInfo.
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* LCE_NOT_SUPPORTED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
*/
#define RIL_REQUEST_PULL_LCEDATA 134
/**
* RIL_REQUEST_GET_ACTIVITY_INFO
*
* Get modem activity information for power consumption estimation.
*
* Request clear-on-read statistics information that is used for
* estimating the per-millisecond power consumption of the cellular
* modem.
*
* "data" is null
* "response" is const RIL_ActivityStatsInfo *
*
* Valid errors:
*
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* MODEM_ERR
* NOT_PROVISIONED
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES CANCELLED
*/
#define RIL_REQUEST_GET_ACTIVITY_INFO 135
/**
* RIL_REQUEST_SET_CARRIER_RESTRICTIONS
*
* Set carrier restrictions for this sim slot. Expected modem behavior:
* If never receives this command
* - Must allow all carriers
* Receives this command with data being NULL
* - Must allow all carriers. If a previously allowed SIM is present, modem must not reload
* the SIM. If a previously disallowed SIM is present, reload the SIM and notify Android.
* Receives this command with a list of carriers
* - Only allow specified carriers, persist across power cycles and FDR. If a present SIM
* is in the allowed list, modem must not reload the SIM. If a present SIM is *not* in
* the allowed list, modem must detach from the registered network and only keep emergency
* service, and notify Android SIM refresh reset with new SIM state being
* RIL_CARDSTATE_RESTRICTED. Emergency service must be enabled.
*
* "data" is const RIL_CarrierRestrictions *
* A list of allowed carriers and possibly a list of excluded carriers.
* If data is NULL, means to clear previous carrier restrictions and allow all carriers
*
* "response" is int *
* ((int *)data)[0] contains the number of allowed carriers which have been set correctly.
* On success, it should match the length of list data->allowed_carriers.
* If data is NULL, the value must be 0.
*
* Valid errors:
* RIL_E_SUCCESS
* RIL_E_INVALID_ARGUMENTS
* RIL_E_RADIO_NOT_AVAILABLE
* RIL_E_REQUEST_NOT_SUPPORTED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_SET_CARRIER_RESTRICTIONS 136
/**
* RIL_REQUEST_GET_CARRIER_RESTRICTIONS
*
* Get carrier restrictions for this sim slot. Expected modem behavior:
* Return list of allowed carriers, or null if all carriers are allowed.
*
* "data" is NULL
*
* "response" is const RIL_CarrierRestrictions *.
* If response is NULL, it means all carriers are allowed.
*
* Valid errors:
* RIL_E_SUCCESS
* RIL_E_RADIO_NOT_AVAILABLE
* RIL_E_REQUEST_NOT_SUPPORTED
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_GET_CARRIER_RESTRICTIONS 137
/**
* RIL_REQUEST_SEND_DEVICE_STATE
*
* Send the updated device state.
* Modem can perform power saving based on the provided device state.
* "data" is const int *
* ((const int*)data)[0] A RIL_DeviceStateType that specifies the device state type.
* ((const int*)data)[1] Specifies the state. See RIL_DeviceStateType for the definition of each
* type.
*
* "datalen" is count * sizeof(const RIL_DeviceState *)
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE (radio resetting)
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* INVALID_ARGUMENTS
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_SEND_DEVICE_STATE 138
/**
* RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER
*
* Set the unsolicited response filter
* This is used to prevent unnecessary application processor
* wake up for power saving purposes by suppressing the
* unsolicited responses in certain scenarios.
*
* "data" is an int *
*
* ((int *)data)[0] is a 32-bit bitmask of RIL_UnsolicitedResponseFilter
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* INVALID_ARGUMENTS (e.g. the requested filter doesn't exist)
* RADIO_NOT_AVAILABLE (radio resetting)
* NO_MEMORY
* INTERNAL_ERR
* SYSTEM_ERR
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER 139
/**
* RIL_REQUEST_SET_SIM_CARD_POWER
*
* Set SIM card power up or down
*
* Request is equivalent to inserting and removing the card, with
* an additional effect where the ability to detect card removal/insertion
* is disabled when the SIM card is powered down.
*
* This will generate RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED
* as if the SIM had been inserted or removed.
*
* "data" is int *
* ((int *)data)[0] is 1 for "SIM POWER UP"
* ((int *)data)[0] is 0 for "SIM POWER DOWN"
*
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* REQUEST_NOT_SUPPORTED
* SIM_ABSENT
* INVALID_ARGUMENTS
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_SET_SIM_CARD_POWER 140
/**
* RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION
*
* Provide Carrier specific information to the modem that will be used to
* encrypt the IMSI and IMPI. Sent by the framework during boot, carrier
* switch and everytime we receive a new certificate.
*
* "data" is the RIL_CarrierInfoForImsiEncryption * structure.
*
* "response" is NULL
*
* Valid errors:
* RIL_E_SUCCESS
* RIL_E_RADIO_NOT_AVAILABLE
* SIM_ABSENT
* RIL_E_REQUEST_NOT_SUPPORTED
* INVALID_ARGUMENTS
* MODEM_INTERNAL_FAILURE
* INTERNAL_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
*/
#define RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION 141
/**
* RIL_REQUEST_START_NETWORK_SCAN
*
* Starts a new network scan
*
* Request to start a network scan with specified radio access networks with frequency bands and/or
* channels.
*
* "data" is a const RIL_NetworkScanRequest *.
* "response" is NULL
*
* Valid errors:
* SUCCESS
* RADIO_NOT_AVAILABLE
* OPERATION_NOT_ALLOWED
* DEVICE_IN_USE
* INTERNAL_ERR
* NO_MEMORY
* MODEM_ERR
* INVALID_ARGUMENTS
* REQUEST_NOT_SUPPORTED
* NO_RESOURCES
* CANCELLED
*
*/
#define RIL_REQUEST_START_NETWORK_SCAN 142
/**
* RIL_REQUEST_STOP_NETWORK_SCAN
*
* Stops an ongoing network scan
*
* Request to stop the ongoing network scan. Since the modem can only perform one scan at a time,
* there is no parameter for this request.
*
* "data" is NULL
* "response" is NULL
*
* Valid errors:
* SUCCESS
* INTERNAL_ERR
* MODEM_ERR
* NO_MEMORY
* NO_RESOURCES
* CANCELLED
* REQUEST_NOT_SUPPORTED
*
*/
#define RIL_REQUEST_STOP_NETWORK_SCAN 143
/**
* RIL_REQUEST_START_KEEPALIVE
*
* Start a keepalive session
*
* Request that the modem begin sending keepalive packets on a particular
* data call, with a specified source, destination, and format.
*
* "data" is a const RIL_RequestKeepalive
* "response" is RIL_KeepaliveStatus with a valid "handle"
*
* Valid errors:
* SUCCESS
* NO_RESOURCES
* INVALID_ARGUMENTS
*
*/
#define RIL_REQUEST_START_KEEPALIVE 144
/**
* RIL_REQUEST_STOP_KEEPALIVE
*
* Stops an ongoing keepalive session
*
* Requests that a keepalive session with the given handle be stopped.
* there is no parameter for this request.
*
* "data" is an integer handle
* "response" is NULL
*
* Valid errors:
* SUCCESS
* INVALID_ARGUMENTS
*
*/
#define RIL_REQUEST_STOP_KEEPALIVE 145
/***********************************************************************/
/**
* RIL_RESPONSE_ACKNOWLEDGEMENT
*
* This is used by Asynchronous solicited messages and Unsolicited messages
* to acknowledge the receipt of those messages in RIL.java so that the ack
* can be used to let ril.cpp to release wakelock.
*
* Valid errors
* SUCCESS
* RADIO_NOT_AVAILABLE
*/
#define RIL_RESPONSE_ACKNOWLEDGEMENT 800
/***********************************************************************/
#define RIL_UNSOL_RESPONSE_BASE 1000
/**
* RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED
*
* Indicate when value of RIL_RadioState has changed.
*
* Callee will invoke RIL_RadioStateRequest method on main thread
*
* "data" is NULL
*/
#define RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED 1000
/**
* RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED
*
* Indicate when call state has changed
*
* Callee will invoke RIL_REQUEST_GET_CURRENT_CALLS on main thread
*
* "data" is NULL
*
* Response should be invoked on, for example,
* "RING", "BUSY", "NO CARRIER", and also call state
* transitions (DIALING->ALERTING ALERTING->ACTIVE)
*
* Redundent or extraneous invocations are tolerated
*/
#define RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED 1001
/**
* RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED
*
* Called when the voice network state changed
*
* Callee will invoke the following requests on main thread:
*
* RIL_REQUEST_VOICE_REGISTRATION_STATE
* RIL_REQUEST_OPERATOR
*
* "data" is NULL
*
* FIXME should this happen when SIM records are loaded? (eg, for
* EONS)
*/
#define RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 1002
/**
* RIL_UNSOL_RESPONSE_NEW_SMS
*
* Called when new SMS is received.
*
* "data" is const char *
* This is a pointer to a string containing the PDU of an SMS-DELIVER
* as an ascii string of hex digits. The PDU starts with the SMSC address
* per TS 27.005 (+CMT:)
*
* Callee will subsequently confirm the receipt of thei SMS with a
* RIL_REQUEST_SMS_ACKNOWLEDGE
*
* No new RIL_UNSOL_RESPONSE_NEW_SMS
* or RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT messages should be sent until a
* RIL_REQUEST_SMS_ACKNOWLEDGE has been received
*/
#define RIL_UNSOL_RESPONSE_NEW_SMS 1003
/**
* RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT
*
* Called when new SMS Status Report is received.
*
* "data" is const char *
* This is a pointer to a string containing the PDU of an SMS-STATUS-REPORT
* as an ascii string of hex digits. The PDU starts with the SMSC address
* per TS 27.005 (+CDS:).
*
* Callee will subsequently confirm the receipt of the SMS with a
* RIL_REQUEST_SMS_ACKNOWLEDGE
*
* No new RIL_UNSOL_RESPONSE_NEW_SMS
* or RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT messages should be sent until a
* RIL_REQUEST_SMS_ACKNOWLEDGE has been received
*/
#define RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT 1004
/**
* RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM
*
* Called when new SMS has been stored on SIM card
*
* "data" is const int *
* ((const int *)data)[0] contains the slot index on the SIM that contains
* the new message
*/
#define RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM 1005
/**
* RIL_UNSOL_ON_USSD
*
* Called when a new USSD message is received.
*
* "data" is const char **
* ((const char **)data)[0] points to a type code, which is
* one of these string values:
* "0" USSD-Notify -- text in ((const char **)data)[1]
* "1" USSD-Request -- text in ((const char **)data)[1]
* "2" Session terminated by network
* "3" other local client (eg, SIM Toolkit) has responded
* "4" Operation not supported
* "5" Network timeout
*
* The USSD session is assumed to persist if the type code is "1", otherwise
* the current session (if any) is assumed to have terminated.
*
* ((const char **)data)[1] points to a message string if applicable, which
* should always be in UTF-8.
*/
#define RIL_UNSOL_ON_USSD 1006
/* Previously #define RIL_UNSOL_ON_USSD_NOTIFY 1006 */
/**
* RIL_UNSOL_ON_USSD_REQUEST
*
* Obsolete. Send via RIL_UNSOL_ON_USSD
*/
#define RIL_UNSOL_ON_USSD_REQUEST 1007
/**
* RIL_UNSOL_NITZ_TIME_RECEIVED
*
* Called when radio has received a NITZ time message
*
* "data" is const char * pointing to NITZ time string
* in the form "yy/mm/dd,hh:mm:ss(+/-)tz,dt"
*/
#define RIL_UNSOL_NITZ_TIME_RECEIVED 1008
/**
* RIL_UNSOL_SIGNAL_STRENGTH
*
* Radio may report signal strength rather han have it polled.
*
* "data" is a const RIL_SignalStrength *
*/
#define RIL_UNSOL_SIGNAL_STRENGTH 1009
/**
* RIL_UNSOL_DATA_CALL_LIST_CHANGED
*
* "data" is an array of RIL_Data_Call_Response_v6 identical to that
* returned by RIL_REQUEST_DATA_CALL_LIST. It is the complete list
* of current data contexts including new contexts that have been
* activated. A data call is only removed from this list when the
* framework sends a RIL_REQUEST_DEACTIVATE_DATA_CALL or the radio
* is powered off/on.
*
* See also: RIL_REQUEST_DATA_CALL_LIST
*/
#define RIL_UNSOL_DATA_CALL_LIST_CHANGED 1010
/**
* RIL_UNSOL_SUPP_SVC_NOTIFICATION
*
* Reports supplementary service related notification from the network.
*
* "data" is a const RIL_SuppSvcNotification *
*
*/
#define RIL_UNSOL_SUPP_SVC_NOTIFICATION 1011
/**
* RIL_UNSOL_STK_SESSION_END
*
* Indicate when STK session is terminated by SIM.
*
* "data" is NULL
*/
#define RIL_UNSOL_STK_SESSION_END 1012
/**
* RIL_UNSOL_STK_PROACTIVE_COMMAND
*
* Indicate when SIM issue a STK proactive command to applications
*
* "data" is a const char * containing SAT/USAT proactive command
* in hexadecimal format string starting with command tag
*
*/
#define RIL_UNSOL_STK_PROACTIVE_COMMAND 1013
/**
* RIL_UNSOL_STK_EVENT_NOTIFY
*
* Indicate when SIM notifies applcations some event happens.
* Generally, application does not need to have any feedback to
* SIM but shall be able to indicate appropriate messages to users.
*
* "data" is a const char * containing SAT/USAT commands or responses
* sent by ME to SIM or commands handled by ME, in hexadecimal format string
* starting with first byte of response data or command tag
*
*/
#define RIL_UNSOL_STK_EVENT_NOTIFY 1014
/**
* RIL_UNSOL_STK_CALL_SETUP
*
* Indicate when SIM wants application to setup a voice call.
*
* "data" is const int *
* ((const int *)data)[0] contains timeout value (in milliseconds)
*/
#define RIL_UNSOL_STK_CALL_SETUP 1015
/**
* RIL_UNSOL_SIM_SMS_STORAGE_FULL
*
* Indicates that SMS storage on the SIM is full. Sent when the network
* attempts to deliver a new SMS message. Messages cannot be saved on the
* SIM until space is freed. In particular, incoming Class 2 messages
* cannot be stored.
*
* "data" is null
*
*/
#define RIL_UNSOL_SIM_SMS_STORAGE_FULL 1016
/**
* RIL_UNSOL_SIM_REFRESH
*
* Indicates that file(s) on the SIM have been updated, or the SIM
* has been reinitialized.
*
* In the case where RIL is version 6 or older:
* "data" is an int *
* ((int *)data)[0] is a RIL_SimRefreshResult.
* ((int *)data)[1] is the EFID of the updated file if the result is
* SIM_FILE_UPDATE or NULL for any other result.
*
* In the case where RIL is version 7:
* "data" is a RIL_SimRefreshResponse_v7 *
*
* Note: If the SIM state changes as a result of the SIM refresh (eg,
* SIM_READY -> SIM_LOCKED_OR_ABSENT), RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED
* should be sent.
*/
#define RIL_UNSOL_SIM_REFRESH 1017
/**
* RIL_UNSOL_CALL_RING
*
* Ring indication for an incoming call (eg, RING or CRING event).
* There must be at least one RIL_UNSOL_CALL_RING at the beginning
* of a call and sending multiple is optional. If the system property
* ro.telephony.call_ring.multiple is false then the upper layers
* will generate the multiple events internally. Otherwise the vendor
* ril must generate multiple RIL_UNSOL_CALL_RING if
* ro.telephony.call_ring.multiple is true or if it is absent.
*
* The rate of these events is controlled by ro.telephony.call_ring.delay
* and has a default value of 3000 (3 seconds) if absent.
*
* "data" is null for GSM
* "data" is const RIL_CDMA_SignalInfoRecord * if CDMA
*/
#define RIL_UNSOL_CALL_RING 1018
/**
* RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED
*
* Indicates that SIM state changes.
*
* Callee will invoke RIL_REQUEST_GET_SIM_STATUS on main thread
* "data" is null
*/
#define RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED 1019
/**
* RIL_UNSOL_RESPONSE_CDMA_NEW_SMS
*
* Called when new CDMA SMS is received
*
* "data" is const RIL_CDMA_SMS_Message *
*
* Callee will subsequently confirm the receipt of the SMS with
* a RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE
*
* No new RIL_UNSOL_RESPONSE_CDMA_NEW_SMS should be sent until
* RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE has been received
*
*/
#define RIL_UNSOL_RESPONSE_CDMA_NEW_SMS 1020
/**
* RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS
*
* Called when new Broadcast SMS is received
*
* "data" can be one of the following:
* If received from GSM network, "data" is const char of 88 bytes
* which indicates each page of a CBS Message sent to the MS by the
* BTS as coded in 3GPP 23.041 Section 9.4.1.2.
* If received from UMTS network, "data" is const char of 90 up to 1252
* bytes which contain between 1 and 15 CBS Message pages sent as one
* packet to the MS by the BTS as coded in 3GPP 23.041 Section 9.4.2.2.
*
*/
#define RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS 1021
/**
* RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL
*
* Indicates that SMS storage on the RUIM is full. Messages
* cannot be saved on the RUIM until space is freed.
*
* "data" is null
*
*/
#define RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL 1022
/**
* RIL_UNSOL_RESTRICTED_STATE_CHANGED
*
* Indicates a restricted state change (eg, for Domain Specific Access Control).
*
* Radio need send this msg after radio off/on cycle no matter it is changed or not.
*
* "data" is an int *
* ((int *)data)[0] contains a bitmask of RIL_RESTRICTED_STATE_* values.
*/
#define RIL_UNSOL_RESTRICTED_STATE_CHANGED 1023
/**
* RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE
*
* Indicates that the radio system selection module has
* autonomously entered emergency callback mode.
*
* "data" is null
*
*/
#define RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE 1024
/**
* RIL_UNSOL_CDMA_CALL_WAITING
*
* Called when CDMA radio receives a call waiting indication.
*
* "data" is const RIL_CDMA_CallWaiting *
*
*/
#define RIL_UNSOL_CDMA_CALL_WAITING 1025
/**
* RIL_UNSOL_CDMA_OTA_PROVISION_STATUS
*
* Called when CDMA radio receives an update of the progress of an
* OTASP/OTAPA call.
*
* "data" is const int *
* For CDMA this is an integer OTASP/OTAPA status listed in
* RIL_CDMA_OTA_ProvisionStatus.
*
*/
#define RIL_UNSOL_CDMA_OTA_PROVISION_STATUS 1026
/**
* RIL_UNSOL_CDMA_INFO_REC
*
* Called when CDMA radio receives one or more info recs.
*
* "data" is const RIL_CDMA_InformationRecords *
*
*/
#define RIL_UNSOL_CDMA_INFO_REC 1027
/**
* RIL_UNSOL_OEM_HOOK_RAW
*
* This is for OEM specific use.
*
* "data" is a byte[]
*/
#define RIL_UNSOL_OEM_HOOK_RAW 1028
/**
* RIL_UNSOL_RINGBACK_TONE
*
* Indicates that nework doesn't have in-band information, need to
* play out-band tone.
*
* "data" is an int *
* ((int *)data)[0] == 0 for stop play ringback tone.
* ((int *)data)[0] == 1 for start play ringback tone.
*/
#define RIL_UNSOL_RINGBACK_TONE 1029
/**
* RIL_UNSOL_RESEND_INCALL_MUTE
*
* Indicates that framework/application need reset the uplink mute state.
*
* There may be situations where the mute state becomes out of sync
* between the application and device in some GSM infrastructures.
*
* "data" is null
*/
#define RIL_UNSOL_RESEND_INCALL_MUTE 1030
/**
* RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED
*
* Called when CDMA subscription source changed.
*
* "data" is int *
* ((int *)data)[0] is == RIL_CdmaSubscriptionSource
*/
#define RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED 1031
/**
* RIL_UNSOL_CDMA_PRL_CHANGED
*
* Called when PRL (preferred roaming list) changes.
*
* "data" is int *
* ((int *)data)[0] is PRL_VERSION as would be returned by RIL_REQUEST_CDMA_SUBSCRIPTION
*/
#define RIL_UNSOL_CDMA_PRL_CHANGED 1032
/**
* RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE
*
* Called when Emergency Callback Mode Ends
*
* Indicates that the radio system selection module has
* proactively exited emergency callback mode.
*
* "data" is NULL
*
*/
#define RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE 1033
/**
* RIL_UNSOL_RIL_CONNECTED
*
* Called the ril connects and returns the version
*
* "data" is int *
* ((int *)data)[0] is RIL_VERSION
*/
#define RIL_UNSOL_RIL_CONNECTED 1034
/**
* RIL_UNSOL_VOICE_RADIO_TECH_CHANGED
*
* Indicates that voice technology has changed. Contains new radio technology
* as a data in the message.
*
* "data" is int *
* ((int *)data)[0] is of type const RIL_RadioTechnology
*
*/
#define RIL_UNSOL_VOICE_RADIO_TECH_CHANGED 1035
/**
* RIL_UNSOL_CELL_INFO_LIST
*
* Same information as returned by RIL_REQUEST_GET_CELL_INFO_LIST, but returned
* at the rate no greater than specified by RIL_REQUEST_SET_UNSOL_CELL_INFO_RATE.
*
* "data" is NULL
*
* "response" is an array of RIL_CellInfo_v12.
*/
#define RIL_UNSOL_CELL_INFO_LIST 1036
/**
* RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED
*
* This message is DEPRECATED and shall be removed in a future release (target: 2018);
* instead, provide IMS registration status via an IMS Service.
*
* Called when IMS registration state has changed
*
* To get IMS registration state and IMS SMS format, callee needs to invoke the
* following request on main thread:
*
* RIL_REQUEST_IMS_REGISTRATION_STATE
*
* "data" is NULL
*
*/
#define RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED 1037
/**
* RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED
*
* Indicated when there is a change in subscription status.
* This event will be sent in the following scenarios
* - subscription readiness at modem, which was selected by telephony layer
* - when subscription is deactivated by modem due to UICC card removal
* - When network invalidates the subscription i.e. attach reject due to authentication reject
*
* "data" is const int *
* ((const int *)data)[0] == 0 for Subscription Deactivated
* ((const int *)data)[0] == 1 for Subscription Activated
*
*/
#define RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED 1038
/**
* RIL_UNSOL_SRVCC_STATE_NOTIFY
*
* Called when Single Radio Voice Call Continuity(SRVCC)
* progress state has changed
*
* "data" is int *
* ((int *)data)[0] is of type const RIL_SrvccState
*
*/
#define RIL_UNSOL_SRVCC_STATE_NOTIFY 1039
/**
* RIL_UNSOL_HARDWARE_CONFIG_CHANGED
*
* Called when the hardware configuration associated with the RILd changes
*
* "data" is an array of RIL_HardwareConfig
*
*/
#define RIL_UNSOL_HARDWARE_CONFIG_CHANGED 1040
/**
* RIL_UNSOL_DC_RT_INFO_CHANGED
*
* The message is DEPRECATED, use RIL_REQUEST_GET_ACTIVITY_INFO
* Sent when the DC_RT_STATE changes but the time
* between these messages must not be less than the
* value set by RIL_REQUEST_SET_DC_RT_RATE.
*
* "data" is the most recent RIL_DcRtInfo
*
*/
#define RIL_UNSOL_DC_RT_INFO_CHANGED 1041
/**
* RIL_UNSOL_RADIO_CAPABILITY
*
* Sent when RIL_REQUEST_SET_RADIO_CAPABILITY completes.
* Returns the phone radio capability exactly as
* RIL_REQUEST_GET_RADIO_CAPABILITY and should be the
* same set as sent by RIL_REQUEST_SET_RADIO_CAPABILITY.
*
* "data" is the RIL_RadioCapability structure
*/
#define RIL_UNSOL_RADIO_CAPABILITY 1042
/*
* RIL_UNSOL_ON_SS
*
* Called when SS response is received when DIAL/USSD/SS is changed to SS by
* call control.
*
* "data" is const RIL_StkCcUnsolSsResponse *
*
*/
#define RIL_UNSOL_ON_SS 1043
/**
* RIL_UNSOL_STK_CC_ALPHA_NOTIFY
*
* Called when there is an ALPHA from UICC during Call Control.
*
* "data" is const char * containing ALPHA string from UICC in UTF-8 format.
*
*/
#define RIL_UNSOL_STK_CC_ALPHA_NOTIFY 1044
/**
* RIL_UNSOL_LCEDATA_RECV
*
* Called when there is an incoming Link Capacity Estimate (LCE) info report.
*
* "data" is the RIL_LceDataInfo structure.
*
*/
#define RIL_UNSOL_LCEDATA_RECV 1045
/**
* RIL_UNSOL_PCO_DATA
*
* Called when there is new Carrier PCO data received for a data call. Ideally
* only new data will be forwarded, though this is not required. Multiple
* boxes of carrier PCO data for a given call should result in a series of
* RIL_UNSOL_PCO_DATA calls.
*
* "data" is the RIL_PCO_Data structure.
*
*/
#define RIL_UNSOL_PCO_DATA 1046
/**
* RIL_UNSOL_MODEM_RESTART
*
* Called when there is a modem reset.
*
* "reason" is "const char *" containing the reason for the reset. It
* could be a crash signature if the restart was due to a crash or some
* string such as "user-initiated restart" or "AT command initiated
* restart" that explains the cause of the modem restart.
*
* When modem restarts, one of the following radio state transitions will happen
* 1) RADIO_STATE_ON->RADIO_STATE_UNAVAILABLE->RADIO_STATE_ON or
* 2) RADIO_STATE_OFF->RADIO_STATE_UNAVAILABLE->RADIO_STATE_OFF
* This message can be sent either just before the RADIO_STATE changes to RADIO_STATE_UNAVAILABLE
* or just after but should never be sent after the RADIO_STATE changes from UNAVAILABLE to
* AVAILABLE(RADIO_STATE_ON/RADIO_STATE_OFF) again.
*
* It should NOT be sent after the RADIO_STATE changes to AVAILABLE after the
* modem restart as that could be interpreted as a second modem reset by the
* framework.
*/
#define RIL_UNSOL_MODEM_RESTART 1047
/**
* RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION
*
* Called when the modem needs Carrier specific information that will
* be used to encrypt IMSI and IMPI.
*
* "data" is NULL
*
*/
#define RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION 1048
/**
* RIL_UNSOL_NETWORK_SCAN_RESULT
*
* Returns incremental result for the network scan which is started by
* RIL_REQUEST_START_NETWORK_SCAN, sent to report results, status, or errors.
*
* "data" is NULL
* "response" is a const RIL_NetworkScanResult *
*/
#define RIL_UNSOL_NETWORK_SCAN_RESULT 1049
/**
* RIL_UNSOL_KEEPALIVE_STATUS
*
* "data" is NULL
* "response" is a const RIL_KeepaliveStatus *
*/
#define RIL_UNSOL_KEEPALIVE_STATUS 1050
/***********************************************************************/
#if defined(ANDROID_MULTI_SIM)
/**
* RIL_Request Function pointer
*
* @param request is one of RIL_REQUEST_*
* @param data is pointer to data defined for that RIL_REQUEST_*
* data is owned by caller, and should not be modified or freed by callee
* structures passed as data may contain pointers to non-contiguous memory
* @param t should be used in subsequent call to RIL_onResponse
* @param datalen is the length of "data" which is defined as other argument. It may or may
* not be equal to sizeof(data). Refer to the documentation of individual structures
* to find if pointers listed in the structure are contiguous and counted in the datalen
* length or not.
* (Eg: RIL_IMS_SMS_Message where we don't have datalen equal to sizeof(data))
*
*/
typedef void (*RIL_RequestFunc) (int request, void *data,
size_t datalen, RIL_Token t, RIL_SOCKET_ID socket_id);
/**
* This function should return the current radio state synchronously
*/
typedef RIL_RadioState (*RIL_RadioStateRequest)(RIL_SOCKET_ID socket_id);
#else
/* Backward compatible */
/**
* RIL_Request Function pointer
*
* @param request is one of RIL_REQUEST_*
* @param data is pointer to data defined for that RIL_REQUEST_*
* data is owned by caller, and should not be modified or freed by callee
* structures passed as data may contain pointers to non-contiguous memory
* @param t should be used in subsequent call to RIL_onResponse
* @param datalen is the length of "data" which is defined as other argument. It may or may
* not be equal to sizeof(data). Refer to the documentation of individual structures
* to find if pointers listed in the structure are contiguous and counted in the datalen
* length or not.
* (Eg: RIL_IMS_SMS_Message where we don't have datalen equal to sizeof(data))
*
*/
typedef void (*RIL_RequestFunc) (int request, void *data,
size_t datalen, RIL_Token t);
/**
* This function should return the current radio state synchronously
*/
typedef RIL_RadioState (*RIL_RadioStateRequest)();
#endif
/**
* This function returns "1" if the specified RIL_REQUEST code is
* supported and 0 if it is not
*
* @param requestCode is one of RIL_REQUEST codes
*/
typedef int (*RIL_Supports)(int requestCode);
/**
* This function is called from a separate thread--not the
* thread that calls RIL_RequestFunc--and indicates that a pending
* request should be cancelled.
*
* On cancel, the callee should do its best to abandon the request and
* call RIL_onRequestComplete with RIL_Errno CANCELLED at some later point.
*
* Subsequent calls to RIL_onRequestComplete for this request with
* other results will be tolerated but ignored. (That is, it is valid
* to ignore the cancellation request)
*
* RIL_Cancel calls should return immediately, and not wait for cancellation
*
* Please see ITU v.250 5.6.1 for how one might implement this on a TS 27.007
* interface
*
* @param t token wants to be canceled
*/
typedef void (*RIL_Cancel)(RIL_Token t);
typedef void (*RIL_TimedCallback) (void *param);
/**
* Return a version string for your RIL implementation
*/
typedef const char * (*RIL_GetVersion) (void);
typedef struct {
int version; /* set to RIL_VERSION */
RIL_RequestFunc onRequest;
RIL_RadioStateRequest onStateRequest;
RIL_Supports supports;
RIL_Cancel onCancel;
RIL_GetVersion getVersion;
} RIL_RadioFunctions;
typedef struct {
char *apn; /* the APN to connect to */
char *protocol; /* one of the PDP_type values in TS 27.007 section 10.1.1 used on
roaming network. For example, "IP", "IPV6", "IPV4V6", or "PPP".*/
int authtype; /* authentication protocol used for this PDP context
(None: 0, PAP: 1, CHAP: 2, PAP&CHAP: 3) */
char *username; /* the username for APN, or NULL */
char *password; /* the password for APN, or NULL */
} RIL_InitialAttachApn;
typedef struct {
char *apn; /* the APN to connect to */
char *protocol; /* one of the PDP_type values in TS 27.007 section 10.1.1 used on
home network. For example, "IP", "IPV6", "IPV4V6", or "PPP". */
char *roamingProtocol; /* one of the PDP_type values in TS 27.007 section 10.1.1 used on
roaming network. For example, "IP", "IPV6", "IPV4V6", or "PPP".*/
int authtype; /* authentication protocol used for this PDP context
(None: 0, PAP: 1, CHAP: 2, PAP&CHAP: 3) */
char *username; /* the username for APN, or NULL */
char *password; /* the password for APN, or NULL */
int supportedTypesBitmask; /* supported APN types bitmask. See RIL_ApnTypes for the value of
each bit. */
int bearerBitmask; /* the bearer bitmask. See RIL_RadioAccessFamily for the value of
each bit. */
int modemCognitive; /* indicating the APN setting was sent to the modem through
setDataProfile earlier. */
int mtu; /* maximum transmission unit (MTU) size in bytes */
char *mvnoType; /* the MVNO type: possible values are "imsi", "gid", "spn" */
char *mvnoMatchData; /* MVNO match data. Can be anything defined by the carrier.
For example,
SPN like: "A MOBILE", "BEN NL", etc...
IMSI like: "302720x94", "2060188", etc...
GID like: "4E", "33", etc... */
} RIL_InitialAttachApn_v15;
typedef struct {
int authContext; /* P2 value of authentication command, see P2 parameter in
3GPP TS 31.102 7.1.2 */
char *authData; /* the challenge string in Base64 format, see 3GPP
TS 31.102 7.1.2 */
char *aid; /* AID value, See ETSI 102.221 8.1 and 101.220 4,
NULL if no value. */
} RIL_SimAuthentication;
typedef struct {
int cid; /* Context ID, uniquely identifies this call */
char *bearer_proto; /* One of the PDP_type values in TS 27.007 section 10.1.1.
For example, "IP", "IPV6", "IPV4V6". */
int pco_id; /* The protocol ID for this box. Note that only IDs from
FF00H - FFFFH are accepted. If more than one is included
from the network, multiple calls should be made to send all
of them. */
int contents_length; /* The number of octets in the contents. */
char *contents; /* Carrier-defined content. It is binary, opaque and
loosely defined in LTE Layer 3 spec 24.008 */
} RIL_PCO_Data;
typedef enum {
NATT_IPV4 = 0, /* Keepalive specified by RFC 3948 Sec. 2.3 using IPv4 */
NATT_IPV6 = 1 /* Keepalive specified by RFC 3948 Sec. 2.3 using IPv6 */
} RIL_KeepaliveType;
#define MAX_INADDR_LEN 16
typedef struct {
RIL_KeepaliveType type; /* Type of keepalive packet */
char sourceAddress[MAX_INADDR_LEN]; /* Source address in network-byte order */
int sourcePort; /* Source port if applicable, or 0x7FFFFFFF;
the maximum value is 65535 */
char destinationAddress[MAX_INADDR_LEN]; /* Destination address in network-byte order */
int destinationPort; /* Destination port if applicable or 0x7FFFFFFF;
the maximum value is 65535 */
int maxKeepaliveIntervalMillis; /* Maximum milliseconds between two packets */
int cid; /* Context ID, uniquely identifies this call */
} RIL_KeepaliveRequest;
typedef enum {
KEEPALIVE_ACTIVE, /* Keepalive session is active */
KEEPALIVE_INACTIVE, /* Keepalive session is inactive */
KEEPALIVE_PENDING /* Keepalive session status not available */
} RIL_KeepaliveStatusCode;
typedef struct {
uint32_t sessionHandle;
RIL_KeepaliveStatusCode code;
} RIL_KeepaliveStatus;
#ifdef RIL_SHLIB
struct RIL_Env {
/**
* "t" is parameter passed in on previous call to RIL_Notification
* routine.
*
* If "e" != SUCCESS, then response can be null/is ignored
*
* "response" is owned by caller, and should not be modified or
* freed by callee
*
* RIL_onRequestComplete will return as soon as possible
*/
void (*OnRequestComplete)(RIL_Token t, RIL_Errno e,
void *response, size_t responselen);
#if defined(ANDROID_MULTI_SIM)
/**
* "unsolResponse" is one of RIL_UNSOL_RESPONSE_*
* "data" is pointer to data defined for that RIL_UNSOL_RESPONSE_*
*
* "data" is owned by caller, and should not be modified or freed by callee
*/
void (*OnUnsolicitedResponse)(int unsolResponse, const void *data, size_t datalen, RIL_SOCKET_ID socket_id);
#else
/**
* "unsolResponse" is one of RIL_UNSOL_RESPONSE_*
* "data" is pointer to data defined for that RIL_UNSOL_RESPONSE_*
*
* "data" is owned by caller, and should not be modified or freed by callee
*/
void (*OnUnsolicitedResponse)(int unsolResponse, const void *data, size_t datalen);
#endif
/**
* Call user-specifed "callback" function on on the same thread that
* RIL_RequestFunc is called. If "relativeTime" is specified, then it specifies
* a relative time value at which the callback is invoked. If relativeTime is
* NULL or points to a 0-filled structure, the callback will be invoked as
* soon as possible
*/
void (*RequestTimedCallback) (RIL_TimedCallback callback,
void *param, const struct timeval *relativeTime);
/**
* "t" is parameter passed in on previous call RIL_Notification routine
*
* RIL_onRequestAck will be called by vendor when an Async RIL request was received
* by them and an ack needs to be sent back to java ril.
*/
void (*OnRequestAck) (RIL_Token t);
};
/**
* RIL implementations must defined RIL_Init
* argc and argv will be command line arguments intended for the RIL implementation
* Return NULL on error
*
* @param env is environment point defined as RIL_Env
* @param argc number of arguments
* @param argv list fo arguments
*
*/
const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **argv);
/**
* If BT SAP(SIM Access Profile) is supported, then RIL implementations must define RIL_SAP_Init
* for initializing RIL_RadioFunctions used for BT SAP communcations. It is called whenever RILD
* starts or modem restarts. Returns handlers for SAP related request that are made on SAP
* sepecific socket, analogous to the RIL_RadioFunctions returned by the call to RIL_Init
* and used on the general RIL socket.
* argc and argv will be command line arguments intended for the RIL implementation
* Return NULL on error.
*
* @param env is environment point defined as RIL_Env
* @param argc number of arguments
* @param argv list fo arguments
*
*/
const RIL_RadioFunctions *RIL_SAP_Init(const struct RIL_Env *env, int argc, char **argv);
#else /* RIL_SHLIB */
/**
* Call this once at startup to register notification routine
*
* @param callbacks user-specifed callback function
*/
void RIL_register (const RIL_RadioFunctions *callbacks);
void rilc_thread_pool();
/**
*
* RIL_onRequestComplete will return as soon as possible
*
* @param t is parameter passed in on previous call to RIL_Notification
* routine.
* @param e error code
* if "e" != SUCCESS, then response can be null/is ignored
* @param response is owned by caller, and should not be modified or
* freed by callee
* @param responselen the length of response in byte
*/
void RIL_onRequestComplete(RIL_Token t, RIL_Errno e,
void *response, size_t responselen);
/**
* RIL_onRequestAck will be called by vendor when an Async RIL request was received by them and
* an ack needs to be sent back to java ril. This doesn't mark the end of the command or it's
* results, just that the command was received and will take a while. After sending this Ack
* its vendor's responsibility to make sure that AP is up whenever needed while command is
* being processed.
*
* @param t is parameter passed in on previous call to RIL_Notification
* routine.
*/
void RIL_onRequestAck(RIL_Token t);
#if defined(ANDROID_MULTI_SIM)
/**
* @param unsolResponse is one of RIL_UNSOL_RESPONSE_*
* @param data is pointer to data defined for that RIL_UNSOL_RESPONSE_*
* "data" is owned by caller, and should not be modified or freed by callee
* @param datalen the length of data in byte
*/
void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
size_t datalen, RIL_SOCKET_ID socket_id);
#else
/**
* @param unsolResponse is one of RIL_UNSOL_RESPONSE_*
* @param data is pointer to data defined for that RIL_UNSOL_RESPONSE_*
* "data" is owned by caller, and should not be modified or freed by callee
* @param datalen the length of data in byte
*/
void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
size_t datalen);
#endif
/**
* Call user-specifed "callback" function on on the same thread that
* RIL_RequestFunc is called. If "relativeTime" is specified, then it specifies
* a relative time value at which the callback is invoked. If relativeTime is
* NULL or points to a 0-filled structure, the callback will be invoked as
* soon as possible
*
* @param callback user-specifed callback function
* @param param parameter list
* @param relativeTime a relative time value at which the callback is invoked
*/
void RIL_requestTimedCallback (RIL_TimedCallback callback,
void *param, const struct timeval *relativeTime);
#endif /* RIL_SHLIB */
#ifdef __cplusplus
}
#endif
#endif /*ANDROID_RIL_H*/
| 32.070304 | 126 | 0.657334 | [
"vector"
] |
b11993a70e573aff8d0caa6cbb3ada6aad7d5987 | 6,717 | h | C | Validation/RecoTau/interface/TauTagValidation.h | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 1 | 2021-11-30T16:24:46.000Z | 2021-11-30T16:24:46.000Z | Validation/RecoTau/interface/TauTagValidation.h | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 4 | 2021-11-29T13:57:56.000Z | 2022-03-29T06:28:36.000Z | Validation/RecoTau/interface/TauTagValidation.h | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 1 | 2022-02-27T06:12:26.000Z | 2022-02-27T06:12:26.000Z | #ifndef TauTagValidation_h
#define TauTagValidation_h
// -*- C++ -*-
//
// Package: TauTagValidation
// Class: TauTagValidation
//
/* *\class TauTagValidation TauTagValidation.cc
Description: EDAnalyzer to validate the Collections from the ConeIsolation Producer
It is supposed to be used for Offline Tau Reconstrction, so PrimaryVertex should be used.
Implementation:
*/
// Original Author: Ricardo Vasquez Sierra On August 29, 2007
// user include files
#include "FWCore/Common/interface/Provenance.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"
#include "DataFormats/Math/interface/Vector3D.h"
#include "DataFormats/Math/interface/LorentzVector.h"
#include "DataFormats/Provenance/interface/ProcessHistoryID.h"
#include "DataFormats/Provenance/interface/ProductProvenance.h"
#include "DataFormats/TauReco/interface/PFTau.h"
#include "DataFormats/TauReco/interface/PFTauDiscriminator.h"
#include "DataFormats/TauReco/interface/TauDiscriminatorContainer.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "RecoParticleFlow/Benchmark/interface/PFBenchmarkAlgo.h"
// Math
#include "Math/GenVector/VectorUtil.h"
#include "Math/GenVector/PxPyPzE4D.h"
#include "TLorentzVector.h"
#include "TH1D.h"
#include "TH1.h"
#include "TH1F.h"
#include <vector>
#include <string>
// Include DQM core
#include <DQMServices/Core/interface/DQMStore.h>
#include <DQMServices/Core/interface/DQMEDAnalyzer.h>
typedef math::XYZTLorentzVectorD LV;
typedef std::vector<LV> LVCollection;
struct hinfo {
int nbins;
double min;
double max;
hinfo(int n, double m, double M) {
nbins = n;
min = m;
max = M;
}
hinfo(const edm::ParameterSet& config) {
nbins = config.getParameter<int>("nbins");
min = config.getParameter<double>("min");
max = config.getParameter<double>("max");
}
};
// class declaration
class TauTagValidation : public DQMEDAnalyzer {
public:
explicit TauTagValidation(const edm::ParameterSet&);
~TauTagValidation() override;
void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override;
void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
private:
/// label of the current module
std::string moduleLabel_;
///sum the transversal momentum of all candidates
double getSumPt(const std::vector<edm::Ptr<reco::Candidate> >& candidates);
///get rid of redundant parts to shorten the label
bool stripDiscriminatorLabel(const std::string& discriminatorLabel, std::string& newLabel);
edm::ParameterSet histoSettings_;
/// generic access to dynamic trigger table
GenericTriggerEventFlag* genericTriggerEventFlag_;
/// What's the reference for the Validation Leptons or Jets
std::string dataType_;
// Matching criteria
double matchDeltaR_Leptons_;
double matchDeltaR_Jets_;
double TauPtCut_;
//optional: filter candidates by passed cuts
std::string recoCuts_, genCuts_;
// output histograms
bool saveoutputhistograms_, turnOnTrigger_;
// Reference Collection
edm::InputTag refCollectionInputTag_;
edm::EDGetTokenT<edm::View<reco::Candidate> > refCollectionInputTagToken_;
edm::EDGetTokenT<reco::PFTauCollection> tauProducerInputTagToken_;
edm::EDGetTokenT<reco::VertexCollection> primaryVertexCollectionToken_;
std::vector<edm::EDGetTokenT<reco::PFTauDiscriminator> > currentDiscriminatorToken_;
std::vector<std::pair<edm::EDGetTokenT<reco::TauDiscriminatorContainer>, int> > currentDiscriminatorContainerToken_;
std::vector<std::string> currentDiscriminatorContainerProvCfgName_;
std::vector<std::pair<std::string, std::string> > currentDiscriminatorContainerIdName_;
edm::ProcessHistoryID phID_;
std::string refCollection_;
// In case you need to distinguish the output file
std::string extensionName_;
// Reconstructed product of interest
edm::InputTag TauProducerInputTag_, PrimaryVertexCollection_;
std::string TauProducer_;
// std::vector<std::string> TauProducerDiscriminators_;
// std::vector<double> TauDiscriminatorCuts_;
std::vector<edm::ParameterSet> discriminators_;
// CMSSW version
std::string tversion;
std::string outPutFile_;
std::map<std::string, MonitorElement*> ptTauVisibleMap;
std::map<std::string, MonitorElement*> etaTauVisibleMap;
std::map<std::string, MonitorElement*> phiTauVisibleMap;
std::map<std::string, MonitorElement*> pileupTauVisibleMap;
std::map<std::string, MonitorElement*> nTauVisibleMap;
std::map<std::string, MonitorElement*> massTauVisibleMap;
std::map<std::string, MonitorElement*> plotMap_;
std::map<std::string, MonitorElement*> summaryMap;
std::map<std::string, int> tauDecayCountMap_;
MonitorElement* nTaus_;
// All the extra MonitorElements that we would like to add for each Tau Tagging step
// First for the PFTaus
// Number of PFTau Candidates with a leading charged hadron in it (within a cone of 0.1 avound the jet axis and a minimum pt of 6 GeV)
MonitorElement* nPFJet_LeadingChargedHadron_ChargedHadronsSignal_;
MonitorElement* nPFJet_LeadingChargedHadron_ChargedHadronsIsolAnnulus_;
MonitorElement* nPFJet_LeadingChargedHadron_GammasSignal_;
MonitorElement* nPFJet_LeadingChargedHadron_GammasIsolAnnulus_;
MonitorElement* nPFJet_LeadingChargedHadron_NeutralHadronsSignal_;
MonitorElement* nPFJet_LeadingChargedHadron_NeutralHadronsIsolAnnulus_;
// Isolated PFTau with a Leading charged hadron with no Charged Hadrons inside the isolation annulus
MonitorElement* nIsolated_NoChargedHadrons_ChargedHadronsSignal_;
MonitorElement* nIsolated_NoChargedHadrons_GammasSignal_;
MonitorElement* nIsolated_NoChargedHadrons_GammasIsolAnnulus_;
MonitorElement* nIsolated_NoChargedHadrons_NeutralHadronsSignal_;
MonitorElement* nIsolated_NoChargedHadrons_NeutralHadronsIsolAnnulus_;
// Isolated PFTau with a Leading charge hadron with no Charged Hadron inside the isolation annulus with no Ecal/Gamma candidates in the isolation annulus
MonitorElement* nIsolated_NoChargedNoGammas_ChargedHadronsSignal_;
MonitorElement* nIsolated_NoChargedNoGammas_GammasSignal_;
MonitorElement* nIsolated_NoChargedNoGammas_NeutralHadronsSignal_;
MonitorElement* nIsolated_NoChargedNoGammas_NeutralHadronsIsolAnnulus_;
// book-keeping variables
int numEvents_;
protected:
PFBenchmarkAlgo* algo_;
private:
bool chainCuts_;
};
#endif
| 36.308108 | 155 | 0.790829 | [
"vector"
] |
b11a9c93e78029e43f7e5900d6a2be184b843223 | 48,912 | c | C | fs/xfs/xfs_qm.c | CaelestisZ/HeraQ | 2804afc99bf59c43740038833077ef7b14993592 | [
"MIT"
] | null | null | null | fs/xfs/xfs_qm.c | CaelestisZ/HeraQ | 2804afc99bf59c43740038833077ef7b14993592 | [
"MIT"
] | null | null | null | fs/xfs/xfs_qm.c | CaelestisZ/HeraQ | 2804afc99bf59c43740038833077ef7b14993592 | [
"MIT"
] | null | null | null | /*
* Copyright (c) 2000-2005 Silicon Graphics, Inc.
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "xfs.h"
#include "xfs_fs.h"
#include "xfs_shared.h"
#include "xfs_format.h"
#include "xfs_log_format.h"
#include "xfs_trans_resv.h"
#include "xfs_bit.h"
#include "xfs_sb.h"
#include "xfs_ag.h"
#include "xfs_mount.h"
#include "xfs_inode.h"
#include "xfs_ialloc.h"
#include "xfs_itable.h"
#include "xfs_quota.h"
#include "xfs_error.h"
#include "xfs_bmap.h"
#include "xfs_bmap_btree.h"
#include "xfs_trans.h"
#include "xfs_trans_space.h"
#include "xfs_qm.h"
#include "xfs_trace.h"
#include "xfs_icache.h"
#include "xfs_cksum.h"
#include "xfs_dinode.h"
/*
* The global quota manager. There is only one of these for the entire
* system, _not_ one per file system. XQM keeps track of the overall
* quota functionality, including maintaining the freelist and hash
* tables of dquots.
*/
STATIC int xfs_qm_init_quotainos(xfs_mount_t *);
STATIC int xfs_qm_init_quotainfo(xfs_mount_t *);
STATIC void xfs_qm_destroy_quotainos(xfs_quotainfo_t *qi);
STATIC void xfs_qm_dqfree_one(struct xfs_dquot *dqp);
/*
* We use the batch lookup interface to iterate over the dquots as it
* currently is the only interface into the radix tree code that allows
* fuzzy lookups instead of exact matches. Holding the lock over multiple
* operations is fine as all callers are used either during mount/umount
* or quotaoff.
*/
#define XFS_DQ_LOOKUP_BATCH 32
STATIC int
xfs_qm_dquot_walk(
struct xfs_mount *mp,
int type,
int (*execute)(struct xfs_dquot *dqp, void *data),
void *data)
{
struct xfs_quotainfo *qi = mp->m_quotainfo;
struct radix_tree_root *tree = xfs_dquot_tree(qi, type);
uint32_t next_index;
int last_error = 0;
int skipped;
int nr_found;
restart:
skipped = 0;
next_index = 0;
nr_found = 0;
while (1) {
struct xfs_dquot *batch[XFS_DQ_LOOKUP_BATCH];
int error = 0;
int i;
mutex_lock(&qi->qi_tree_lock);
nr_found = radix_tree_gang_lookup(tree, (void **)batch,
next_index, XFS_DQ_LOOKUP_BATCH);
if (!nr_found) {
mutex_unlock(&qi->qi_tree_lock);
break;
}
for (i = 0; i < nr_found; i++) {
struct xfs_dquot *dqp = batch[i];
next_index = be32_to_cpu(dqp->q_core.d_id) + 1;
error = execute(batch[i], data);
if (error == -EAGAIN) {
skipped++;
continue;
}
if (error && last_error != -EFSCORRUPTED)
last_error = error;
}
mutex_unlock(&qi->qi_tree_lock);
/* bail out if the filesystem is corrupted. */
if (last_error == -EFSCORRUPTED) {
skipped = 0;
break;
}
}
if (skipped) {
delay(1);
goto restart;
}
return last_error;
}
/*
* Purge a dquot from all tracking data structures and free it.
*/
STATIC int
xfs_qm_dqpurge(
struct xfs_dquot *dqp,
void *data)
{
struct xfs_mount *mp = dqp->q_mount;
struct xfs_quotainfo *qi = mp->m_quotainfo;
xfs_dqlock(dqp);
if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) {
xfs_dqunlock(dqp);
return -EAGAIN;
}
dqp->dq_flags |= XFS_DQ_FREEING;
xfs_dqflock(dqp);
/*
* If we are turning this type of quotas off, we don't care
* about the dirty metadata sitting in this dquot. OTOH, if
* we're unmounting, we do care, so we flush it and wait.
*/
if (XFS_DQ_IS_DIRTY(dqp)) {
struct xfs_buf *bp = NULL;
int error;
/*
* We don't care about getting disk errors here. We need
* to purge this dquot anyway, so we go ahead regardless.
*/
error = xfs_qm_dqflush(dqp, &bp);
if (error) {
xfs_warn(mp, "%s: dquot %p flush failed",
__func__, dqp);
} else {
error = xfs_bwrite(bp);
xfs_buf_relse(bp);
}
xfs_dqflock(dqp);
}
ASSERT(atomic_read(&dqp->q_pincount) == 0);
ASSERT(XFS_FORCED_SHUTDOWN(mp) ||
!(dqp->q_logitem.qli_item.li_flags & XFS_LI_IN_AIL));
xfs_dqfunlock(dqp);
xfs_dqunlock(dqp);
radix_tree_delete(xfs_dquot_tree(qi, dqp->q_core.d_flags),
be32_to_cpu(dqp->q_core.d_id));
qi->qi_dquots--;
/*
* We move dquots to the freelist as soon as their reference count
* hits zero, so it really should be on the freelist here.
*/
ASSERT(!list_empty(&dqp->q_lru));
list_lru_del(&qi->qi_lru, &dqp->q_lru);
XFS_STATS_DEC(xs_qm_dquot_unused);
xfs_qm_dqdestroy(dqp);
return 0;
}
/*
* Purge the dquot cache.
*/
void
xfs_qm_dqpurge_all(
struct xfs_mount *mp,
uint flags)
{
if (flags & XFS_QMOPT_UQUOTA)
xfs_qm_dquot_walk(mp, XFS_DQ_USER, xfs_qm_dqpurge, NULL);
if (flags & XFS_QMOPT_GQUOTA)
xfs_qm_dquot_walk(mp, XFS_DQ_GROUP, xfs_qm_dqpurge, NULL);
if (flags & XFS_QMOPT_PQUOTA)
xfs_qm_dquot_walk(mp, XFS_DQ_PROJ, xfs_qm_dqpurge, NULL);
}
/*
* Just destroy the quotainfo structure.
*/
void
xfs_qm_unmount(
struct xfs_mount *mp)
{
if (mp->m_quotainfo) {
xfs_qm_dqpurge_all(mp, XFS_QMOPT_QUOTALL);
xfs_qm_destroy_quotainfo(mp);
}
}
/*
* Called from the vfsops layer.
*/
void
xfs_qm_unmount_quotas(
xfs_mount_t *mp)
{
/*
* Release the dquots that root inode, et al might be holding,
* before we flush quotas and blow away the quotainfo structure.
*/
ASSERT(mp->m_rootip);
xfs_qm_dqdetach(mp->m_rootip);
if (mp->m_rbmip)
xfs_qm_dqdetach(mp->m_rbmip);
if (mp->m_rsumip)
xfs_qm_dqdetach(mp->m_rsumip);
/*
* Release the quota inodes.
*/
if (mp->m_quotainfo) {
if (mp->m_quotainfo->qi_uquotaip) {
IRELE(mp->m_quotainfo->qi_uquotaip);
mp->m_quotainfo->qi_uquotaip = NULL;
}
if (mp->m_quotainfo->qi_gquotaip) {
IRELE(mp->m_quotainfo->qi_gquotaip);
mp->m_quotainfo->qi_gquotaip = NULL;
}
if (mp->m_quotainfo->qi_pquotaip) {
IRELE(mp->m_quotainfo->qi_pquotaip);
mp->m_quotainfo->qi_pquotaip = NULL;
}
}
}
STATIC int
xfs_qm_dqattach_one(
xfs_inode_t *ip,
xfs_dqid_t id,
uint type,
uint doalloc,
xfs_dquot_t **IO_idqpp)
{
xfs_dquot_t *dqp;
int error;
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
error = 0;
/*
* See if we already have it in the inode itself. IO_idqpp is &i_udquot
* or &i_gdquot. This made the code look weird, but made the logic a lot
* simpler.
*/
dqp = *IO_idqpp;
if (dqp) {
trace_xfs_dqattach_found(dqp);
return 0;
}
/*
* Find the dquot from somewhere. This bumps the reference count of
* dquot and returns it locked. This can return ENOENT if dquot didn't
* exist on disk and we didn't ask it to allocate; ESRCH if quotas got
* turned off suddenly.
*/
error = xfs_qm_dqget(ip->i_mount, ip, id, type,
doalloc | XFS_QMOPT_DOWARN, &dqp);
if (error)
return error;
trace_xfs_dqattach_get(dqp);
/*
* dqget may have dropped and re-acquired the ilock, but it guarantees
* that the dquot returned is the one that should go in the inode.
*/
*IO_idqpp = dqp;
xfs_dqunlock(dqp);
return 0;
}
static bool
xfs_qm_need_dqattach(
struct xfs_inode *ip)
{
struct xfs_mount *mp = ip->i_mount;
if (!XFS_IS_QUOTA_RUNNING(mp))
return false;
if (!XFS_IS_QUOTA_ON(mp))
return false;
if (!XFS_NOT_DQATTACHED(mp, ip))
return false;
if (xfs_is_quota_inode(&mp->m_sb, ip->i_ino))
return false;
return true;
}
/*
* Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON
* into account.
* If XFS_QMOPT_DQALLOC, the dquot(s) will be allocated if needed.
* Inode may get unlocked and relocked in here, and the caller must deal with
* the consequences.
*/
int
xfs_qm_dqattach_locked(
xfs_inode_t *ip,
uint flags)
{
xfs_mount_t *mp = ip->i_mount;
int error = 0;
if (!xfs_qm_need_dqattach(ip))
return 0;
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
if (XFS_IS_UQUOTA_ON(mp) && !ip->i_udquot) {
error = xfs_qm_dqattach_one(ip, ip->i_d.di_uid, XFS_DQ_USER,
flags & XFS_QMOPT_DQALLOC,
&ip->i_udquot);
if (error)
goto done;
ASSERT(ip->i_udquot);
}
if (XFS_IS_GQUOTA_ON(mp) && !ip->i_gdquot) {
error = xfs_qm_dqattach_one(ip, ip->i_d.di_gid, XFS_DQ_GROUP,
flags & XFS_QMOPT_DQALLOC,
&ip->i_gdquot);
if (error)
goto done;
ASSERT(ip->i_gdquot);
}
if (XFS_IS_PQUOTA_ON(mp) && !ip->i_pdquot) {
error = xfs_qm_dqattach_one(ip, xfs_get_projid(ip), XFS_DQ_PROJ,
flags & XFS_QMOPT_DQALLOC,
&ip->i_pdquot);
if (error)
goto done;
ASSERT(ip->i_pdquot);
}
done:
/*
* Don't worry about the dquots that we may have attached before any
* error - they'll get detached later if it has not already been done.
*/
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
return error;
}
int
xfs_qm_dqattach(
struct xfs_inode *ip,
uint flags)
{
int error;
if (!xfs_qm_need_dqattach(ip))
return 0;
xfs_ilock(ip, XFS_ILOCK_EXCL);
error = xfs_qm_dqattach_locked(ip, flags);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error;
}
/*
* Release dquots (and their references) if any.
* The inode should be locked EXCL except when this's called by
* xfs_ireclaim.
*/
void
xfs_qm_dqdetach(
xfs_inode_t *ip)
{
if (!(ip->i_udquot || ip->i_gdquot || ip->i_pdquot))
return;
trace_xfs_dquot_dqdetach(ip);
ASSERT(!xfs_is_quota_inode(&ip->i_mount->m_sb, ip->i_ino));
if (ip->i_udquot) {
xfs_qm_dqrele(ip->i_udquot);
ip->i_udquot = NULL;
}
if (ip->i_gdquot) {
xfs_qm_dqrele(ip->i_gdquot);
ip->i_gdquot = NULL;
}
if (ip->i_pdquot) {
xfs_qm_dqrele(ip->i_pdquot);
ip->i_pdquot = NULL;
}
}
struct xfs_qm_isolate {
struct list_head buffers;
struct list_head dispose;
};
static enum lru_status
xfs_qm_dquot_isolate(
struct list_head *item,
spinlock_t *lru_lock,
void *arg)
__releases(lru_lock) __acquires(lru_lock)
{
struct xfs_dquot *dqp = container_of(item,
struct xfs_dquot, q_lru);
struct xfs_qm_isolate *isol = arg;
if (!xfs_dqlock_nowait(dqp))
goto out_miss_busy;
/*
* This dquot has acquired a reference in the meantime remove it from
* the freelist and try again.
*/
if (dqp->q_nrefs) {
xfs_dqunlock(dqp);
XFS_STATS_INC(xs_qm_dqwants);
trace_xfs_dqreclaim_want(dqp);
list_del_init(&dqp->q_lru);
XFS_STATS_DEC(xs_qm_dquot_unused);
return LRU_REMOVED;
}
/*
* If the dquot is dirty, flush it. If it's already being flushed, just
* skip it so there is time for the IO to complete before we try to
* reclaim it again on the next LRU pass.
*/
if (!xfs_dqflock_nowait(dqp)) {
xfs_dqunlock(dqp);
goto out_miss_busy;
}
if (XFS_DQ_IS_DIRTY(dqp)) {
struct xfs_buf *bp = NULL;
int error;
trace_xfs_dqreclaim_dirty(dqp);
/* we have to drop the LRU lock to flush the dquot */
spin_unlock(lru_lock);
error = xfs_qm_dqflush(dqp, &bp);
if (error) {
xfs_warn(dqp->q_mount, "%s: dquot %p flush failed",
__func__, dqp);
goto out_unlock_dirty;
}
xfs_buf_delwri_queue(bp, &isol->buffers);
xfs_buf_relse(bp);
goto out_unlock_dirty;
}
xfs_dqfunlock(dqp);
/*
* Prevent lookups now that we are past the point of no return.
*/
dqp->dq_flags |= XFS_DQ_FREEING;
xfs_dqunlock(dqp);
ASSERT(dqp->q_nrefs == 0);
list_move_tail(&dqp->q_lru, &isol->dispose);
XFS_STATS_DEC(xs_qm_dquot_unused);
trace_xfs_dqreclaim_done(dqp);
XFS_STATS_INC(xs_qm_dqreclaims);
return LRU_REMOVED;
out_miss_busy:
trace_xfs_dqreclaim_busy(dqp);
XFS_STATS_INC(xs_qm_dqreclaim_misses);
return LRU_SKIP;
out_unlock_dirty:
trace_xfs_dqreclaim_busy(dqp);
XFS_STATS_INC(xs_qm_dqreclaim_misses);
xfs_dqunlock(dqp);
spin_lock(lru_lock);
return LRU_RETRY;
}
static unsigned long
xfs_qm_shrink_scan(
struct shrinker *shrink,
struct shrink_control *sc)
{
struct xfs_quotainfo *qi = container_of(shrink,
struct xfs_quotainfo, qi_shrinker);
struct xfs_qm_isolate isol;
unsigned long freed;
int error;
unsigned long nr_to_scan = sc->nr_to_scan;
if ((sc->gfp_mask & (__GFP_FS|__GFP_WAIT)) != (__GFP_FS|__GFP_WAIT))
return 0;
INIT_LIST_HEAD(&isol.buffers);
INIT_LIST_HEAD(&isol.dispose);
freed = list_lru_walk_node(&qi->qi_lru, sc->nid, xfs_qm_dquot_isolate, &isol,
&nr_to_scan);
error = xfs_buf_delwri_submit(&isol.buffers);
if (error)
xfs_warn(NULL, "%s: dquot reclaim failed", __func__);
while (!list_empty(&isol.dispose)) {
struct xfs_dquot *dqp;
dqp = list_first_entry(&isol.dispose, struct xfs_dquot, q_lru);
list_del_init(&dqp->q_lru);
xfs_qm_dqfree_one(dqp);
}
return freed;
}
static unsigned long
xfs_qm_shrink_count(
struct shrinker *shrink,
struct shrink_control *sc)
{
struct xfs_quotainfo *qi = container_of(shrink,
struct xfs_quotainfo, qi_shrinker);
return list_lru_count_node(&qi->qi_lru, sc->nid);
}
/*
* This initializes all the quota information that's kept in the
* mount structure
*/
STATIC int
xfs_qm_init_quotainfo(
xfs_mount_t *mp)
{
xfs_quotainfo_t *qinf;
int error;
xfs_dquot_t *dqp;
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP);
error = list_lru_init(&qinf->qi_lru);
if (error)
goto out_free_qinf;
/*
* See if quotainodes are setup, and if not, allocate them,
* and change the superblock accordingly.
*/
error = xfs_qm_init_quotainos(mp);
if (error)
goto out_free_lru;
INIT_RADIX_TREE(&qinf->qi_uquota_tree, GFP_NOFS);
INIT_RADIX_TREE(&qinf->qi_gquota_tree, GFP_NOFS);
INIT_RADIX_TREE(&qinf->qi_pquota_tree, GFP_NOFS);
mutex_init(&qinf->qi_tree_lock);
/* mutex used to serialize quotaoffs */
mutex_init(&qinf->qi_quotaofflock);
/* Precalc some constants */
qinf->qi_dqchunklen = XFS_FSB_TO_BB(mp, XFS_DQUOT_CLUSTER_SIZE_FSB);
qinf->qi_dqperchunk = xfs_calc_dquots_per_chunk(qinf->qi_dqchunklen);
mp->m_qflags |= (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_CHKD);
/*
* We try to get the limits from the superuser's limits fields.
* This is quite hacky, but it is standard quota practice.
*
* We look at the USR dquot with id == 0 first, but if user quotas
* are not enabled we goto the GRP dquot with id == 0.
* We don't really care to keep separate default limits for user
* and group quotas, at least not at this point.
*
* Since we may not have done a quotacheck by this point, just read
* the dquot without attaching it to any hashtables or lists.
*/
error = xfs_qm_dqread(mp, 0,
XFS_IS_UQUOTA_RUNNING(mp) ? XFS_DQ_USER :
(XFS_IS_GQUOTA_RUNNING(mp) ? XFS_DQ_GROUP :
XFS_DQ_PROJ),
XFS_QMOPT_DOWARN, &dqp);
if (!error) {
xfs_disk_dquot_t *ddqp = &dqp->q_core;
/*
* The warnings and timers set the grace period given to
* a user or group before he or she can not perform any
* more writing. If it is zero, a default is used.
*/
qinf->qi_btimelimit = ddqp->d_btimer ?
be32_to_cpu(ddqp->d_btimer) : XFS_QM_BTIMELIMIT;
qinf->qi_itimelimit = ddqp->d_itimer ?
be32_to_cpu(ddqp->d_itimer) : XFS_QM_ITIMELIMIT;
qinf->qi_rtbtimelimit = ddqp->d_rtbtimer ?
be32_to_cpu(ddqp->d_rtbtimer) : XFS_QM_RTBTIMELIMIT;
qinf->qi_bwarnlimit = ddqp->d_bwarns ?
be16_to_cpu(ddqp->d_bwarns) : XFS_QM_BWARNLIMIT;
qinf->qi_iwarnlimit = ddqp->d_iwarns ?
be16_to_cpu(ddqp->d_iwarns) : XFS_QM_IWARNLIMIT;
qinf->qi_rtbwarnlimit = ddqp->d_rtbwarns ?
be16_to_cpu(ddqp->d_rtbwarns) : XFS_QM_RTBWARNLIMIT;
qinf->qi_bhardlimit = be64_to_cpu(ddqp->d_blk_hardlimit);
qinf->qi_bsoftlimit = be64_to_cpu(ddqp->d_blk_softlimit);
qinf->qi_ihardlimit = be64_to_cpu(ddqp->d_ino_hardlimit);
qinf->qi_isoftlimit = be64_to_cpu(ddqp->d_ino_softlimit);
qinf->qi_rtbhardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit);
qinf->qi_rtbsoftlimit = be64_to_cpu(ddqp->d_rtb_softlimit);
xfs_qm_dqdestroy(dqp);
} else {
qinf->qi_btimelimit = XFS_QM_BTIMELIMIT;
qinf->qi_itimelimit = XFS_QM_ITIMELIMIT;
qinf->qi_rtbtimelimit = XFS_QM_RTBTIMELIMIT;
qinf->qi_bwarnlimit = XFS_QM_BWARNLIMIT;
qinf->qi_iwarnlimit = XFS_QM_IWARNLIMIT;
qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
}
qinf->qi_shrinker.count_objects = xfs_qm_shrink_count;
qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan;
qinf->qi_shrinker.seeks = DEFAULT_SEEKS;
qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE;
error = register_shrinker(&qinf->qi_shrinker);
if (error)
goto out_free_inos;
return 0;
out_free_inos:
mutex_destroy(&qinf->qi_quotaofflock);
mutex_destroy(&qinf->qi_tree_lock);
xfs_qm_destroy_quotainos(qinf);
out_free_lru:
list_lru_destroy(&qinf->qi_lru);
out_free_qinf:
kmem_free(qinf);
mp->m_quotainfo = NULL;
return error;
}
/*
* Gets called when unmounting a filesystem or when all quotas get
* turned off.
* This purges the quota inodes, destroys locks and frees itself.
*/
void
xfs_qm_destroy_quotainfo(
xfs_mount_t *mp)
{
xfs_quotainfo_t *qi;
qi = mp->m_quotainfo;
ASSERT(qi != NULL);
unregister_shrinker(&qi->qi_shrinker);
list_lru_destroy(&qi->qi_lru);
xfs_qm_destroy_quotainos(qi);
mutex_destroy(&qi->qi_tree_lock);
mutex_destroy(&qi->qi_quotaofflock);
kmem_free(qi);
mp->m_quotainfo = NULL;
}
/*
* Create an inode and return with a reference already taken, but unlocked
* This is how we create quota inodes
*/
STATIC int
xfs_qm_qino_alloc(
xfs_mount_t *mp,
xfs_inode_t **ip,
__int64_t sbfields,
uint flags)
{
xfs_trans_t *tp;
int error;
int committed;
*ip = NULL;
/*
* With superblock that doesn't have separate pquotino, we
* share an inode between gquota and pquota. If the on-disk
* superblock has GQUOTA and the filesystem is now mounted
* with PQUOTA, just use sb_gquotino for sb_pquotino and
* vice-versa.
*/
if (!xfs_sb_version_has_pquotino(&mp->m_sb) &&
(flags & (XFS_QMOPT_PQUOTA|XFS_QMOPT_GQUOTA))) {
xfs_ino_t ino = NULLFSINO;
if ((flags & XFS_QMOPT_PQUOTA) &&
(mp->m_sb.sb_gquotino != NULLFSINO)) {
ino = mp->m_sb.sb_gquotino;
ASSERT(mp->m_sb.sb_pquotino == NULLFSINO);
} else if ((flags & XFS_QMOPT_GQUOTA) &&
(mp->m_sb.sb_pquotino != NULLFSINO)) {
ino = mp->m_sb.sb_pquotino;
ASSERT(mp->m_sb.sb_gquotino == NULLFSINO);
}
if (ino != NULLFSINO) {
error = xfs_iget(mp, NULL, ino, 0, 0, ip);
if (error)
return error;
mp->m_sb.sb_gquotino = NULLFSINO;
mp->m_sb.sb_pquotino = NULLFSINO;
}
}
tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QINOCREATE);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_create,
XFS_QM_QINOCREATE_SPACE_RES(mp), 0);
if (error) {
xfs_trans_cancel(tp, 0);
return error;
}
if (!*ip) {
error = xfs_dir_ialloc(&tp, NULL, S_IFREG, 1, 0, 0, 1, ip,
&committed);
if (error) {
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES |
XFS_TRANS_ABORT);
return error;
}
}
/*
* Make the changes in the superblock, and log those too.
* sbfields arg may contain fields other than *QUOTINO;
* VERSIONNUM for example.
*/
spin_lock(&mp->m_sb_lock);
if (flags & XFS_QMOPT_SBVERSION) {
ASSERT(!xfs_sb_version_hasquota(&mp->m_sb));
ASSERT((sbfields & (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO |
XFS_SB_GQUOTINO | XFS_SB_PQUOTINO | XFS_SB_QFLAGS)) ==
(XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO |
XFS_SB_GQUOTINO | XFS_SB_PQUOTINO |
XFS_SB_QFLAGS));
xfs_sb_version_addquota(&mp->m_sb);
mp->m_sb.sb_uquotino = NULLFSINO;
mp->m_sb.sb_gquotino = NULLFSINO;
mp->m_sb.sb_pquotino = NULLFSINO;
/* qflags will get updated fully _after_ quotacheck */
mp->m_sb.sb_qflags = mp->m_qflags & XFS_ALL_QUOTA_ACCT;
}
if (flags & XFS_QMOPT_UQUOTA)
mp->m_sb.sb_uquotino = (*ip)->i_ino;
else if (flags & XFS_QMOPT_GQUOTA)
mp->m_sb.sb_gquotino = (*ip)->i_ino;
else
mp->m_sb.sb_pquotino = (*ip)->i_ino;
spin_unlock(&mp->m_sb_lock);
xfs_mod_sb(tp, sbfields);
if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES))) {
xfs_alert(mp, "%s failed (error %d)!", __func__, error);
return error;
}
return 0;
}
STATIC void
xfs_qm_reset_dqcounts(
xfs_mount_t *mp,
xfs_buf_t *bp,
xfs_dqid_t id,
uint type)
{
struct xfs_dqblk *dqb;
int j;
trace_xfs_reset_dqcounts(bp, _RET_IP_);
/*
* Reset all counters and timers. They'll be
* started afresh by xfs_qm_quotacheck.
*/
#ifdef DEBUG
j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB);
do_div(j, sizeof(xfs_dqblk_t));
ASSERT(mp->m_quotainfo->qi_dqperchunk == j);
#endif
dqb = bp->b_addr;
for (j = 0; j < mp->m_quotainfo->qi_dqperchunk; j++) {
struct xfs_disk_dquot *ddq;
ddq = (struct xfs_disk_dquot *)&dqb[j];
/*
* Do a sanity check, and if needed, repair the dqblk. Don't
* output any warnings because it's perfectly possible to
* find uninitialised dquot blks. See comment in xfs_dqcheck.
*/
xfs_dqcheck(mp, ddq, id+j, type, XFS_QMOPT_DQREPAIR,
"xfs_quotacheck");
/*
* Reset type in case we are reusing group quota file for
* project quotas or vice versa
*/
ddq->d_flags = type;
ddq->d_bcount = 0;
ddq->d_icount = 0;
ddq->d_rtbcount = 0;
ddq->d_btimer = 0;
ddq->d_itimer = 0;
ddq->d_rtbtimer = 0;
ddq->d_bwarns = 0;
ddq->d_iwarns = 0;
ddq->d_rtbwarns = 0;
if (xfs_sb_version_hascrc(&mp->m_sb)) {
xfs_update_cksum((char *)&dqb[j],
sizeof(struct xfs_dqblk),
XFS_DQUOT_CRC_OFF);
}
}
}
STATIC int
xfs_qm_dqiter_bufs(
struct xfs_mount *mp,
xfs_dqid_t firstid,
xfs_fsblock_t bno,
xfs_filblks_t blkcnt,
uint flags,
struct list_head *buffer_list)
{
struct xfs_buf *bp;
int error;
int type;
ASSERT(blkcnt > 0);
type = flags & XFS_QMOPT_UQUOTA ? XFS_DQ_USER :
(flags & XFS_QMOPT_PQUOTA ? XFS_DQ_PROJ : XFS_DQ_GROUP);
error = 0;
/*
* Blkcnt arg can be a very big number, and might even be
* larger than the log itself. So, we have to break it up into
* manageable-sized transactions.
* Note that we don't start a permanent transaction here; we might
* not be able to get a log reservation for the whole thing up front,
* and we don't really care to either, because we just discard
* everything if we were to crash in the middle of this loop.
*/
while (blkcnt--) {
error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
XFS_FSB_TO_DADDR(mp, bno),
mp->m_quotainfo->qi_dqchunklen, 0, &bp,
&xfs_dquot_buf_ops);
/*
* CRC and validation errors will return a EFSCORRUPTED here. If
* this occurs, re-read without CRC validation so that we can
* repair the damage via xfs_qm_reset_dqcounts(). This process
* will leave a trace in the log indicating corruption has
* been detected.
*/
if (error == -EFSCORRUPTED) {
error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
XFS_FSB_TO_DADDR(mp, bno),
mp->m_quotainfo->qi_dqchunklen, 0, &bp,
NULL);
}
if (error)
break;
/*
* A corrupt buffer might not have a verifier attached, so
* make sure we have the correct one attached before writeback
* occurs.
*/
bp->b_ops = &xfs_dquot_buf_ops;
xfs_qm_reset_dqcounts(mp, bp, firstid, type);
xfs_buf_delwri_queue(bp, buffer_list);
xfs_buf_relse(bp);
/* goto the next block. */
bno++;
firstid += mp->m_quotainfo->qi_dqperchunk;
}
return error;
}
/*
* Iterate over all allocated USR/GRP/PRJ dquots in the system, calling a
* caller supplied function for every chunk of dquots that we find.
*/
STATIC int
xfs_qm_dqiterate(
struct xfs_mount *mp,
struct xfs_inode *qip,
uint flags,
struct list_head *buffer_list)
{
struct xfs_bmbt_irec *map;
int i, nmaps; /* number of map entries */
int error; /* return value */
xfs_fileoff_t lblkno;
xfs_filblks_t maxlblkcnt;
xfs_dqid_t firstid;
xfs_fsblock_t rablkno;
xfs_filblks_t rablkcnt;
error = 0;
/*
* This looks racy, but we can't keep an inode lock across a
* trans_reserve. But, this gets called during quotacheck, and that
* happens only at mount time which is single threaded.
*/
if (qip->i_d.di_nblocks == 0)
return 0;
map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), KM_SLEEP);
lblkno = 0;
maxlblkcnt = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
do {
uint lock_mode;
nmaps = XFS_DQITER_MAP_SIZE;
/*
* We aren't changing the inode itself. Just changing
* some of its data. No new blocks are added here, and
* the inode is never added to the transaction.
*/
lock_mode = xfs_ilock_data_map_shared(qip);
error = xfs_bmapi_read(qip, lblkno, maxlblkcnt - lblkno,
map, &nmaps, 0);
xfs_iunlock(qip, lock_mode);
if (error)
break;
ASSERT(nmaps <= XFS_DQITER_MAP_SIZE);
for (i = 0; i < nmaps; i++) {
ASSERT(map[i].br_startblock != DELAYSTARTBLOCK);
ASSERT(map[i].br_blockcount);
lblkno += map[i].br_blockcount;
if (map[i].br_startblock == HOLESTARTBLOCK)
continue;
firstid = (xfs_dqid_t) map[i].br_startoff *
mp->m_quotainfo->qi_dqperchunk;
/*
* Do a read-ahead on the next extent.
*/
if ((i+1 < nmaps) &&
(map[i+1].br_startblock != HOLESTARTBLOCK)) {
rablkcnt = map[i+1].br_blockcount;
rablkno = map[i+1].br_startblock;
while (rablkcnt--) {
xfs_buf_readahead(mp->m_ddev_targp,
XFS_FSB_TO_DADDR(mp, rablkno),
mp->m_quotainfo->qi_dqchunklen,
&xfs_dquot_buf_ops);
rablkno++;
}
}
/*
* Iterate thru all the blks in the extent and
* reset the counters of all the dquots inside them.
*/
error = xfs_qm_dqiter_bufs(mp, firstid,
map[i].br_startblock,
map[i].br_blockcount,
flags, buffer_list);
if (error)
goto out;
}
} while (nmaps > 0);
out:
kmem_free(map);
return error;
}
/*
* Called by dqusage_adjust in doing a quotacheck.
*
* Given the inode, and a dquot id this updates both the incore dqout as well
* as the buffer copy. This is so that once the quotacheck is done, we can
* just log all the buffers, as opposed to logging numerous updates to
* individual dquots.
*/
STATIC int
xfs_qm_quotacheck_dqadjust(
struct xfs_inode *ip,
xfs_dqid_t id,
uint type,
xfs_qcnt_t nblks,
xfs_qcnt_t rtblks)
{
struct xfs_mount *mp = ip->i_mount;
struct xfs_dquot *dqp;
int error;
error = xfs_qm_dqget(mp, ip, id, type,
XFS_QMOPT_DQALLOC | XFS_QMOPT_DOWARN, &dqp);
if (error) {
/*
* Shouldn't be able to turn off quotas here.
*/
ASSERT(error != -ESRCH);
ASSERT(error != -ENOENT);
return error;
}
trace_xfs_dqadjust(dqp);
/*
* Adjust the inode count and the block count to reflect this inode's
* resource usage.
*/
be64_add_cpu(&dqp->q_core.d_icount, 1);
dqp->q_res_icount++;
if (nblks) {
be64_add_cpu(&dqp->q_core.d_bcount, nblks);
dqp->q_res_bcount += nblks;
}
if (rtblks) {
be64_add_cpu(&dqp->q_core.d_rtbcount, rtblks);
dqp->q_res_rtbcount += rtblks;
}
/*
* Set default limits, adjust timers (since we changed usages)
*
* There are no timers for the default values set in the root dquot.
*/
if (dqp->q_core.d_id) {
xfs_qm_adjust_dqlimits(mp, dqp);
xfs_qm_adjust_dqtimers(mp, &dqp->q_core);
}
dqp->dq_flags |= XFS_DQ_DIRTY;
xfs_qm_dqput(dqp);
return 0;
}
STATIC int
xfs_qm_get_rtblks(
xfs_inode_t *ip,
xfs_qcnt_t *O_rtblks)
{
xfs_filblks_t rtblks; /* total rt blks */
xfs_extnum_t idx; /* extent record index */
xfs_ifork_t *ifp; /* inode fork pointer */
xfs_extnum_t nextents; /* number of extent entries */
int error;
ASSERT(XFS_IS_REALTIME_INODE(ip));
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
if ((error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK)))
return error;
}
rtblks = 0;
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
for (idx = 0; idx < nextents; idx++)
rtblks += xfs_bmbt_get_blockcount(xfs_iext_get_ext(ifp, idx));
*O_rtblks = (xfs_qcnt_t)rtblks;
return 0;
}
/*
* callback routine supplied to bulkstat(). Given an inumber, find its
* dquots and update them to account for resources taken by that inode.
*/
/* ARGSUSED */
STATIC int
xfs_qm_dqusage_adjust(
xfs_mount_t *mp, /* mount point for filesystem */
xfs_ino_t ino, /* inode number to get data for */
void __user *buffer, /* not used */
int ubsize, /* not used */
int *ubused, /* not used */
int *res) /* result code value */
{
xfs_inode_t *ip;
xfs_qcnt_t nblks, rtblks = 0;
int error;
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
/*
* rootino must have its resources accounted for, not so with the quota
* inodes.
*/
if (xfs_is_quota_inode(&mp->m_sb, ino)) {
*res = BULKSTAT_RV_NOTHING;
return -EINVAL;
}
/*
* We don't _need_ to take the ilock EXCL. However, the xfs_qm_dqget
* interface expects the inode to be exclusively locked because that's
* the case in all other instances. It's OK that we do this because
* quotacheck is done only at mount time.
*/
error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip);
if (error) {
*res = BULKSTAT_RV_NOTHING;
return error;
}
ASSERT(ip->i_delayed_blks == 0);
if (XFS_IS_REALTIME_INODE(ip)) {
/*
* Walk thru the extent list and count the realtime blocks.
*/
error = xfs_qm_get_rtblks(ip, &rtblks);
if (error)
goto error0;
}
nblks = (xfs_qcnt_t)ip->i_d.di_nblocks - rtblks;
/*
* Add the (disk blocks and inode) resources occupied by this
* inode to its dquots. We do this adjustment in the incore dquot,
* and also copy the changes to its buffer.
* We don't care about putting these changes in a transaction
* envelope because if we crash in the middle of a 'quotacheck'
* we have to start from the beginning anyway.
* Once we're done, we'll log all the dquot bufs.
*
* The *QUOTA_ON checks below may look pretty racy, but quotachecks
* and quotaoffs don't race. (Quotachecks happen at mount time only).
*/
if (XFS_IS_UQUOTA_ON(mp)) {
error = xfs_qm_quotacheck_dqadjust(ip, ip->i_d.di_uid,
XFS_DQ_USER, nblks, rtblks);
if (error)
goto error0;
}
if (XFS_IS_GQUOTA_ON(mp)) {
error = xfs_qm_quotacheck_dqadjust(ip, ip->i_d.di_gid,
XFS_DQ_GROUP, nblks, rtblks);
if (error)
goto error0;
}
if (XFS_IS_PQUOTA_ON(mp)) {
error = xfs_qm_quotacheck_dqadjust(ip, xfs_get_projid(ip),
XFS_DQ_PROJ, nblks, rtblks);
if (error)
goto error0;
}
xfs_iunlock(ip, XFS_ILOCK_EXCL);
IRELE(ip);
*res = BULKSTAT_RV_DIDONE;
return 0;
error0:
xfs_iunlock(ip, XFS_ILOCK_EXCL);
IRELE(ip);
*res = BULKSTAT_RV_GIVEUP;
return error;
}
STATIC int
xfs_qm_flush_one(
struct xfs_dquot *dqp,
void *data)
{
struct list_head *buffer_list = data;
struct xfs_buf *bp = NULL;
int error = 0;
xfs_dqlock(dqp);
if (dqp->dq_flags & XFS_DQ_FREEING)
goto out_unlock;
if (!XFS_DQ_IS_DIRTY(dqp))
goto out_unlock;
xfs_dqflock(dqp);
error = xfs_qm_dqflush(dqp, &bp);
if (error)
goto out_unlock;
xfs_buf_delwri_queue(bp, buffer_list);
xfs_buf_relse(bp);
out_unlock:
xfs_dqunlock(dqp);
return error;
}
/*
* Walk thru all the filesystem inodes and construct a consistent view
* of the disk quota world. If the quotacheck fails, disable quotas.
*/
STATIC int
xfs_qm_quotacheck(
xfs_mount_t *mp)
{
int done, count, error, error2;
xfs_ino_t lastino;
size_t structsz;
uint flags;
LIST_HEAD (buffer_list);
struct xfs_inode *uip = mp->m_quotainfo->qi_uquotaip;
struct xfs_inode *gip = mp->m_quotainfo->qi_gquotaip;
struct xfs_inode *pip = mp->m_quotainfo->qi_pquotaip;
count = INT_MAX;
structsz = 1;
lastino = 0;
flags = 0;
ASSERT(uip || gip || pip);
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
xfs_notice(mp, "Quotacheck needed: Please wait.");
/*
* First we go thru all the dquots on disk, USR and GRP/PRJ, and reset
* their counters to zero. We need a clean slate.
* We don't log our changes till later.
*/
if (uip) {
error = xfs_qm_dqiterate(mp, uip, XFS_QMOPT_UQUOTA,
&buffer_list);
if (error)
goto error_return;
flags |= XFS_UQUOTA_CHKD;
}
if (gip) {
error = xfs_qm_dqiterate(mp, gip, XFS_QMOPT_GQUOTA,
&buffer_list);
if (error)
goto error_return;
flags |= XFS_GQUOTA_CHKD;
}
if (pip) {
error = xfs_qm_dqiterate(mp, pip, XFS_QMOPT_PQUOTA,
&buffer_list);
if (error)
goto error_return;
flags |= XFS_PQUOTA_CHKD;
}
do {
/*
* Iterate thru all the inodes in the file system,
* adjusting the corresponding dquot counters in core.
*/
error = xfs_bulkstat(mp, &lastino, &count,
xfs_qm_dqusage_adjust,
structsz, NULL, &done);
if (error)
break;
} while (!done);
/*
* We've made all the changes that we need to make incore. Flush them
* down to disk buffers if everything was updated successfully.
*/
if (XFS_IS_UQUOTA_ON(mp)) {
error = xfs_qm_dquot_walk(mp, XFS_DQ_USER, xfs_qm_flush_one,
&buffer_list);
}
if (XFS_IS_GQUOTA_ON(mp)) {
error2 = xfs_qm_dquot_walk(mp, XFS_DQ_GROUP, xfs_qm_flush_one,
&buffer_list);
if (!error)
error = error2;
}
if (XFS_IS_PQUOTA_ON(mp)) {
error2 = xfs_qm_dquot_walk(mp, XFS_DQ_PROJ, xfs_qm_flush_one,
&buffer_list);
if (!error)
error = error2;
}
error2 = xfs_buf_delwri_submit(&buffer_list);
if (!error)
error = error2;
/*
* We can get this error if we couldn't do a dquot allocation inside
* xfs_qm_dqusage_adjust (via bulkstat). We don't care about the
* dirty dquots that might be cached, we just want to get rid of them
* and turn quotaoff. The dquots won't be attached to any of the inodes
* at this point (because we intentionally didn't in dqget_noattach).
*/
if (error) {
xfs_qm_dqpurge_all(mp, XFS_QMOPT_QUOTALL);
goto error_return;
}
/*
* If one type of quotas is off, then it will lose its
* quotachecked status, since we won't be doing accounting for
* that type anymore.
*/
mp->m_qflags &= ~XFS_ALL_QUOTA_CHKD;
mp->m_qflags |= flags;
error_return:
xfs_buf_delwri_cancel(&buffer_list);
if (error) {
xfs_warn(mp,
"Quotacheck: Unsuccessful (Error %d): Disabling quotas.",
error);
/*
* We must turn off quotas.
*/
ASSERT(mp->m_quotainfo != NULL);
xfs_qm_destroy_quotainfo(mp);
if (xfs_mount_reset_sbqflags(mp)) {
xfs_warn(mp,
"Quotacheck: Failed to reset quota flags.");
}
} else
xfs_notice(mp, "Quotacheck: Done.");
return error;
}
/*
* This is called from xfs_mountfs to start quotas and initialize all
* necessary data structures like quotainfo. This is also responsible for
* running a quotacheck as necessary. We are guaranteed that the superblock
* is consistently read in at this point.
*
* If we fail here, the mount will continue with quota turned off. We don't
* need to inidicate success or failure at all.
*/
void
xfs_qm_mount_quotas(
struct xfs_mount *mp)
{
int error = 0;
uint sbf;
/*
* If quotas on realtime volumes is not supported, we disable
* quotas immediately.
*/
if (mp->m_sb.sb_rextents) {
xfs_notice(mp, "Cannot turn on quotas for realtime filesystem");
mp->m_qflags = 0;
goto write_changes;
}
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
/*
* Allocate the quotainfo structure inside the mount struct, and
* create quotainode(s), and change/rev superblock if necessary.
*/
error = xfs_qm_init_quotainfo(mp);
if (error) {
/*
* We must turn off quotas.
*/
ASSERT(mp->m_quotainfo == NULL);
mp->m_qflags = 0;
goto write_changes;
}
/*
* If any of the quotas are not consistent, do a quotacheck.
*/
if (XFS_QM_NEED_QUOTACHECK(mp)) {
error = xfs_qm_quotacheck(mp);
if (error) {
/* Quotacheck failed and disabled quotas. */
return;
}
}
/*
* If one type of quotas is off, then it will lose its
* quotachecked status, since we won't be doing accounting for
* that type anymore.
*/
if (!XFS_IS_UQUOTA_ON(mp))
mp->m_qflags &= ~XFS_UQUOTA_CHKD;
if (!XFS_IS_GQUOTA_ON(mp))
mp->m_qflags &= ~XFS_GQUOTA_CHKD;
if (!XFS_IS_PQUOTA_ON(mp))
mp->m_qflags &= ~XFS_PQUOTA_CHKD;
write_changes:
/*
* We actually don't have to acquire the m_sb_lock at all.
* This can only be called from mount, and that's single threaded. XXX
*/
spin_lock(&mp->m_sb_lock);
sbf = mp->m_sb.sb_qflags;
mp->m_sb.sb_qflags = mp->m_qflags & XFS_MOUNT_QUOTA_ALL;
spin_unlock(&mp->m_sb_lock);
if (sbf != (mp->m_qflags & XFS_MOUNT_QUOTA_ALL)) {
if (xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS)) {
/*
* We could only have been turning quotas off.
* We aren't in very good shape actually because
* the incore structures are convinced that quotas are
* off, but the on disk superblock doesn't know that !
*/
ASSERT(!(XFS_IS_QUOTA_RUNNING(mp)));
xfs_alert(mp, "%s: Superblock update failed!",
__func__);
}
}
if (error) {
xfs_warn(mp, "Failed to initialize disk quotas.");
return;
}
}
/*
* This is called after the superblock has been read in and we're ready to
* iget the quota inodes.
*/
STATIC int
xfs_qm_init_quotainos(
xfs_mount_t *mp)
{
struct xfs_inode *uip = NULL;
struct xfs_inode *gip = NULL;
struct xfs_inode *pip = NULL;
int error;
__int64_t sbflags = 0;
uint flags = 0;
ASSERT(mp->m_quotainfo);
/*
* Get the uquota and gquota inodes
*/
if (xfs_sb_version_hasquota(&mp->m_sb)) {
if (XFS_IS_UQUOTA_ON(mp) &&
mp->m_sb.sb_uquotino != NULLFSINO) {
ASSERT(mp->m_sb.sb_uquotino > 0);
error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
0, 0, &uip);
if (error)
return error;
}
if (XFS_IS_GQUOTA_ON(mp) &&
mp->m_sb.sb_gquotino != NULLFSINO) {
ASSERT(mp->m_sb.sb_gquotino > 0);
error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
0, 0, &gip);
if (error)
goto error_rele;
}
if (XFS_IS_PQUOTA_ON(mp) &&
mp->m_sb.sb_pquotino != NULLFSINO) {
ASSERT(mp->m_sb.sb_pquotino > 0);
error = xfs_iget(mp, NULL, mp->m_sb.sb_pquotino,
0, 0, &pip);
if (error)
goto error_rele;
}
} else {
flags |= XFS_QMOPT_SBVERSION;
sbflags |= (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO |
XFS_SB_GQUOTINO | XFS_SB_PQUOTINO |
XFS_SB_QFLAGS);
}
/*
* Create the three inodes, if they don't exist already. The changes
* made above will get added to a transaction and logged in one of
* the qino_alloc calls below. If the device is readonly,
* temporarily switch to read-write to do this.
*/
if (XFS_IS_UQUOTA_ON(mp) && uip == NULL) {
error = xfs_qm_qino_alloc(mp, &uip,
sbflags | XFS_SB_UQUOTINO,
flags | XFS_QMOPT_UQUOTA);
if (error)
goto error_rele;
flags &= ~XFS_QMOPT_SBVERSION;
}
if (XFS_IS_GQUOTA_ON(mp) && gip == NULL) {
error = xfs_qm_qino_alloc(mp, &gip,
sbflags | XFS_SB_GQUOTINO,
flags | XFS_QMOPT_GQUOTA);
if (error)
goto error_rele;
flags &= ~XFS_QMOPT_SBVERSION;
}
if (XFS_IS_PQUOTA_ON(mp) && pip == NULL) {
error = xfs_qm_qino_alloc(mp, &pip,
sbflags | XFS_SB_PQUOTINO,
flags | XFS_QMOPT_PQUOTA);
if (error)
goto error_rele;
}
mp->m_quotainfo->qi_uquotaip = uip;
mp->m_quotainfo->qi_gquotaip = gip;
mp->m_quotainfo->qi_pquotaip = pip;
return 0;
error_rele:
if (uip)
IRELE(uip);
if (gip)
IRELE(gip);
if (pip)
IRELE(pip);
return error;
}
STATIC void
xfs_qm_destroy_quotainos(
xfs_quotainfo_t *qi)
{
if (qi->qi_uquotaip) {
IRELE(qi->qi_uquotaip);
qi->qi_uquotaip = NULL; /* paranoia */
}
if (qi->qi_gquotaip) {
IRELE(qi->qi_gquotaip);
qi->qi_gquotaip = NULL;
}
if (qi->qi_pquotaip) {
IRELE(qi->qi_pquotaip);
qi->qi_pquotaip = NULL;
}
}
STATIC void
xfs_qm_dqfree_one(
struct xfs_dquot *dqp)
{
struct xfs_mount *mp = dqp->q_mount;
struct xfs_quotainfo *qi = mp->m_quotainfo;
mutex_lock(&qi->qi_tree_lock);
radix_tree_delete(xfs_dquot_tree(qi, dqp->q_core.d_flags),
be32_to_cpu(dqp->q_core.d_id));
qi->qi_dquots--;
mutex_unlock(&qi->qi_tree_lock);
xfs_qm_dqdestroy(dqp);
}
/*
* Start a transaction and write the incore superblock changes to
* disk. flags parameter indicates which fields have changed.
*/
int
xfs_qm_write_sb_changes(
xfs_mount_t *mp,
__int64_t flags)
{
xfs_trans_t *tp;
int error;
tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_sbchange, 0, 0);
if (error) {
xfs_trans_cancel(tp, 0);
return error;
}
xfs_mod_sb(tp, flags);
error = xfs_trans_commit(tp, 0);
return error;
}
/* --------------- utility functions for vnodeops ---------------- */
/*
* Given an inode, a uid, gid and prid make sure that we have
* allocated relevant dquot(s) on disk, and that we won't exceed inode
* quotas by creating this file.
* This also attaches dquot(s) to the given inode after locking it,
* and returns the dquots corresponding to the uid and/or gid.
*
* in : inode (unlocked)
* out : udquot, gdquot with references taken and unlocked
*/
int
xfs_qm_vop_dqalloc(
struct xfs_inode *ip,
xfs_dqid_t uid,
xfs_dqid_t gid,
prid_t prid,
uint flags,
struct xfs_dquot **O_udqpp,
struct xfs_dquot **O_gdqpp,
struct xfs_dquot **O_pdqpp)
{
struct xfs_mount *mp = ip->i_mount;
struct xfs_dquot *uq = NULL;
struct xfs_dquot *gq = NULL;
struct xfs_dquot *pq = NULL;
int error;
uint lockflags;
if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
return 0;
lockflags = XFS_ILOCK_EXCL;
xfs_ilock(ip, lockflags);
if ((flags & XFS_QMOPT_INHERIT) && XFS_INHERIT_GID(ip))
gid = ip->i_d.di_gid;
/*
* Attach the dquot(s) to this inode, doing a dquot allocation
* if necessary. The dquot(s) will not be locked.
*/
if (XFS_NOT_DQATTACHED(mp, ip)) {
error = xfs_qm_dqattach_locked(ip, XFS_QMOPT_DQALLOC);
if (error) {
xfs_iunlock(ip, lockflags);
return error;
}
}
if ((flags & XFS_QMOPT_UQUOTA) && XFS_IS_UQUOTA_ON(mp)) {
if (ip->i_d.di_uid != uid) {
/*
* What we need is the dquot that has this uid, and
* if we send the inode to dqget, the uid of the inode
* takes priority over what's sent in the uid argument.
* We must unlock inode here before calling dqget if
* we're not sending the inode, because otherwise
* we'll deadlock by doing trans_reserve while
* holding ilock.
*/
xfs_iunlock(ip, lockflags);
error = xfs_qm_dqget(mp, NULL, uid,
XFS_DQ_USER,
XFS_QMOPT_DQALLOC |
XFS_QMOPT_DOWARN,
&uq);
if (error) {
ASSERT(error != -ENOENT);
return error;
}
/*
* Get the ilock in the right order.
*/
xfs_dqunlock(uq);
lockflags = XFS_ILOCK_SHARED;
xfs_ilock(ip, lockflags);
} else {
/*
* Take an extra reference, because we'll return
* this to caller
*/
ASSERT(ip->i_udquot);
uq = xfs_qm_dqhold(ip->i_udquot);
}
}
if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) {
if (ip->i_d.di_gid != gid) {
xfs_iunlock(ip, lockflags);
error = xfs_qm_dqget(mp, NULL, gid,
XFS_DQ_GROUP,
XFS_QMOPT_DQALLOC |
XFS_QMOPT_DOWARN,
&gq);
if (error) {
ASSERT(error != -ENOENT);
goto error_rele;
}
xfs_dqunlock(gq);
lockflags = XFS_ILOCK_SHARED;
xfs_ilock(ip, lockflags);
} else {
ASSERT(ip->i_gdquot);
gq = xfs_qm_dqhold(ip->i_gdquot);
}
}
if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) {
if (xfs_get_projid(ip) != prid) {
xfs_iunlock(ip, lockflags);
error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)prid,
XFS_DQ_PROJ,
XFS_QMOPT_DQALLOC |
XFS_QMOPT_DOWARN,
&pq);
if (error) {
ASSERT(error != -ENOENT);
goto error_rele;
}
xfs_dqunlock(pq);
lockflags = XFS_ILOCK_SHARED;
xfs_ilock(ip, lockflags);
} else {
ASSERT(ip->i_pdquot);
pq = xfs_qm_dqhold(ip->i_pdquot);
}
}
if (uq)
trace_xfs_dquot_dqalloc(ip);
xfs_iunlock(ip, lockflags);
if (O_udqpp)
*O_udqpp = uq;
else if (uq)
xfs_qm_dqrele(uq);
if (O_gdqpp)
*O_gdqpp = gq;
else if (gq)
xfs_qm_dqrele(gq);
if (O_pdqpp)
*O_pdqpp = pq;
else if (pq)
xfs_qm_dqrele(pq);
return 0;
error_rele:
if (gq)
xfs_qm_dqrele(gq);
if (uq)
xfs_qm_dqrele(uq);
return error;
}
/*
* Actually transfer ownership, and do dquot modifications.
* These were already reserved.
*/
xfs_dquot_t *
xfs_qm_vop_chown(
xfs_trans_t *tp,
xfs_inode_t *ip,
xfs_dquot_t **IO_olddq,
xfs_dquot_t *newdq)
{
xfs_dquot_t *prevdq;
uint bfield = XFS_IS_REALTIME_INODE(ip) ?
XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT;
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount));
/* old dquot */
prevdq = *IO_olddq;
ASSERT(prevdq);
ASSERT(prevdq != newdq);
xfs_trans_mod_dquot(tp, prevdq, bfield, -(ip->i_d.di_nblocks));
xfs_trans_mod_dquot(tp, prevdq, XFS_TRANS_DQ_ICOUNT, -1);
/* the sparkling new dquot */
xfs_trans_mod_dquot(tp, newdq, bfield, ip->i_d.di_nblocks);
xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_ICOUNT, 1);
/*
* Take an extra reference, because the inode is going to keep
* this dquot pointer even after the trans_commit.
*/
*IO_olddq = xfs_qm_dqhold(newdq);
return prevdq;
}
/*
* Quota reservations for setattr(AT_UID|AT_GID|AT_PROJID).
*/
int
xfs_qm_vop_chown_reserve(
struct xfs_trans *tp,
struct xfs_inode *ip,
struct xfs_dquot *udqp,
struct xfs_dquot *gdqp,
struct xfs_dquot *pdqp,
uint flags)
{
struct xfs_mount *mp = ip->i_mount;
uint delblks, blkflags, prjflags = 0;
struct xfs_dquot *udq_unres = NULL;
struct xfs_dquot *gdq_unres = NULL;
struct xfs_dquot *pdq_unres = NULL;
struct xfs_dquot *udq_delblks = NULL;
struct xfs_dquot *gdq_delblks = NULL;
struct xfs_dquot *pdq_delblks = NULL;
int error;
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
delblks = ip->i_delayed_blks;
blkflags = XFS_IS_REALTIME_INODE(ip) ?
XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS;
if (XFS_IS_UQUOTA_ON(mp) && udqp &&
ip->i_d.di_uid != be32_to_cpu(udqp->q_core.d_id)) {
udq_delblks = udqp;
/*
* If there are delayed allocation blocks, then we have to
* unreserve those from the old dquot, and add them to the
* new dquot.
*/
if (delblks) {
ASSERT(ip->i_udquot);
udq_unres = ip->i_udquot;
}
}
if (XFS_IS_GQUOTA_ON(ip->i_mount) && gdqp &&
ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id)) {
gdq_delblks = gdqp;
if (delblks) {
ASSERT(ip->i_gdquot);
gdq_unres = ip->i_gdquot;
}
}
if (XFS_IS_PQUOTA_ON(ip->i_mount) && pdqp &&
xfs_get_projid(ip) != be32_to_cpu(pdqp->q_core.d_id)) {
prjflags = XFS_QMOPT_ENOSPC;
pdq_delblks = pdqp;
if (delblks) {
ASSERT(ip->i_pdquot);
pdq_unres = ip->i_pdquot;
}
}
error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount,
udq_delblks, gdq_delblks, pdq_delblks,
ip->i_d.di_nblocks, 1,
flags | blkflags | prjflags);
if (error)
return error;
/*
* Do the delayed blks reservations/unreservations now. Since, these
* are done without the help of a transaction, if a reservation fails
* its previous reservations won't be automatically undone by trans
* code. So, we have to do it manually here.
*/
if (delblks) {
/*
* Do the reservations first. Unreservation can't fail.
*/
ASSERT(udq_delblks || gdq_delblks || pdq_delblks);
ASSERT(udq_unres || gdq_unres || pdq_unres);
error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount,
udq_delblks, gdq_delblks, pdq_delblks,
(xfs_qcnt_t)delblks, 0,
flags | blkflags | prjflags);
if (error)
return error;
xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount,
udq_unres, gdq_unres, pdq_unres,
-((xfs_qcnt_t)delblks), 0, blkflags);
}
return 0;
}
int
xfs_qm_vop_rename_dqattach(
struct xfs_inode **i_tab)
{
struct xfs_mount *mp = i_tab[0]->i_mount;
int i;
if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
return 0;
for (i = 0; (i < 4 && i_tab[i]); i++) {
struct xfs_inode *ip = i_tab[i];
int error;
/*
* Watch out for duplicate entries in the table.
*/
if (i == 0 || ip != i_tab[i-1]) {
if (XFS_NOT_DQATTACHED(mp, ip)) {
error = xfs_qm_dqattach(ip, 0);
if (error)
return error;
}
}
}
return 0;
}
void
xfs_qm_vop_create_dqattach(
struct xfs_trans *tp,
struct xfs_inode *ip,
struct xfs_dquot *udqp,
struct xfs_dquot *gdqp,
struct xfs_dquot *pdqp)
{
struct xfs_mount *mp = tp->t_mountp;
if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
return;
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
if (udqp && XFS_IS_UQUOTA_ON(mp)) {
ASSERT(ip->i_udquot == NULL);
ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id));
ip->i_udquot = xfs_qm_dqhold(udqp);
xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1);
}
if (gdqp && XFS_IS_GQUOTA_ON(mp)) {
ASSERT(ip->i_gdquot == NULL);
ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id));
ip->i_gdquot = xfs_qm_dqhold(gdqp);
xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);
}
if (pdqp && XFS_IS_PQUOTA_ON(mp)) {
ASSERT(ip->i_pdquot == NULL);
ASSERT(xfs_get_projid(ip) == be32_to_cpu(pdqp->q_core.d_id));
ip->i_pdquot = xfs_qm_dqhold(pdqp);
xfs_trans_mod_dquot(tp, pdqp, XFS_TRANS_DQ_ICOUNT, 1);
}
}
| 24.616004 | 78 | 0.691078 | [
"shape"
] |
b11bab621d39e48f509a66dfab6233e712541f1f | 6,669 | h | C | InitFile/ifAddress.h | opendragon/IF | 11e9132b896a67115b8fc9fc9cddcd592b838bfa | [
"BSD-3-Clause"
] | null | null | null | InitFile/ifAddress.h | opendragon/IF | 11e9132b896a67115b8fc9fc9cddcd592b838bfa | [
"BSD-3-Clause"
] | null | null | null | InitFile/ifAddress.h | opendragon/IF | 11e9132b896a67115b8fc9fc9cddcd592b838bfa | [
"BSD-3-Clause"
] | null | null | null | //--------------------------------------------------------------------------------------------------
//
// File: InitFile/ifAddress.h
//
// Project: IF
//
// Contains: The class declaration for InitFile Address values.
//
// Written by: Norman Jaffe
//
// Copyright: (c) 2020 by OpenDragon.
//
// All rights reserved. Redistribution and use in source and binary forms, with or
// without modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this
// list of conditions and the following disclaimer in the documentation and / or
// other materials provided with the distribution.
// * Neither the name of the copyright holders nor the names of its contributors may
// be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// Created: 2020-09-22
//
//--------------------------------------------------------------------------------------------------
#if (! defined(ifAddress_H_))
# define ifAddress_H_ /* Header guard */
# include <ifBase.h>
# if defined(__APPLE__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
# endif // defined(__APPLE__)
/*! @file
@brief The class declaration for %InitFile Address values. */
# if defined(__APPLE__)
# pragma clang diagnostic pop
# endif // defined(__APPLE__)
namespace InitFile
{
/*! @brief A class to provide the base type for Address values. */
class AddressValue final : public BaseValue
{
public :
// Public type definitions.
protected :
// Protected type definitions.
private :
// Private type definitions.
/*! @brief The class that this class is derived from. */
using inherited = BaseValue;
public :
// Public methods.
/*! @brief The constructor.
@param[in] parent The parent of this value. */
inline AddressValue
(SpBase parent,
const uint32_t value) :
inherited(parent), fValue(value)
{
} /* constructor */
/*! @brief The move constructor.
@param[in] other The object to be moved. */
AddressValue
(AddressValue && other)
noexcept;
/*! @brief The destructor. */
virtual
~AddressValue
(void);
/*! @brief Return @c this if this is an IPv4 address.
@return @c this if this is an IPv4 address. */
virtual AddressValue *
AsAddress
(void)
override;
/*! @brief Return @c this if this is an IPv4 address.
@return @c this if this is an IPv4 address. */
virtual const AddressValue *
AsAddress
(void)
const
override;
/*! @brief Return a copy of this value.
@return A newly allocated copy of this value. */
virtual SpBase
Clone
(void)
const
override;
/*! @brief Return the content of this value.
@return The content of this value. */
inline uint32_t
GetValue
(void)
const
{
return fValue;
} // GetValue
/*! @brief The copy assignment operator.
@param[in] other The object to be copied.
@return The updated object. */
AddressValue &
operator =
(const AddressValue & other) = delete;
/*! @brief The move assignment operator.
@param[in] other The object to be moved.
@return The updated object. */
AddressValue &
operator =
(AddressValue && other)
noexcept;
/*! @brief Return @c true if the two values are equal.
@param[in] other The value to be compared with.
@return @c true if the two values are comparable and equal. */
virtual bool
operator ==
(const BaseValue & other)
const
override;
/*! @brief Write a human-readable representation of the value to a stream.
@param[in,out] output The stream to be written to.
@param[in] indentStep How many characters to insert at each level
@param[in] indentChar The character to be used for indentation
@param[in] indentLevel The amount of indentation to apply
@param[in] squished @c true if the output has no unnecessary characters and @c false if it
is as readable as possible.
@return The stream being written to. */
virtual std::ostream &
Print
(std::ostream & output,
const size_t indentStep = 2,
const char indentChar = ' ',
const size_t indentLevel = 0,
const bool squished = false)
const
override;
protected :
// Protected methods.
private :
// Private methods.
/*! @brief The copy constructor. Used by Clone().
@param[in] other The object to be copied. */
AddressValue
(const AddressValue & other);
public :
// Public fields.
protected :
// Protected fields.
private :
// Private fields.
/*! @brief The content of this value. */
uint32_t fValue;
}; // AddressValue
} // InitFile
#endif /* not ifAddress_H_ */
| 33.681818 | 101 | 0.579397 | [
"object"
] |
b11c3d7c20d703f45cf3cfe383b14f504760bb0c | 817 | h | C | Modules/Osmium/GPU/Shader/ShaderStage.h | Ferrum3D/Ferrum3D | 12ecc54d8b3f2d5f22013d6580c244b935cee54d | [
"Apache-2.0"
] | null | null | null | Modules/Osmium/GPU/Shader/ShaderStage.h | Ferrum3D/Ferrum3D | 12ecc54d8b3f2d5f22013d6580c244b935cee54d | [
"Apache-2.0"
] | null | null | null | Modules/Osmium/GPU/Shader/ShaderStage.h | Ferrum3D/Ferrum3D | 12ecc54d8b3f2d5f22013d6580c244b935cee54d | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <FeCore/Base/Base.h>
namespace FE::GPU
{
enum class ShaderStage : UInt32
{
Vertex,
Pixel,
Hull,
Domain,
Geometry,
Compute
};
enum class ShaderStageFlags : UInt32
{
None = 0,
Vertex = 1 << static_cast<UInt32>(ShaderStage::Vertex),
Pixel = 1 << static_cast<UInt32>(ShaderStage::Pixel),
Hull = 1 << static_cast<UInt32>(ShaderStage::Hull),
Domain = 1 << static_cast<UInt32>(ShaderStage::Domain),
Geometry = 1 << static_cast<UInt32>(ShaderStage::Geometry),
Compute = 1 << static_cast<UInt32>(ShaderStage::Compute),
All = Vertex | Hull | Domain | Pixel | Geometry | Compute
};
FE_ENUM_OPERATORS(ShaderStageFlags);
} // namespace FE::GPU
| 27.233333 | 70 | 0.582619 | [
"geometry"
] |
b11c4d658e4a1a64055dc6b580b9321f31f5d228 | 3,172 | h | C | src/map/linkshell.h | MarkWaldron/topaz | 271665a3cb6c0e0cd9842d32e5b91dd14541c9f3 | [
"FTL"
] | 2 | 2020-09-17T12:21:55.000Z | 2022-02-06T02:59:57.000Z | src/map/linkshell.h | MarkWaldron/topaz | 271665a3cb6c0e0cd9842d32e5b91dd14541c9f3 | [
"FTL"
] | 5 | 2020-04-10T19:33:53.000Z | 2021-06-27T17:50:05.000Z | src/map/linkshell.h | MarkWaldron/topaz | 271665a3cb6c0e0cd9842d32e5b91dd14541c9f3 | [
"FTL"
] | 2 | 2020-04-11T16:56:14.000Z | 2021-06-26T12:21:12.000Z | /*
===========================================================================
Copyright (c) 2010-2015 Darkstar Dev Teams
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
===========================================================================
*/
#ifndef _CLINKSHELL_H
#define _CLINKSHELL_H
#include "../common/cbasetypes.h"
#include "../common/mmo.h"
#include <vector>
/************************************************************************
* *
* *
* *
************************************************************************/
class CBasicPacket;
class CCharEntity;
class CItemLinkshell;
class CLinkshell
{
public:
CLinkshell(uint32 id);
uint32 getID();
uint16 getColor();
uint8 getPostRights();
void setColor(uint16 color);
void setPostRights(uint8 postrights); // Updates lsmes privilege and writes to db
const int8* getName();
void setName(int8* name);
void setMessage(const int8* message, const int8* poster);
void AddMember(CCharEntity* PChar,int8 type, uint8 lsNum);
bool DelMember(CCharEntity* PChar);
void BreakLinkshell(int8* lsname, bool gm);
void RemoveMemberByName(int8* MemberName, uint8 kickerRank);
void ChangeMemberRank(int8* MemberName, uint8 toSack);
void PushPacket(uint32 senderID, CBasicPacket* packet);
void PushLinkshellMessage(CCharEntity* PChar, bool ls1);
std::vector<CCharEntity*> members; // список участников linkshell
uint8 m_postRights;
private:
uint32 m_id;
uint16 m_color;
string_t m_name;
};
/************************************************************************
* *
* namespase для работы с Linkshells *
* *
************************************************************************/
namespace linkshell
{
CLinkshell* LoadLinkshell(uint32 id);
void UnloadLinkshell(uint32 id);
bool AddOnlineMember(CCharEntity* PChar, CItemLinkshell* PItemLinkshell, uint8 lsNum);
bool DelOnlineMember(CCharEntity* PChar, CItemLinkshell* PItemLinkshell);
uint32 RegisterNewLinkshell(const int8* name, uint16 color);
CLinkshell* GetLinkshell(uint32 id);
};
#endif
| 32.701031 | 92 | 0.521122 | [
"vector"
] |
b11cabafbd2807eff9f8709444bc6b09d6757548 | 16,140 | h | C | libredex/DexTypeEnvironment.h | 272152441/redex | e9a320b48fa7dfa306c55ec1c53ff4a869c86155 | [
"MIT"
] | 7 | 2021-12-18T05:49:24.000Z | 2021-12-28T09:52:33.000Z | libredex/DexTypeEnvironment.h | 272152441/redex | e9a320b48fa7dfa306c55ec1c53ff4a869c86155 | [
"MIT"
] | 1 | 2021-04-19T09:55:31.000Z | 2021-04-19T09:55:31.000Z | libredex/DexTypeEnvironment.h | 272152441/redex | e9a320b48fa7dfa306c55ec1c53ff4a869c86155 | [
"MIT"
] | null | null | null | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <ostream>
#include <boost/optional.hpp>
#include "AbstractDomain.h"
#include "DexUtil.h"
#include "FiniteAbstractDomain.h"
#include "NullnessDomain.h"
#include "PatriciaTreeMapAbstractEnvironment.h"
#include "PatriciaTreeSet.h"
#include "ReducedProductAbstractDomain.h"
namespace dtv_impl {
class DexTypeValue final : public sparta::AbstractValue<DexTypeValue> {
public:
~DexTypeValue() override {
static_assert(std::is_default_constructible<DexType*>::value,
"Constant is not default constructible");
static_assert(std::is_copy_constructible<DexType*>::value,
"Constant is not copy constructible");
static_assert(std::is_copy_assignable<DexType*>::value,
"Constant is not copy assignable");
}
DexTypeValue() = default;
explicit DexTypeValue(const DexType* dex_type) : m_dex_type(dex_type) {}
void clear() override { m_dex_type = nullptr; }
sparta::AbstractValueKind kind() const override {
return sparta::AbstractValueKind::Value;
}
/*
* None means there's no type value. It can be used to denote a null in Java
* or the type of an uninitialized Java field. It is conceptually similar to
* Bottom but not an actual Bottom in an AbstractDomain.
*
* The reason we need this special case is because in Sparta, we cannot assign
* a Bottom to an Environment or a ReduceProductAbstractDomain. Doing so will
* mark the entire thing as Bottom. A Bottom environment or domain carries a
* different meaning in the analysis. Therefore, we need something that is not
* a Bottom to denote an empty or uninitialized DexType value.
*
* It is not necessarily the case in a different DexTypeDomain implementation.
* If we as an alternative model the DexTypeDomain as a set of DexTypes, we
* can use an empty set to denote a none.
*/
bool is_none() const { return m_dex_type == nullptr; }
bool leq(const DexTypeValue& other) const override { return equals(other); }
bool equals(const DexTypeValue& other) const override {
return m_dex_type == other.get_dex_type();
}
sparta::AbstractValueKind join_with(const DexTypeValue& other) override;
sparta::AbstractValueKind widen_with(const DexTypeValue& other) override {
return join_with(other);
}
sparta::AbstractValueKind meet_with(const DexTypeValue& other) override {
if (equals(other)) {
return sparta::AbstractValueKind::Value;
}
clear();
return sparta::AbstractValueKind::Bottom;
}
sparta::AbstractValueKind narrow_with(const DexTypeValue& other) override {
return meet_with(other);
}
const DexType* get_dex_type() const { return m_dex_type; }
private:
const DexType* m_dex_type;
};
} // namespace dtv_impl
/*
* DexType domain
*
* Singleton here means that we only track a single DexType value. The join of
* two distinct SingletonDexTypeDomain will produce a single DexType value that
* is guaranteed to be compatible with the two inputs. This is the most simple
* data structure we can use to represent a DexType domain.
*/
class SingletonDexTypeDomain final
: public sparta::AbstractDomainScaffolding<dtv_impl::DexTypeValue,
SingletonDexTypeDomain> {
public:
SingletonDexTypeDomain() { this->set_to_top(); }
explicit SingletonDexTypeDomain(const DexType* cst) {
this->set_to_value(dtv_impl::DexTypeValue(cst));
}
explicit SingletonDexTypeDomain(sparta::AbstractValueKind kind)
: sparta::AbstractDomainScaffolding<dtv_impl::DexTypeValue,
SingletonDexTypeDomain>(kind) {}
boost::optional<const DexType*> get_dex_type() const {
if (this->kind() != sparta::AbstractValueKind::Value || this->is_none()) {
return boost::none;
}
return boost::optional<const DexType*>(this->get_value()->get_dex_type());
}
static SingletonDexTypeDomain bottom() {
return SingletonDexTypeDomain(sparta::AbstractValueKind::Bottom);
}
static SingletonDexTypeDomain top() {
return SingletonDexTypeDomain(sparta::AbstractValueKind::Top);
}
static SingletonDexTypeDomain none() {
return SingletonDexTypeDomain(nullptr);
}
bool is_none() const {
return this->kind() == sparta::AbstractValueKind::Value &&
this->get_value()->is_none();
}
friend std::ostream& operator<<(std::ostream& out,
const SingletonDexTypeDomain& x);
};
std::ostream& operator<<(std::ostream& out, const SingletonDexTypeDomain& x);
std::ostream& operator<<(std::ostream& output, const DexType* dex_type);
/*
*
* Small Set DexTypeDomain
*
*/
constexpr size_t MAX_SET_SIZE = 4;
class SmallSetDexTypeDomain final
: public sparta::AbstractDomain<SmallSetDexTypeDomain> {
public:
SmallSetDexTypeDomain() : m_kind(sparta::AbstractValueKind::Value) {}
explicit SmallSetDexTypeDomain(const DexType* type) {
m_types.insert(type);
m_kind = sparta::AbstractValueKind::Value;
}
bool is_bottom() const override {
return m_kind == sparta::AbstractValueKind::Bottom;
}
bool is_top() const override {
return m_kind == sparta::AbstractValueKind::Top;
}
void set_to_bottom() override {
m_kind = sparta::AbstractValueKind::Bottom;
m_types.clear();
}
void set_to_top() override {
m_kind = sparta::AbstractValueKind::Top;
m_types.clear();
}
sparta::AbstractValueKind kind() const { return m_kind; }
sparta::PatriciaTreeSet<const DexType*> get_types() const {
always_assert(!is_top());
return m_types;
}
bool leq(const SmallSetDexTypeDomain& other) const override;
bool equals(const SmallSetDexTypeDomain& other) const override;
void join_with(const SmallSetDexTypeDomain& other) override;
void widen_with(const SmallSetDexTypeDomain& other) override;
void meet_with(const SmallSetDexTypeDomain& /* other */) override {
throw std::runtime_error("meet_with not implemented!");
}
void narrow_with(const SmallSetDexTypeDomain& /* other */) override {
throw std::runtime_error("narrow_with not implemented!");
}
friend std::ostream& operator<<(std::ostream& out,
const SmallSetDexTypeDomain& x);
private:
sparta::PatriciaTreeSet<const DexType*> m_types;
sparta::AbstractValueKind m_kind;
};
/*
*
* NullnessDomain X SingletonDexTypeDomain
*
*/
class DexTypeDomain
: public sparta::ReducedProductAbstractDomain<DexTypeDomain,
ArrayConstNullnessDomain,
SingletonDexTypeDomain,
SmallSetDexTypeDomain> {
public:
using ReducedProductAbstractDomain::ReducedProductAbstractDomain;
using BaseType =
sparta::ReducedProductAbstractDomain<DexTypeDomain,
ArrayConstNullnessDomain,
SingletonDexTypeDomain,
SmallSetDexTypeDomain>;
// Some older compilers complain that the class is not default
// constructible. We intended to use the default constructors of the base
// class (via the `using` declaration above), but some compilers fail to
// catch this. So we insert a redundant '= default'.
DexTypeDomain() = default;
explicit DexTypeDomain(int64_t v)
: ReducedProductAbstractDomain(
std::make_tuple(ConstNullnessDomain(v),
SingletonDexTypeDomain(),
SmallSetDexTypeDomain::top())) {}
explicit DexTypeDomain(const DexType* array_type, uint32_t array_length)
: ReducedProductAbstractDomain(
std::make_tuple(ArrayNullnessDomain(array_length),
SingletonDexTypeDomain(array_type),
SmallSetDexTypeDomain(array_type))) {}
explicit DexTypeDomain(const DexType* dex_type)
: ReducedProductAbstractDomain(
std::make_tuple(ConstNullnessDomain(NOT_NULL),
SingletonDexTypeDomain(dex_type),
SmallSetDexTypeDomain(dex_type))) {}
explicit DexTypeDomain(const DexType* dex_type, const Nullness nullness)
: ReducedProductAbstractDomain(
std::make_tuple(ConstNullnessDomain(nullness),
SingletonDexTypeDomain(dex_type),
SmallSetDexTypeDomain(dex_type))) {}
static void reduce_product(std::tuple<ArrayConstNullnessDomain,
SingletonDexTypeDomain,
SmallSetDexTypeDomain>& /* product */) {
}
static DexTypeDomain null() { return DexTypeDomain(IS_NULL); }
NullnessDomain get_nullness() const {
auto domain = get<0>();
if (domain.which() == 0) {
return domain.get<ConstNullnessDomain>().get_nullness();
} else {
return domain.get<ArrayNullnessDomain>().get_nullness();
}
}
bool is_null() const { return get_nullness().element() == IS_NULL; }
bool is_not_null() const { return get_nullness().element() == NOT_NULL; }
bool is_nullable() const { return get_nullness().is_top(); }
boost::optional<ConstantDomain::ConstantType> get_constant() const {
if (auto const_nullness = get<0>().maybe_get<ConstNullnessDomain>()) {
return const_nullness->const_domain().get_constant();
}
return boost::none;
}
ArrayNullnessDomain get_array_nullness() const {
if (auto array_nullness = get<0>().maybe_get<ArrayNullnessDomain>()) {
return *array_nullness;
}
return ArrayNullnessDomain::top();
}
NullnessDomain get_array_element_nullness(
boost::optional<int64_t> idx) const {
if (!ArrayNullnessDomain::is_valid_array_idx(idx)) {
return NullnessDomain::top();
}
return get_array_nullness().get_element(*idx);
}
void set_array_element_nullness(boost::optional<int64_t> idx,
const NullnessDomain& nullness) {
if (!ArrayNullnessDomain::is_valid_array_idx(idx)) {
apply<0>([&](ArrayConstNullnessDomain* d) {
d->apply<ArrayNullnessDomain>([&](ArrayNullnessDomain* array_nullness) {
array_nullness->reset_elements();
});
});
return;
}
apply<0>([&](ArrayConstNullnessDomain* d) {
d->apply<ArrayNullnessDomain>([&](ArrayNullnessDomain* array_nullness) {
array_nullness->set_element(*idx, nullness);
});
});
}
SingletonDexTypeDomain get_single_domain() const { return get<1>(); }
boost::optional<const DexType*> get_dex_type() const {
return get<1>().get_dex_type();
}
boost::optional<const DexClass*> get_dex_cls() const {
auto dex_type = get<1>().get_dex_type();
if (!dex_type) {
return boost::none;
}
auto dex_cls = type_class(*dex_type);
return dex_cls ? boost::optional<const DexClass*>(dex_cls) : boost::none;
}
SmallSetDexTypeDomain get_set_domain() { return get<2>(); }
sparta::PatriciaTreeSet<const DexType*> get_type_set() {
return get<2>().get_types();
}
private:
explicit DexTypeDomain(const Nullness nullness)
: ReducedProductAbstractDomain(
std::make_tuple(ConstNullnessDomain(nullness),
SingletonDexTypeDomain::none(),
SmallSetDexTypeDomain())) {}
};
/*
* We model the register to DexTypeDomain mapping using an Environment. A
* write to a register always overwrites the existing mapping.
*/
using RegTypeEnvironment =
sparta::PatriciaTreeMapAbstractEnvironment<reg_t, DexTypeDomain>;
/*
* We model the field to DexTypeDomain mapping using an Environment. But we
* need to handle the initial write to a field correctly. We should overwrite
* the default top value of a field upon the 1st write. The subsequent writes
* to the same field always require a join with the existing type mapping to
* preserve all the type information.
*
* Note that at method level, this field type mapping can still be incomplete.
* We need to join all the mappings from the analysis for all methods globally
* to make sure that we don't lose any type information for a given field.
* However, we can always fall back to the declared type, which is still
* sound.
*/
using FieldTypeEnvironment =
sparta::PatriciaTreeMapAbstractEnvironment<const DexField*, DexTypeDomain>;
/*
* A simple Environment that tracks the registers possibly holding the value of
* `this` pointer.
*
* The purpose of this is to make the FieldTypeEnvironment propagation in
* CtorFieldAnalyzer instance sensitive. We can ignore field operations that do
* not update field types on `this` obj.
*/
using IsDomain = sparta::ConstantAbstractDomain<bool>;
using ThisPointerEnvironment =
sparta::PatriciaTreeMapAbstractEnvironment<reg_t, IsDomain>;
/*
* Combining the register mapping and the field mapping to the DexTypeDomain.
*/
class DexTypeEnvironment final
: public sparta::ReducedProductAbstractDomain<DexTypeEnvironment,
RegTypeEnvironment,
FieldTypeEnvironment,
ThisPointerEnvironment> {
public:
using ReducedProductAbstractDomain::ReducedProductAbstractDomain;
// Some older compilers complain that the class is not default
// constructible. We intended to use the default constructors of the base
// class (via the `using` declaration above), but some compilers fail to
// catch this. So we insert a redundant '= default'.
DexTypeEnvironment() = default;
DexTypeEnvironment(std::initializer_list<std::pair<reg_t, DexTypeDomain>> l)
: ReducedProductAbstractDomain(
std::make_tuple(RegTypeEnvironment(l),
FieldTypeEnvironment(),
ThisPointerEnvironment())) {}
static void reduce_product(std::tuple<RegTypeEnvironment,
FieldTypeEnvironment,
ThisPointerEnvironment>&) {}
/*
* Getters and setters
*/
const RegTypeEnvironment& get_reg_environment() const {
return ReducedProductAbstractDomain::get<0>();
}
const FieldTypeEnvironment& get_field_environment() const {
return ReducedProductAbstractDomain::get<1>();
}
const ThisPointerEnvironment& get_this_ptr_environment() const {
return ReducedProductAbstractDomain::get<2>();
}
DexTypeDomain get(reg_t reg) const { return get_reg_environment().get(reg); }
DexTypeDomain get(DexField* field) const {
return get_field_environment().get(field);
}
DexTypeEnvironment& mutate_reg_environment(
const std::function<void(RegTypeEnvironment*)>& f) {
apply<0>(f);
return *this;
}
DexTypeEnvironment& mutate_field_environment(
const std::function<void(FieldTypeEnvironment*)>& f) {
apply<1>(f);
return *this;
}
DexTypeEnvironment& set(reg_t reg, const DexTypeDomain& type) {
return mutate_reg_environment(
[&](RegTypeEnvironment* env) { env->set(reg, type); });
}
DexTypeEnvironment& set(const DexField* field, const DexTypeDomain& type) {
return mutate_field_environment(
[&](FieldTypeEnvironment* env) { env->set(field, type); });
}
DexTypeEnvironment& clear_field_environment() {
return mutate_field_environment(
[](FieldTypeEnvironment* env) { env->set_to_bottom(); });
}
bool is_this_ptr(reg_t reg) const {
auto is_this = get_this_ptr_environment().get(reg).get_constant();
return is_this && *is_this;
}
IsDomain get_this_ptr(reg_t reg) const {
return get_this_ptr_environment().get(reg);
}
void set_this_ptr(reg_t reg, const IsDomain& is_this) {
apply<2>([&](ThisPointerEnvironment* env) { env->set(reg, is_this); });
}
};
| 33.907563 | 80 | 0.676704 | [
"model"
] |
b11e773c7168ca32beab178336a15146def10d6d | 1,727 | h | C | Code/MainWidgets/sketchViewProvider.h | jiaguobing/FastCAE | 2348ab87e83fe5c704e4c998cf391229c25ac5d5 | [
"BSD-3-Clause"
] | 2 | 2020-02-21T01:04:35.000Z | 2020-02-21T03:35:37.000Z | Code/MainWidgets/sketchViewProvider.h | Sunqia/FastCAE | cbc023fe07b6e306ceefae8b8bd7c12bc1562acb | [
"BSD-3-Clause"
] | 1 | 2020-03-06T04:49:42.000Z | 2020-03-06T04:49:42.000Z | Code/MainWidgets/sketchViewProvider.h | Sunqia/FastCAE | cbc023fe07b6e306ceefae8b8bd7c12bc1562acb | [
"BSD-3-Clause"
] | 1 | 2021-11-21T13:03:26.000Z | 2021-11-21T13:03:26.000Z | #ifndef SKETCHVIEWPROVIDER_H_
#define SKETCHVIEWPROVIDER_H_
#include <QObject>
#include "moduleBase/ModuleType.h"
#include <QHash>
class vtkActor;
class TopoDS_Shape;
class gp_Pnt;
class QDialog;
namespace Geometry
{
class GeometryData;
}
namespace GUI
{
class MainWindow;
}
namespace ModuleBase
{
class PropPickerInteractionStyle;
}
namespace Command
{
class SketchCreater;
}
namespace GeometryWidget
{
class SketchPointWidget;
}
namespace MainWidget
{
class PreWindow;
class SketchViewProvider : public QObject
{
Q_OBJECT
public:
SketchViewProvider(GUI::MainWindow* mainwindow, PreWindow* preWin);
~SketchViewProvider();
void setSketchType( ModuleBase::SketchType t );
void showSketchPlane(bool show);
signals:
void showSketch(TopoDS_Shape*);
void hideSketch(TopoDS_Shape*);
void showMessage(QString);
void showDialog(QDialog*);
private slots:
void onMouseRelease(double* pt);
void onMouseMove(double* pt);
void onRightMoustRelease();
void onMiddleMouseUp();
void showSketchSlot(TopoDS_Shape* shape);
void removeSketchSlot(TopoDS_Shape* shape);
void removeSketchActors();
void pointTo2D(gp_Pnt* p);
private:
GUI::MainWindow* _mainWindow{};
PreWindow* _preWindow{};
Geometry::GeometryData* _geoData{};
GeometryWidget::SketchPointWidget* _pointWidget{};
ModuleBase::SketchType _sketchType{ ModuleBase::SketchNone };
ModuleBase::PropPickerInteractionStyle* _interactionStyle{};
Command::SketchCreater* _creater{};
vtkActor* _axisXActor{};
vtkActor* _axisYActor{};
vtkActor* _tempActor{};
QHash<TopoDS_Shape*, vtkActor*> _sketchActorHash{};
};
}
#endif | 19.404494 | 70 | 0.722061 | [
"geometry",
"shape"
] |
b11eabad575bb5003bc35ca6dce0af40d64a6fe7 | 36,722 | c | C | drivers/net/can/usb/peak_usb/pcan_usb_fd.c | Server2356/Sun-Kernel | 63cc54a6948ba572388f829c1fd641ffde0803d8 | [
"MIT"
] | 3 | 2022-03-11T06:46:44.000Z | 2022-03-14T18:04:48.000Z | kernel/drivers/net/can/usb/peak_usb/pcan_usb_fd.c | SFIP/SFIP | e428a425d2d0e287f23d49f3dd583617ebd2e4a3 | [
"Zlib"
] | null | null | null | kernel/drivers/net/can/usb/peak_usb/pcan_usb_fd.c | SFIP/SFIP | e428a425d2d0e287f23d49f3dd583617ebd2e4a3 | [
"Zlib"
] | null | null | null | // SPDX-License-Identifier: GPL-2.0-only
/*
* CAN driver for PEAK System PCAN-USB FD / PCAN-USB Pro FD adapter
*
* Copyright (C) 2013-2014 Stephane Grosjean <s.grosjean@peak-system.com>
*/
#include <linux/netdevice.h>
#include <linux/usb.h>
#include <linux/module.h>
#include <linux/ethtool.h>
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
#include <linux/can/dev/peak_canfd.h>
#include "pcan_usb_core.h"
#include "pcan_usb_pro.h"
#define PCAN_USBPROFD_CHANNEL_COUNT 2
#define PCAN_USBFD_CHANNEL_COUNT 1
/* PCAN-USB Pro FD adapter internal clock (Hz) */
#define PCAN_UFD_CRYSTAL_HZ 80000000
#define PCAN_UFD_CMD_BUFFER_SIZE 512
#define PCAN_UFD_LOSPD_PKT_SIZE 64
/* PCAN-USB Pro FD command timeout (ms.) */
#define PCAN_UFD_CMD_TIMEOUT_MS 1000
/* PCAN-USB Pro FD rx/tx buffers size */
#define PCAN_UFD_RX_BUFFER_SIZE 2048
#define PCAN_UFD_TX_BUFFER_SIZE 512
/* read some versions info from the hw device */
struct __packed pcan_ufd_fw_info {
__le16 size_of; /* sizeof this */
__le16 type; /* type of this structure */
u8 hw_type; /* Type of hardware (HW_TYPE_xxx) */
u8 bl_version[3]; /* Bootloader version */
u8 hw_version; /* Hardware version (PCB) */
u8 fw_version[3]; /* Firmware version */
__le32 dev_id[2]; /* "device id" per CAN */
__le32 ser_no; /* S/N */
__le32 flags; /* special functions */
};
/* handle device specific info used by the netdevices */
struct pcan_usb_fd_if {
struct peak_usb_device *dev[PCAN_USB_MAX_CHANNEL];
struct pcan_ufd_fw_info fw_info;
struct peak_time_ref time_ref;
int cm_ignore_count;
int dev_opened_count;
};
/* device information */
struct pcan_usb_fd_device {
struct peak_usb_device dev;
struct can_berr_counter bec;
struct pcan_usb_fd_if *usb_if;
u8 *cmd_buffer_addr;
};
/* Extended USB commands (non uCAN commands) */
/* Clock Modes command */
#define PCAN_UFD_CMD_CLK_SET 0x80
#define PCAN_UFD_CLK_80MHZ 0x0
#define PCAN_UFD_CLK_60MHZ 0x1
#define PCAN_UFD_CLK_40MHZ 0x2
#define PCAN_UFD_CLK_30MHZ 0x3
#define PCAN_UFD_CLK_24MHZ 0x4
#define PCAN_UFD_CLK_20MHZ 0x5
#define PCAN_UFD_CLK_DEF PCAN_UFD_CLK_80MHZ
struct __packed pcan_ufd_clock {
__le16 opcode_channel;
u8 mode;
u8 unused[5];
};
/* LED control command */
#define PCAN_UFD_CMD_LED_SET 0x86
#define PCAN_UFD_LED_DEV 0x00
#define PCAN_UFD_LED_FAST 0x01
#define PCAN_UFD_LED_SLOW 0x02
#define PCAN_UFD_LED_ON 0x03
#define PCAN_UFD_LED_OFF 0x04
#define PCAN_UFD_LED_DEF PCAN_UFD_LED_DEV
struct __packed pcan_ufd_led {
__le16 opcode_channel;
u8 mode;
u8 unused[5];
};
/* Extended usage of uCAN commands CMD_xxx_xx_OPTION for PCAN-USB Pro FD */
#define PCAN_UFD_FLTEXT_CALIBRATION 0x8000
struct __packed pcan_ufd_options {
__le16 opcode_channel;
__le16 ucan_mask;
u16 unused;
__le16 usb_mask;
};
/* Extended usage of uCAN messages for PCAN-USB Pro FD */
#define PCAN_UFD_MSG_CALIBRATION 0x100
struct __packed pcan_ufd_ts_msg {
__le16 size;
__le16 type;
__le32 ts_low;
__le32 ts_high;
__le16 usb_frame_index;
u16 unused;
};
#define PCAN_UFD_MSG_OVERRUN 0x101
#define PCAN_UFD_OVMSG_CHANNEL(o) ((o)->channel & 0xf)
struct __packed pcan_ufd_ovr_msg {
__le16 size;
__le16 type;
__le32 ts_low;
__le32 ts_high;
u8 channel;
u8 unused[3];
};
static inline int pufd_omsg_get_channel(struct pcan_ufd_ovr_msg *om)
{
return om->channel & 0xf;
}
/* Clock mode frequency values */
static const u32 pcan_usb_fd_clk_freq[6] = {
[PCAN_UFD_CLK_80MHZ] = 80000000,
[PCAN_UFD_CLK_60MHZ] = 60000000,
[PCAN_UFD_CLK_40MHZ] = 40000000,
[PCAN_UFD_CLK_30MHZ] = 30000000,
[PCAN_UFD_CLK_24MHZ] = 24000000,
[PCAN_UFD_CLK_20MHZ] = 20000000
};
/* return a device USB interface */
static inline
struct pcan_usb_fd_if *pcan_usb_fd_dev_if(struct peak_usb_device *dev)
{
struct pcan_usb_fd_device *pdev =
container_of(dev, struct pcan_usb_fd_device, dev);
return pdev->usb_if;
}
/* return a device USB commands buffer */
static inline void *pcan_usb_fd_cmd_buffer(struct peak_usb_device *dev)
{
struct pcan_usb_fd_device *pdev =
container_of(dev, struct pcan_usb_fd_device, dev);
return pdev->cmd_buffer_addr;
}
/* send PCAN-USB Pro FD commands synchronously */
static int pcan_usb_fd_send_cmd(struct peak_usb_device *dev, void *cmd_tail)
{
void *cmd_head = pcan_usb_fd_cmd_buffer(dev);
int err = 0;
u8 *packet_ptr;
int packet_len;
ptrdiff_t cmd_len;
/* usb device unregistered? */
if (!(dev->state & PCAN_USB_STATE_CONNECTED))
return 0;
/* if a packet is not filled completely by commands, the command list
* is terminated with an "end of collection" record.
*/
cmd_len = cmd_tail - cmd_head;
if (cmd_len <= (PCAN_UFD_CMD_BUFFER_SIZE - sizeof(u64))) {
memset(cmd_tail, 0xff, sizeof(u64));
cmd_len += sizeof(u64);
}
packet_ptr = cmd_head;
packet_len = cmd_len;
/* firmware is not able to re-assemble 512 bytes buffer in full-speed */
if (unlikely(dev->udev->speed != USB_SPEED_HIGH))
packet_len = min(packet_len, PCAN_UFD_LOSPD_PKT_SIZE);
do {
err = usb_bulk_msg(dev->udev,
usb_sndbulkpipe(dev->udev,
PCAN_USBPRO_EP_CMDOUT),
packet_ptr, packet_len,
NULL, PCAN_UFD_CMD_TIMEOUT_MS);
if (err) {
netdev_err(dev->netdev,
"sending command failure: %d\n", err);
break;
}
packet_ptr += packet_len;
cmd_len -= packet_len;
if (cmd_len < PCAN_UFD_LOSPD_PKT_SIZE)
packet_len = cmd_len;
} while (packet_len > 0);
return err;
}
/* build the commands list in the given buffer, to enter operational mode */
static int pcan_usb_fd_build_restart_cmd(struct peak_usb_device *dev, u8 *buf)
{
struct pucan_wr_err_cnt *prc;
struct pucan_command *cmd;
u8 *pc = buf;
/* 1st, reset error counters: */
prc = (struct pucan_wr_err_cnt *)pc;
prc->opcode_channel = pucan_cmd_opcode_channel(dev->ctrl_idx,
PUCAN_CMD_WR_ERR_CNT);
/* select both counters */
prc->sel_mask = cpu_to_le16(PUCAN_WRERRCNT_TE|PUCAN_WRERRCNT_RE);
/* and reset their values */
prc->tx_counter = 0;
prc->rx_counter = 0;
/* moves the pointer forward */
pc += sizeof(struct pucan_wr_err_cnt);
/* add command to switch from ISO to non-ISO mode, if fw allows it */
if (dev->can.ctrlmode_supported & CAN_CTRLMODE_FD_NON_ISO) {
struct pucan_options *puo = (struct pucan_options *)pc;
puo->opcode_channel =
(dev->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO) ?
pucan_cmd_opcode_channel(dev->ctrl_idx,
PUCAN_CMD_CLR_DIS_OPTION) :
pucan_cmd_opcode_channel(dev->ctrl_idx,
PUCAN_CMD_SET_EN_OPTION);
puo->options = cpu_to_le16(PUCAN_OPTION_CANDFDISO);
/* to be sure that no other extended bits will be taken into
* account
*/
puo->unused = 0;
/* moves the pointer forward */
pc += sizeof(struct pucan_options);
}
/* next, go back to operational mode */
cmd = (struct pucan_command *)pc;
cmd->opcode_channel = pucan_cmd_opcode_channel(dev->ctrl_idx,
(dev->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) ?
PUCAN_CMD_LISTEN_ONLY_MODE :
PUCAN_CMD_NORMAL_MODE);
pc += sizeof(struct pucan_command);
return pc - buf;
}
/* set CAN bus on/off */
static int pcan_usb_fd_set_bus(struct peak_usb_device *dev, u8 onoff)
{
u8 *pc = pcan_usb_fd_cmd_buffer(dev);
int l;
if (onoff) {
/* build the cmds list to enter operational mode */
l = pcan_usb_fd_build_restart_cmd(dev, pc);
} else {
struct pucan_command *cmd = (struct pucan_command *)pc;
/* build cmd to go back to reset mode */
cmd->opcode_channel = pucan_cmd_opcode_channel(dev->ctrl_idx,
PUCAN_CMD_RESET_MODE);
l = sizeof(struct pucan_command);
}
/* send the command */
return pcan_usb_fd_send_cmd(dev, pc + l);
}
/* set filtering masks:
*
* idx in range [0..63] selects a row #idx, all rows otherwise
* mask in range [0..0xffffffff] defines up to 32 CANIDs in the row(s)
*
* Each bit of this 64 x 32 bits array defines a CANID value:
*
* bit[i,j] = 1 implies that CANID=(i x 32)+j will be received, while
* bit[i,j] = 0 implies that CANID=(i x 32)+j will be discarded.
*/
static int pcan_usb_fd_set_filter_std(struct peak_usb_device *dev, int idx,
u32 mask)
{
struct pucan_filter_std *cmd = pcan_usb_fd_cmd_buffer(dev);
int i, n;
/* select all rows when idx is out of range [0..63] */
if ((idx < 0) || (idx >= (1 << PUCAN_FLTSTD_ROW_IDX_BITS))) {
n = 1 << PUCAN_FLTSTD_ROW_IDX_BITS;
idx = 0;
/* select the row (and only the row) otherwise */
} else {
n = idx + 1;
}
for (i = idx; i < n; i++, cmd++) {
cmd->opcode_channel = pucan_cmd_opcode_channel(dev->ctrl_idx,
PUCAN_CMD_FILTER_STD);
cmd->idx = cpu_to_le16(i);
cmd->mask = cpu_to_le32(mask);
}
/* send the command */
return pcan_usb_fd_send_cmd(dev, cmd);
}
/* set/unset options
*
* onoff set(1)/unset(0) options
* mask each bit defines a kind of options to set/unset
*/
static int pcan_usb_fd_set_options(struct peak_usb_device *dev,
bool onoff, u16 ucan_mask, u16 usb_mask)
{
struct pcan_ufd_options *cmd = pcan_usb_fd_cmd_buffer(dev);
cmd->opcode_channel = pucan_cmd_opcode_channel(dev->ctrl_idx,
(onoff) ? PUCAN_CMD_SET_EN_OPTION :
PUCAN_CMD_CLR_DIS_OPTION);
cmd->ucan_mask = cpu_to_le16(ucan_mask);
cmd->usb_mask = cpu_to_le16(usb_mask);
/* send the command */
return pcan_usb_fd_send_cmd(dev, ++cmd);
}
/* setup LED control */
static int pcan_usb_fd_set_can_led(struct peak_usb_device *dev, u8 led_mode)
{
struct pcan_ufd_led *cmd = pcan_usb_fd_cmd_buffer(dev);
cmd->opcode_channel = pucan_cmd_opcode_channel(dev->ctrl_idx,
PCAN_UFD_CMD_LED_SET);
cmd->mode = led_mode;
/* send the command */
return pcan_usb_fd_send_cmd(dev, ++cmd);
}
/* set CAN clock domain */
static int pcan_usb_fd_set_clock_domain(struct peak_usb_device *dev,
u8 clk_mode)
{
struct pcan_ufd_clock *cmd = pcan_usb_fd_cmd_buffer(dev);
cmd->opcode_channel = pucan_cmd_opcode_channel(dev->ctrl_idx,
PCAN_UFD_CMD_CLK_SET);
cmd->mode = clk_mode;
/* send the command */
return pcan_usb_fd_send_cmd(dev, ++cmd);
}
/* set bittiming for CAN and CAN-FD header */
static int pcan_usb_fd_set_bittiming_slow(struct peak_usb_device *dev,
struct can_bittiming *bt)
{
struct pucan_timing_slow *cmd = pcan_usb_fd_cmd_buffer(dev);
cmd->opcode_channel = pucan_cmd_opcode_channel(dev->ctrl_idx,
PUCAN_CMD_TIMING_SLOW);
cmd->sjw_t = PUCAN_TSLOW_SJW_T(bt->sjw - 1,
dev->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES);
cmd->tseg2 = PUCAN_TSLOW_TSEG2(bt->phase_seg2 - 1);
cmd->tseg1 = PUCAN_TSLOW_TSEG1(bt->prop_seg + bt->phase_seg1 - 1);
cmd->brp = cpu_to_le16(PUCAN_TSLOW_BRP(bt->brp - 1));
cmd->ewl = 96; /* default */
/* send the command */
return pcan_usb_fd_send_cmd(dev, ++cmd);
}
/* set CAN-FD bittiming for data */
static int pcan_usb_fd_set_bittiming_fast(struct peak_usb_device *dev,
struct can_bittiming *bt)
{
struct pucan_timing_fast *cmd = pcan_usb_fd_cmd_buffer(dev);
cmd->opcode_channel = pucan_cmd_opcode_channel(dev->ctrl_idx,
PUCAN_CMD_TIMING_FAST);
cmd->sjw = PUCAN_TFAST_SJW(bt->sjw - 1);
cmd->tseg2 = PUCAN_TFAST_TSEG2(bt->phase_seg2 - 1);
cmd->tseg1 = PUCAN_TFAST_TSEG1(bt->prop_seg + bt->phase_seg1 - 1);
cmd->brp = cpu_to_le16(PUCAN_TFAST_BRP(bt->brp - 1));
/* send the command */
return pcan_usb_fd_send_cmd(dev, ++cmd);
}
/* handle restart but in asynchronously way
* (uses PCAN-USB Pro code to complete asynchronous request)
*/
static int pcan_usb_fd_restart_async(struct peak_usb_device *dev,
struct urb *urb, u8 *buf)
{
u8 *pc = buf;
/* build the entire cmds list in the provided buffer, to go back into
* operational mode.
*/
pc += pcan_usb_fd_build_restart_cmd(dev, pc);
/* add EOC */
memset(pc, 0xff, sizeof(struct pucan_command));
pc += sizeof(struct pucan_command);
/* complete the URB */
usb_fill_bulk_urb(urb, dev->udev,
usb_sndbulkpipe(dev->udev, PCAN_USBPRO_EP_CMDOUT),
buf, pc - buf,
pcan_usb_pro_restart_complete, dev);
/* and submit it. */
return usb_submit_urb(urb, GFP_ATOMIC);
}
static int pcan_usb_fd_drv_loaded(struct peak_usb_device *dev, bool loaded)
{
struct pcan_usb_fd_device *pdev =
container_of(dev, struct pcan_usb_fd_device, dev);
pdev->cmd_buffer_addr[0] = 0;
pdev->cmd_buffer_addr[1] = !!loaded;
return pcan_usb_pro_send_req(dev,
PCAN_USBPRO_REQ_FCT,
PCAN_USBPRO_FCT_DRVLD,
pdev->cmd_buffer_addr,
PCAN_USBPRO_FCT_DRVLD_REQ_LEN);
}
static int pcan_usb_fd_decode_canmsg(struct pcan_usb_fd_if *usb_if,
struct pucan_msg *rx_msg)
{
struct pucan_rx_msg *rm = (struct pucan_rx_msg *)rx_msg;
struct peak_usb_device *dev;
struct net_device *netdev;
struct canfd_frame *cfd;
struct sk_buff *skb;
const u16 rx_msg_flags = le16_to_cpu(rm->flags);
if (pucan_msg_get_channel(rm) >= ARRAY_SIZE(usb_if->dev))
return -ENOMEM;
dev = usb_if->dev[pucan_msg_get_channel(rm)];
netdev = dev->netdev;
if (rx_msg_flags & PUCAN_MSG_EXT_DATA_LEN) {
/* CANFD frame case */
skb = alloc_canfd_skb(netdev, &cfd);
if (!skb)
return -ENOMEM;
if (rx_msg_flags & PUCAN_MSG_BITRATE_SWITCH)
cfd->flags |= CANFD_BRS;
if (rx_msg_flags & PUCAN_MSG_ERROR_STATE_IND)
cfd->flags |= CANFD_ESI;
cfd->len = can_fd_dlc2len(pucan_msg_get_dlc(rm));
} else {
/* CAN 2.0 frame case */
skb = alloc_can_skb(netdev, (struct can_frame **)&cfd);
if (!skb)
return -ENOMEM;
can_frame_set_cc_len((struct can_frame *)cfd,
pucan_msg_get_dlc(rm),
dev->can.ctrlmode);
}
cfd->can_id = le32_to_cpu(rm->can_id);
if (rx_msg_flags & PUCAN_MSG_EXT_ID)
cfd->can_id |= CAN_EFF_FLAG;
if (rx_msg_flags & PUCAN_MSG_RTR)
cfd->can_id |= CAN_RTR_FLAG;
else
memcpy(cfd->data, rm->d, cfd->len);
netdev->stats.rx_packets++;
netdev->stats.rx_bytes += cfd->len;
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));
return 0;
}
/* handle uCAN status message */
static int pcan_usb_fd_decode_status(struct pcan_usb_fd_if *usb_if,
struct pucan_msg *rx_msg)
{
struct pucan_status_msg *sm = (struct pucan_status_msg *)rx_msg;
struct pcan_usb_fd_device *pdev;
enum can_state new_state = CAN_STATE_ERROR_ACTIVE;
enum can_state rx_state, tx_state;
struct peak_usb_device *dev;
struct net_device *netdev;
struct can_frame *cf;
struct sk_buff *skb;
if (pucan_stmsg_get_channel(sm) >= ARRAY_SIZE(usb_if->dev))
return -ENOMEM;
dev = usb_if->dev[pucan_stmsg_get_channel(sm)];
pdev = container_of(dev, struct pcan_usb_fd_device, dev);
netdev = dev->netdev;
/* nothing should be sent while in BUS_OFF state */
if (dev->can.state == CAN_STATE_BUS_OFF)
return 0;
if (sm->channel_p_w_b & PUCAN_BUS_BUSOFF) {
new_state = CAN_STATE_BUS_OFF;
} else if (sm->channel_p_w_b & PUCAN_BUS_PASSIVE) {
new_state = CAN_STATE_ERROR_PASSIVE;
} else if (sm->channel_p_w_b & PUCAN_BUS_WARNING) {
new_state = CAN_STATE_ERROR_WARNING;
} else {
/* no error bit (so, no error skb, back to active state) */
dev->can.state = CAN_STATE_ERROR_ACTIVE;
pdev->bec.txerr = 0;
pdev->bec.rxerr = 0;
return 0;
}
/* state hasn't changed */
if (new_state == dev->can.state)
return 0;
/* handle bus state change */
tx_state = (pdev->bec.txerr >= pdev->bec.rxerr) ? new_state : 0;
rx_state = (pdev->bec.txerr <= pdev->bec.rxerr) ? new_state : 0;
/* allocate an skb to store the error frame */
skb = alloc_can_err_skb(netdev, &cf);
if (skb)
can_change_state(netdev, cf, tx_state, rx_state);
/* things must be done even in case of OOM */
if (new_state == CAN_STATE_BUS_OFF)
can_bus_off(netdev);
if (!skb)
return -ENOMEM;
netdev->stats.rx_packets++;
netdev->stats.rx_bytes += cf->len;
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));
return 0;
}
/* handle uCAN error message */
static int pcan_usb_fd_decode_error(struct pcan_usb_fd_if *usb_if,
struct pucan_msg *rx_msg)
{
struct pucan_error_msg *er = (struct pucan_error_msg *)rx_msg;
struct pcan_usb_fd_device *pdev;
struct peak_usb_device *dev;
if (pucan_ermsg_get_channel(er) >= ARRAY_SIZE(usb_if->dev))
return -EINVAL;
dev = usb_if->dev[pucan_ermsg_get_channel(er)];
pdev = container_of(dev, struct pcan_usb_fd_device, dev);
/* keep a trace of tx and rx error counters for later use */
pdev->bec.txerr = er->tx_err_cnt;
pdev->bec.rxerr = er->rx_err_cnt;
return 0;
}
/* handle uCAN overrun message */
static int pcan_usb_fd_decode_overrun(struct pcan_usb_fd_if *usb_if,
struct pucan_msg *rx_msg)
{
struct pcan_ufd_ovr_msg *ov = (struct pcan_ufd_ovr_msg *)rx_msg;
struct peak_usb_device *dev;
struct net_device *netdev;
struct can_frame *cf;
struct sk_buff *skb;
if (pufd_omsg_get_channel(ov) >= ARRAY_SIZE(usb_if->dev))
return -EINVAL;
dev = usb_if->dev[pufd_omsg_get_channel(ov)];
netdev = dev->netdev;
/* allocate an skb to store the error frame */
skb = alloc_can_err_skb(netdev, &cf);
if (!skb)
return -ENOMEM;
cf->can_id |= CAN_ERR_CRTL;
cf->data[1] |= CAN_ERR_CRTL_RX_OVERFLOW;
peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(ov->ts_low));
netdev->stats.rx_over_errors++;
netdev->stats.rx_errors++;
return 0;
}
/* handle USB calibration message */
static void pcan_usb_fd_decode_ts(struct pcan_usb_fd_if *usb_if,
struct pucan_msg *rx_msg)
{
struct pcan_ufd_ts_msg *ts = (struct pcan_ufd_ts_msg *)rx_msg;
/* should wait until clock is stabilized */
if (usb_if->cm_ignore_count > 0)
usb_if->cm_ignore_count--;
else
peak_usb_set_ts_now(&usb_if->time_ref, le32_to_cpu(ts->ts_low));
}
/* callback for bulk IN urb */
static int pcan_usb_fd_decode_buf(struct peak_usb_device *dev, struct urb *urb)
{
struct pcan_usb_fd_if *usb_if = pcan_usb_fd_dev_if(dev);
struct net_device *netdev = dev->netdev;
struct pucan_msg *rx_msg;
u8 *msg_ptr, *msg_end;
int err = 0;
/* loop reading all the records from the incoming message */
msg_ptr = urb->transfer_buffer;
msg_end = urb->transfer_buffer + urb->actual_length;
for (; msg_ptr < msg_end;) {
u16 rx_msg_type, rx_msg_size;
rx_msg = (struct pucan_msg *)msg_ptr;
if (!rx_msg->size) {
/* null packet found: end of list */
break;
}
rx_msg_size = le16_to_cpu(rx_msg->size);
rx_msg_type = le16_to_cpu(rx_msg->type);
/* check if the record goes out of current packet */
if (msg_ptr + rx_msg_size > msg_end) {
netdev_err(netdev,
"got frag rec: should inc usb rx buf sze\n");
err = -EBADMSG;
break;
}
switch (rx_msg_type) {
case PUCAN_MSG_CAN_RX:
err = pcan_usb_fd_decode_canmsg(usb_if, rx_msg);
if (err < 0)
goto fail;
break;
case PCAN_UFD_MSG_CALIBRATION:
pcan_usb_fd_decode_ts(usb_if, rx_msg);
break;
case PUCAN_MSG_ERROR:
err = pcan_usb_fd_decode_error(usb_if, rx_msg);
if (err < 0)
goto fail;
break;
case PUCAN_MSG_STATUS:
err = pcan_usb_fd_decode_status(usb_if, rx_msg);
if (err < 0)
goto fail;
break;
case PCAN_UFD_MSG_OVERRUN:
err = pcan_usb_fd_decode_overrun(usb_if, rx_msg);
if (err < 0)
goto fail;
break;
default:
netdev_err(netdev,
"unhandled msg type 0x%02x (%d): ignored\n",
rx_msg_type, rx_msg_type);
break;
}
msg_ptr += rx_msg_size;
}
fail:
if (err)
pcan_dump_mem("received msg",
urb->transfer_buffer, urb->actual_length);
return err;
}
/* CAN/CANFD frames encoding callback */
static int pcan_usb_fd_encode_msg(struct peak_usb_device *dev,
struct sk_buff *skb, u8 *obuf, size_t *size)
{
struct pucan_tx_msg *tx_msg = (struct pucan_tx_msg *)obuf;
struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
u16 tx_msg_size, tx_msg_flags;
u8 dlc;
if (cfd->len > CANFD_MAX_DLEN)
return -EINVAL;
tx_msg_size = ALIGN(sizeof(struct pucan_tx_msg) + cfd->len, 4);
tx_msg->size = cpu_to_le16(tx_msg_size);
tx_msg->type = cpu_to_le16(PUCAN_MSG_CAN_TX);
tx_msg_flags = 0;
if (cfd->can_id & CAN_EFF_FLAG) {
tx_msg_flags |= PUCAN_MSG_EXT_ID;
tx_msg->can_id = cpu_to_le32(cfd->can_id & CAN_EFF_MASK);
} else {
tx_msg->can_id = cpu_to_le32(cfd->can_id & CAN_SFF_MASK);
}
if (can_is_canfd_skb(skb)) {
/* considering a CANFD frame */
dlc = can_fd_len2dlc(cfd->len);
tx_msg_flags |= PUCAN_MSG_EXT_DATA_LEN;
if (cfd->flags & CANFD_BRS)
tx_msg_flags |= PUCAN_MSG_BITRATE_SWITCH;
if (cfd->flags & CANFD_ESI)
tx_msg_flags |= PUCAN_MSG_ERROR_STATE_IND;
} else {
/* CAND 2.0 frames */
dlc = can_get_cc_dlc((struct can_frame *)cfd,
dev->can.ctrlmode);
if (cfd->can_id & CAN_RTR_FLAG)
tx_msg_flags |= PUCAN_MSG_RTR;
}
/* Single-Shot frame */
if (dev->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
tx_msg_flags |= PUCAN_MSG_SINGLE_SHOT;
tx_msg->flags = cpu_to_le16(tx_msg_flags);
tx_msg->channel_dlc = PUCAN_MSG_CHANNEL_DLC(dev->ctrl_idx, dlc);
memcpy(tx_msg->d, cfd->data, cfd->len);
/* add null size message to tag the end (messages are 32-bits aligned)
*/
tx_msg = (struct pucan_tx_msg *)(obuf + tx_msg_size);
tx_msg->size = 0;
/* set the whole size of the USB packet to send */
*size = tx_msg_size + sizeof(u32);
return 0;
}
/* start the interface (last chance before set bus on) */
static int pcan_usb_fd_start(struct peak_usb_device *dev)
{
struct pcan_usb_fd_device *pdev =
container_of(dev, struct pcan_usb_fd_device, dev);
int err;
/* set filter mode: all acceptance */
err = pcan_usb_fd_set_filter_std(dev, -1, 0xffffffff);
if (err)
return err;
/* opening first device: */
if (pdev->usb_if->dev_opened_count == 0) {
/* reset time_ref */
peak_usb_init_time_ref(&pdev->usb_if->time_ref,
&pcan_usb_pro_fd);
/* enable USB calibration messages */
err = pcan_usb_fd_set_options(dev, 1,
PUCAN_OPTION_ERROR,
PCAN_UFD_FLTEXT_CALIBRATION);
}
pdev->usb_if->dev_opened_count++;
/* reset cached error counters */
pdev->bec.txerr = 0;
pdev->bec.rxerr = 0;
return err;
}
/* socket callback used to copy berr counters values received through USB */
static int pcan_usb_fd_get_berr_counter(const struct net_device *netdev,
struct can_berr_counter *bec)
{
struct peak_usb_device *dev = netdev_priv(netdev);
struct pcan_usb_fd_device *pdev =
container_of(dev, struct pcan_usb_fd_device, dev);
*bec = pdev->bec;
/* must return 0 */
return 0;
}
/* stop interface (last chance before set bus off) */
static int pcan_usb_fd_stop(struct peak_usb_device *dev)
{
struct pcan_usb_fd_device *pdev =
container_of(dev, struct pcan_usb_fd_device, dev);
/* turn off special msgs for that interface if no other dev opened */
if (pdev->usb_if->dev_opened_count == 1)
pcan_usb_fd_set_options(dev, 0,
PUCAN_OPTION_ERROR,
PCAN_UFD_FLTEXT_CALIBRATION);
pdev->usb_if->dev_opened_count--;
return 0;
}
/* called when probing, to initialize a device object */
static int pcan_usb_fd_init(struct peak_usb_device *dev)
{
struct pcan_usb_fd_device *pdev =
container_of(dev, struct pcan_usb_fd_device, dev);
int i, err = -ENOMEM;
/* do this for 1st channel only */
if (!dev->prev_siblings) {
/* allocate netdevices common structure attached to first one */
pdev->usb_if = kzalloc(sizeof(*pdev->usb_if), GFP_KERNEL);
if (!pdev->usb_if)
goto err_out;
/* allocate command buffer once for all for the interface */
pdev->cmd_buffer_addr = kzalloc(PCAN_UFD_CMD_BUFFER_SIZE,
GFP_KERNEL);
if (!pdev->cmd_buffer_addr)
goto err_out_1;
/* number of ts msgs to ignore before taking one into account */
pdev->usb_if->cm_ignore_count = 5;
err = pcan_usb_pro_send_req(dev, PCAN_USBPRO_REQ_INFO,
PCAN_USBPRO_INFO_FW,
&pdev->usb_if->fw_info,
sizeof(pdev->usb_if->fw_info));
if (err) {
dev_err(dev->netdev->dev.parent,
"unable to read %s firmware info (err %d)\n",
dev->adapter->name, err);
goto err_out_2;
}
/* explicit use of dev_xxx() instead of netdev_xxx() here:
* information displayed are related to the device itself, not
* to the canx (channel) device.
*/
dev_info(dev->netdev->dev.parent,
"PEAK-System %s v%u fw v%u.%u.%u (%u channels)\n",
dev->adapter->name, pdev->usb_if->fw_info.hw_version,
pdev->usb_if->fw_info.fw_version[0],
pdev->usb_if->fw_info.fw_version[1],
pdev->usb_if->fw_info.fw_version[2],
dev->adapter->ctrl_count);
/* check for ability to switch between ISO/non-ISO modes */
if (pdev->usb_if->fw_info.fw_version[0] >= 2) {
/* firmware >= 2.x supports ISO/non-ISO switching */
dev->can.ctrlmode_supported |= CAN_CTRLMODE_FD_NON_ISO;
} else {
/* firmware < 2.x only supports fixed(!) non-ISO */
dev->can.ctrlmode |= CAN_CTRLMODE_FD_NON_ISO;
}
/* tell the hardware the can driver is running */
err = pcan_usb_fd_drv_loaded(dev, 1);
if (err) {
dev_err(dev->netdev->dev.parent,
"unable to tell %s driver is loaded (err %d)\n",
dev->adapter->name, err);
goto err_out_2;
}
} else {
/* otherwise, simply copy previous sibling's values */
struct pcan_usb_fd_device *ppdev =
container_of(dev->prev_siblings,
struct pcan_usb_fd_device, dev);
pdev->usb_if = ppdev->usb_if;
pdev->cmd_buffer_addr = ppdev->cmd_buffer_addr;
/* do a copy of the ctrlmode[_supported] too */
dev->can.ctrlmode = ppdev->dev.can.ctrlmode;
dev->can.ctrlmode_supported = ppdev->dev.can.ctrlmode_supported;
}
pdev->usb_if->dev[dev->ctrl_idx] = dev;
dev->device_number =
le32_to_cpu(pdev->usb_if->fw_info.dev_id[dev->ctrl_idx]);
/* set clock domain */
for (i = 0; i < ARRAY_SIZE(pcan_usb_fd_clk_freq); i++)
if (dev->adapter->clock.freq == pcan_usb_fd_clk_freq[i])
break;
if (i >= ARRAY_SIZE(pcan_usb_fd_clk_freq)) {
dev_warn(dev->netdev->dev.parent,
"incompatible clock frequencies\n");
err = -EINVAL;
goto err_out_2;
}
pcan_usb_fd_set_clock_domain(dev, i);
/* set LED in default state (end of init phase) */
pcan_usb_fd_set_can_led(dev, PCAN_UFD_LED_DEF);
return 0;
err_out_2:
kfree(pdev->cmd_buffer_addr);
err_out_1:
kfree(pdev->usb_if);
err_out:
return err;
}
/* called when driver module is being unloaded */
static void pcan_usb_fd_exit(struct peak_usb_device *dev)
{
struct pcan_usb_fd_device *pdev =
container_of(dev, struct pcan_usb_fd_device, dev);
/* when rmmod called before unplug and if down, should reset things
* before leaving
*/
if (dev->can.state != CAN_STATE_STOPPED) {
/* set bus off on the corresponding channel */
pcan_usb_fd_set_bus(dev, 0);
}
/* switch off corresponding CAN LEDs */
pcan_usb_fd_set_can_led(dev, PCAN_UFD_LED_OFF);
/* if channel #0 (only) */
if (dev->ctrl_idx == 0) {
/* turn off calibration message if any device were opened */
if (pdev->usb_if->dev_opened_count > 0)
pcan_usb_fd_set_options(dev, 0,
PUCAN_OPTION_ERROR,
PCAN_UFD_FLTEXT_CALIBRATION);
/* tell USB adapter that the driver is being unloaded */
pcan_usb_fd_drv_loaded(dev, 0);
}
}
/* called when the USB adapter is unplugged */
static void pcan_usb_fd_free(struct peak_usb_device *dev)
{
/* last device: can free shared objects now */
if (!dev->prev_siblings && !dev->next_siblings) {
struct pcan_usb_fd_device *pdev =
container_of(dev, struct pcan_usb_fd_device, dev);
/* free commands buffer */
kfree(pdev->cmd_buffer_addr);
/* free usb interface object */
kfree(pdev->usb_if);
}
}
/* blink LED's */
static int pcan_usb_fd_set_phys_id(struct net_device *netdev,
enum ethtool_phys_id_state state)
{
struct peak_usb_device *dev = netdev_priv(netdev);
int err = 0;
switch (state) {
case ETHTOOL_ID_ACTIVE:
err = pcan_usb_fd_set_can_led(dev, PCAN_UFD_LED_FAST);
break;
case ETHTOOL_ID_INACTIVE:
err = pcan_usb_fd_set_can_led(dev, PCAN_UFD_LED_DEF);
break;
default:
break;
}
return err;
}
static const struct ethtool_ops pcan_usb_fd_ethtool_ops = {
.set_phys_id = pcan_usb_fd_set_phys_id,
};
/* describes the PCAN-USB FD adapter */
static const struct can_bittiming_const pcan_usb_fd_const = {
.name = "pcan_usb_fd",
.tseg1_min = 1,
.tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
.tseg2_min = 1,
.tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
.sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
.brp_min = 1,
.brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
.brp_inc = 1,
};
static const struct can_bittiming_const pcan_usb_fd_data_const = {
.name = "pcan_usb_fd",
.tseg1_min = 1,
.tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
.tseg2_min = 1,
.tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
.sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
.brp_min = 1,
.brp_max = (1 << PUCAN_TFAST_BRP_BITS),
.brp_inc = 1,
};
const struct peak_usb_adapter pcan_usb_fd = {
.name = "PCAN-USB FD",
.device_id = PCAN_USBFD_PRODUCT_ID,
.ctrl_count = PCAN_USBFD_CHANNEL_COUNT,
.ctrlmode_supported = CAN_CTRLMODE_FD |
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC,
.clock = {
.freq = PCAN_UFD_CRYSTAL_HZ,
},
.bittiming_const = &pcan_usb_fd_const,
.data_bittiming_const = &pcan_usb_fd_data_const,
/* size of device private data */
.sizeof_dev_private = sizeof(struct pcan_usb_fd_device),
.ethtool_ops = &pcan_usb_fd_ethtool_ops,
/* timestamps usage */
.ts_used_bits = 32,
.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
.us_per_ts_shift = 0,
/* give here messages in/out endpoints */
.ep_msg_in = PCAN_USBPRO_EP_MSGIN,
.ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0},
/* size of rx/tx usb buffers */
.rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE,
.tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE,
/* device callbacks */
.intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */
.dev_init = pcan_usb_fd_init,
.dev_exit = pcan_usb_fd_exit,
.dev_free = pcan_usb_fd_free,
.dev_set_bus = pcan_usb_fd_set_bus,
.dev_set_bittiming = pcan_usb_fd_set_bittiming_slow,
.dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast,
.dev_decode_buf = pcan_usb_fd_decode_buf,
.dev_start = pcan_usb_fd_start,
.dev_stop = pcan_usb_fd_stop,
.dev_restart_async = pcan_usb_fd_restart_async,
.dev_encode_msg = pcan_usb_fd_encode_msg,
.do_get_berr_counter = pcan_usb_fd_get_berr_counter,
};
/* describes the PCAN-CHIP USB */
static const struct can_bittiming_const pcan_usb_chip_const = {
.name = "pcan_chip_usb",
.tseg1_min = 1,
.tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
.tseg2_min = 1,
.tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
.sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
.brp_min = 1,
.brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
.brp_inc = 1,
};
static const struct can_bittiming_const pcan_usb_chip_data_const = {
.name = "pcan_chip_usb",
.tseg1_min = 1,
.tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
.tseg2_min = 1,
.tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
.sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
.brp_min = 1,
.brp_max = (1 << PUCAN_TFAST_BRP_BITS),
.brp_inc = 1,
};
const struct peak_usb_adapter pcan_usb_chip = {
.name = "PCAN-Chip USB",
.device_id = PCAN_USBCHIP_PRODUCT_ID,
.ctrl_count = PCAN_USBFD_CHANNEL_COUNT,
.ctrlmode_supported = CAN_CTRLMODE_FD |
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC,
.clock = {
.freq = PCAN_UFD_CRYSTAL_HZ,
},
.bittiming_const = &pcan_usb_chip_const,
.data_bittiming_const = &pcan_usb_chip_data_const,
/* size of device private data */
.sizeof_dev_private = sizeof(struct pcan_usb_fd_device),
.ethtool_ops = &pcan_usb_fd_ethtool_ops,
/* timestamps usage */
.ts_used_bits = 32,
.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
.us_per_ts_shift = 0,
/* give here messages in/out endpoints */
.ep_msg_in = PCAN_USBPRO_EP_MSGIN,
.ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0},
/* size of rx/tx usb buffers */
.rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE,
.tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE,
/* device callbacks */
.intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */
.dev_init = pcan_usb_fd_init,
.dev_exit = pcan_usb_fd_exit,
.dev_free = pcan_usb_fd_free,
.dev_set_bus = pcan_usb_fd_set_bus,
.dev_set_bittiming = pcan_usb_fd_set_bittiming_slow,
.dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast,
.dev_decode_buf = pcan_usb_fd_decode_buf,
.dev_start = pcan_usb_fd_start,
.dev_stop = pcan_usb_fd_stop,
.dev_restart_async = pcan_usb_fd_restart_async,
.dev_encode_msg = pcan_usb_fd_encode_msg,
.do_get_berr_counter = pcan_usb_fd_get_berr_counter,
};
/* describes the PCAN-USB Pro FD adapter */
static const struct can_bittiming_const pcan_usb_pro_fd_const = {
.name = "pcan_usb_pro_fd",
.tseg1_min = 1,
.tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
.tseg2_min = 1,
.tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
.sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
.brp_min = 1,
.brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
.brp_inc = 1,
};
static const struct can_bittiming_const pcan_usb_pro_fd_data_const = {
.name = "pcan_usb_pro_fd",
.tseg1_min = 1,
.tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
.tseg2_min = 1,
.tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
.sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
.brp_min = 1,
.brp_max = (1 << PUCAN_TFAST_BRP_BITS),
.brp_inc = 1,
};
const struct peak_usb_adapter pcan_usb_pro_fd = {
.name = "PCAN-USB Pro FD",
.device_id = PCAN_USBPROFD_PRODUCT_ID,
.ctrl_count = PCAN_USBPROFD_CHANNEL_COUNT,
.ctrlmode_supported = CAN_CTRLMODE_FD |
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC,
.clock = {
.freq = PCAN_UFD_CRYSTAL_HZ,
},
.bittiming_const = &pcan_usb_pro_fd_const,
.data_bittiming_const = &pcan_usb_pro_fd_data_const,
/* size of device private data */
.sizeof_dev_private = sizeof(struct pcan_usb_fd_device),
.ethtool_ops = &pcan_usb_fd_ethtool_ops,
/* timestamps usage */
.ts_used_bits = 32,
.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
.us_per_ts_shift = 0,
/* give here messages in/out endpoints */
.ep_msg_in = PCAN_USBPRO_EP_MSGIN,
.ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0, PCAN_USBPRO_EP_MSGOUT_1},
/* size of rx/tx usb buffers */
.rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE,
.tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE,
/* device callbacks */
.intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */
.dev_init = pcan_usb_fd_init,
.dev_exit = pcan_usb_fd_exit,
.dev_free = pcan_usb_fd_free,
.dev_set_bus = pcan_usb_fd_set_bus,
.dev_set_bittiming = pcan_usb_fd_set_bittiming_slow,
.dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast,
.dev_decode_buf = pcan_usb_fd_decode_buf,
.dev_start = pcan_usb_fd_start,
.dev_stop = pcan_usb_fd_stop,
.dev_restart_async = pcan_usb_fd_restart_async,
.dev_encode_msg = pcan_usb_fd_encode_msg,
.do_get_berr_counter = pcan_usb_fd_get_berr_counter,
};
/* describes the PCAN-USB X6 adapter */
static const struct can_bittiming_const pcan_usb_x6_const = {
.name = "pcan_usb_x6",
.tseg1_min = 1,
.tseg1_max = (1 << PUCAN_TSLOW_TSGEG1_BITS),
.tseg2_min = 1,
.tseg2_max = (1 << PUCAN_TSLOW_TSGEG2_BITS),
.sjw_max = (1 << PUCAN_TSLOW_SJW_BITS),
.brp_min = 1,
.brp_max = (1 << PUCAN_TSLOW_BRP_BITS),
.brp_inc = 1,
};
static const struct can_bittiming_const pcan_usb_x6_data_const = {
.name = "pcan_usb_x6",
.tseg1_min = 1,
.tseg1_max = (1 << PUCAN_TFAST_TSGEG1_BITS),
.tseg2_min = 1,
.tseg2_max = (1 << PUCAN_TFAST_TSGEG2_BITS),
.sjw_max = (1 << PUCAN_TFAST_SJW_BITS),
.brp_min = 1,
.brp_max = (1 << PUCAN_TFAST_BRP_BITS),
.brp_inc = 1,
};
const struct peak_usb_adapter pcan_usb_x6 = {
.name = "PCAN-USB X6",
.device_id = PCAN_USBX6_PRODUCT_ID,
.ctrl_count = PCAN_USBPROFD_CHANNEL_COUNT,
.ctrlmode_supported = CAN_CTRLMODE_FD |
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC,
.clock = {
.freq = PCAN_UFD_CRYSTAL_HZ,
},
.bittiming_const = &pcan_usb_x6_const,
.data_bittiming_const = &pcan_usb_x6_data_const,
/* size of device private data */
.sizeof_dev_private = sizeof(struct pcan_usb_fd_device),
.ethtool_ops = &pcan_usb_fd_ethtool_ops,
/* timestamps usage */
.ts_used_bits = 32,
.us_per_ts_scale = 1, /* us = (ts * scale) >> shift */
.us_per_ts_shift = 0,
/* give here messages in/out endpoints */
.ep_msg_in = PCAN_USBPRO_EP_MSGIN,
.ep_msg_out = {PCAN_USBPRO_EP_MSGOUT_0, PCAN_USBPRO_EP_MSGOUT_1},
/* size of rx/tx usb buffers */
.rx_buffer_size = PCAN_UFD_RX_BUFFER_SIZE,
.tx_buffer_size = PCAN_UFD_TX_BUFFER_SIZE,
/* device callbacks */
.intf_probe = pcan_usb_pro_probe, /* same as PCAN-USB Pro */
.dev_init = pcan_usb_fd_init,
.dev_exit = pcan_usb_fd_exit,
.dev_free = pcan_usb_fd_free,
.dev_set_bus = pcan_usb_fd_set_bus,
.dev_set_bittiming = pcan_usb_fd_set_bittiming_slow,
.dev_set_data_bittiming = pcan_usb_fd_set_bittiming_fast,
.dev_decode_buf = pcan_usb_fd_decode_buf,
.dev_start = pcan_usb_fd_start,
.dev_stop = pcan_usb_fd_stop,
.dev_restart_async = pcan_usb_fd_restart_async,
.dev_encode_msg = pcan_usb_fd_encode_msg,
.do_get_berr_counter = pcan_usb_fd_get_berr_counter,
};
| 27.527736 | 79 | 0.723136 | [
"object"
] |
b123218e44417f0f19ecd1f85a9688463bbd70ce | 8,884 | h | C | packages/seacas/libraries/ioss/src/cgns/Iocgns_DecompositionData.h | tokusanya/seacas | 54d9c3b68508ca96e3db1fd00c5d84a810fb330b | [
"Zlib",
"NetCDF",
"MIT",
"BSL-1.0",
"X11",
"BSD-3-Clause"
] | null | null | null | packages/seacas/libraries/ioss/src/cgns/Iocgns_DecompositionData.h | tokusanya/seacas | 54d9c3b68508ca96e3db1fd00c5d84a810fb330b | [
"Zlib",
"NetCDF",
"MIT",
"BSL-1.0",
"X11",
"BSD-3-Clause"
] | null | null | null | packages/seacas/libraries/ioss/src/cgns/Iocgns_DecompositionData.h | tokusanya/seacas | 54d9c3b68508ca96e3db1fd00c5d84a810fb330b | [
"Zlib",
"NetCDF",
"MIT",
"BSL-1.0",
"X11",
"BSD-3-Clause"
] | null | null | null | /*
* Copyright(C) 1999-2022 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
* See packages/seacas/LICENSE for details
*/
#pragma once
#include <cgnsconfig.h>
#if CG_BUILD_PARALLEL
#include <string>
#include <vector>
#define CG_USE_ROBIN
#if defined CG_USE_STD
#include <unordered_map>
#elif defined CG_USE_HOPSCOTCH
#include <bhopscotch_map.h>
#elif defined CG_USE_ROBIN
#include <robin_map.h>
#endif
#include <cstddef>
#include <cstdint>
#include <Ioss_CodeTypes.h>
#include <Ioss_Decomposition.h>
#include <Ioss_FaceGenerator.h>
#include <Ioss_Field.h>
#include <Ioss_MeshType.h>
#include <Ioss_PropertyManager.h>
#include <Ioss_StructuredBlock.h>
#include <cgns/Iocgns_StructuredZoneData.h>
#include <cgnslib.h>
#if 0
#if !defined(NO_PARMETIS_SUPPORT)
#include <parmetis.h>
#endif
#endif
#undef MPICPP
#if !defined(NO_ZOLTAN_SUPPORT)
#include <zoltan_cpp.h>
#endif
namespace Ioss {
class Field;
template <typename INT> class Decomposition;
} // namespace Ioss
namespace Iocgns {
class ZoneData
{
public:
std::string m_name;
size_t m_nodeOffset;
size_t m_nodeCount;
size_t m_elementOffset;
};
class DecompositionDataBase
{
public:
DecompositionDataBase() = default;
virtual ~DecompositionDataBase();
virtual void decompose_model(int filePtr, Ioss::MeshType mesh_type) = 0;
virtual size_t ioss_node_count() const = 0;
virtual size_t ioss_elem_count() const = 0;
virtual int int_size() const = 0;
virtual int spatial_dimension() const = 0;
virtual size_t global_node_count() const = 0;
virtual size_t global_elem_count() const = 0;
virtual size_t decomp_node_offset() const = 0;
virtual size_t decomp_node_count() const = 0;
virtual size_t decomp_elem_offset() const = 0;
virtual size_t decomp_elem_count() const = 0;
virtual std::vector<double> ¢roids() = 0;
virtual size_t get_commset_node_size() const = 0;
virtual void get_node_coordinates(int filePtr, double *ioss_data,
const Ioss::Field &field) const = 0;
void get_block_connectivity(int filePtr, void *data, int blk_seq, bool raw_ids = false) const;
void get_element_field(int filePtr, int solution_index, int blk_seq, int field_index,
double *data) const;
void get_node_field(int filePtr, int step, int field_index, double *data) const;
void get_node_entity_proc_data(void *entity_proc, const Ioss::MapContainer &node_map,
bool do_map) const;
template <typename T>
void communicate_element_data(T *file_data, T *ioss_data, size_t comp_count) const;
template <typename T>
void communicate_node_data(T *file_data, T *ioss_data, size_t comp_count) const;
void get_sideset_element_side(int filePtr, const Ioss::SetDecompositionData &sset,
void *data) const;
std::vector<ZoneData> m_zones;
std::vector<Ioss::BlockDecompositionData> m_elementBlocks;
std::vector<Ioss::SetDecompositionData> m_sideSets;
std::vector<Iocgns::StructuredZoneData *> m_structuredZones;
// Maps nodes shared between zones.
// TODO: Currently each processor has same map; need to figure out how to reduce size
#if defined CG_USE_STD
using ZoneSharedMap = std::unordered_map<cgsize_t, cgsize_t>;
#elif defined CG_USE_HOPSCOTCH
// using ZoneSharedMap = tsl::hopscotch_map<cgsize_t, cgsize_t>;
using ZoneSharedMap = tsl::bhopscotch_map<cgsize_t, cgsize_t>;
#elif defined CG_USE_ROBIN
using ZoneSharedMap = tsl::robin_map<cgsize_t, cgsize_t>;
#endif
ZoneSharedMap m_zoneSharedMap;
};
template <typename INT> class DecompositionData : public DecompositionDataBase
{
public:
DecompositionData(const Ioss::PropertyManager &props, Ioss_MPI_Comm communicator);
~DecompositionData() override = default;
int int_size() const override { return sizeof(INT); }
void decompose_model(int filePtr, Ioss::MeshType mesh_type) override;
int spatial_dimension() const override { return m_decomposition.m_spatialDimension; }
size_t global_node_count() const override { return m_decomposition.global_node_count(); }
size_t global_elem_count() const override { return m_decomposition.global_elem_count(); }
size_t ioss_node_count() const override { return m_decomposition.ioss_node_count(); }
size_t ioss_elem_count() const override { return m_decomposition.ioss_elem_count(); }
size_t decomp_node_offset() const override { return m_decomposition.file_node_offset(); }
size_t decomp_node_count() const override { return m_decomposition.file_node_count(); }
size_t decomp_elem_offset() const override { return m_decomposition.file_elem_offset(); }
size_t decomp_elem_count() const override { return m_decomposition.file_elem_count(); }
std::vector<double> ¢roids() override { return m_decomposition.m_centroids; }
template <typename T>
void communicate_element_data(T *file_data, T *ioss_data, size_t comp_count) const
{
m_decomposition.communicate_element_data(file_data, ioss_data, comp_count);
}
template <typename T>
void communicate_set_data(T *file_data, T *ioss_data, const Ioss::SetDecompositionData &set,
size_t comp_count) const
{
m_decomposition.communicate_set_data(file_data, ioss_data, set, comp_count);
}
template <typename T>
void communicate_node_data(T *file_data, T *ioss_data, size_t comp_count) const
{
m_decomposition.communicate_node_data(file_data, ioss_data, comp_count);
}
template <typename U, typename T>
void communicate_block_data(U *file_data, T *ioss_data,
const Ioss::BlockDecompositionData &block, size_t comp_count) const
{
m_decomposition.communicate_block_data(file_data, ioss_data, block, comp_count);
}
void get_block_connectivity(int filePtr, INT *data, int blk_seq, bool raw_ids) const;
void get_element_field(int filePtr, int solution_index, int blk_seq, int field_index,
double *data) const;
void get_node_field(int filePtr, int step, int field_offset, double *data) const;
size_t get_commset_node_size() const override
{
return m_decomposition.m_nodeCommMap.size() / 2;
}
void get_sideset_element_side(int filePtr, const Ioss::SetDecompositionData &sset,
INT *data) const;
private:
void decompose_structured(int filePtr);
void decompose_unstructured(int filePtr);
void get_sideset_data(int filePtr);
void generate_zone_shared_nodes(int filePtr, INT min_node, INT max_node);
bool i_own_node(size_t node)
const // T/F if node with global index node owned by this processors ioss-decomp.
{
return m_decomposition.i_own_node(node);
}
bool i_own_elem(size_t elem)
const // T/F if node with global index elem owned by this processors ioss-decomp.
{
return m_decomposition.i_own_elem(elem);
}
// global_index is 1-based index into global list of nodes [1..global_node_count]
// return value is 1-based index into local list of nodes on this
// processor (ioss-decomposition)
size_t node_global_to_local(size_t global_index) const
{
return m_decomposition.node_global_to_local(global_index);
}
size_t elem_global_to_local(size_t global_index) const
{
return m_decomposition.elem_global_to_local(global_index);
}
void build_global_to_local_elem_map()
{
return m_decomposition.build_global_to_local_elem_map();
}
void get_element_block_communication()
{
m_decomposition.get_element_block_communication(m_elementBlocks);
}
void generate_adjacency_list(int filePtr, Ioss::Decomposition<INT> &decomposition);
void calculate_element_centroids(int filePtr, std::vector<double> ¢roids);
void get_shared_node_list() { m_decomposition.get_shared_node_list(); }
void get_local_node_list() { m_decomposition.get_local_node_list(); }
void get_file_node_coordinates(int filePtr, int direction, double *ioss_data) const;
void get_node_coordinates(int filePtr, double *ioss_data,
const Ioss::Field &field) const override;
double m_loadBalanceThreshold{1.4};
std::string m_lineDecomposition{};
mutable std::map<int, Ioss::FaceUnorderedSet> m_boundaryFaces;
public:
Ioss::Decomposition<INT> m_decomposition;
};
} // namespace Iocgns
#endif
| 34.169231 | 99 | 0.708802 | [
"vector"
] |
b12473ccf5b4238f4ee95b7848a0842ee5b2ffe0 | 1,813 | h | C | lite/backends/opencl/cl_context.h | smilejames/Paddle-Lite | be7ff0d2731c9e7ea936b6e490b2d6221ba293b1 | [
"Apache-2.0"
] | null | null | null | lite/backends/opencl/cl_context.h | smilejames/Paddle-Lite | be7ff0d2731c9e7ea936b6e490b2d6221ba293b1 | [
"Apache-2.0"
] | null | null | null | lite/backends/opencl/cl_context.h | smilejames/Paddle-Lite | be7ff0d2731c9e7ea936b6e490b2d6221ba293b1 | [
"Apache-2.0"
] | null | null | null | /* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "lite/backends/opencl/cl_image.h"
#include "lite/backends/opencl/cl_include.h"
namespace paddle {
namespace lite {
class CLContext {
public:
cl::CommandQueue &GetCommandQueue();
cl::Context &GetContext();
cl::Program &GetProgram(const std::string &file_name,
const std::string &options);
void AddKernel(const std::string &kernel_name,
const std::string &file_name,
const std::string &options = "",
const std::string &time_stamp = "");
cl::Kernel &GetKernel(const int index);
cl::Kernel &GetKernel(const std::string &name);
cl::NDRange DefaultWorkSize(const CLImage &image);
cl::NDRange LocalWorkSize(cl::NDRange global_work_size, size_t max_work_size);
cl::NDRange LocalWorkSizeTurn(cl::NDRange global_work_size,
size_t max_work_size,
int divitor = 2);
// cl::NDRange LocalWorkSizeConv1x1(cl::NDRange global_work_size,
// size_t max_work_size);
};
} // namespace lite
} // namespace paddle
| 30.728814 | 80 | 0.68064 | [
"vector"
] |
b1265b1b03aad8e45391772bca0d9404ad0d9dbe | 4,065 | h | C | perception/visual_tracking/struck_node/src/struck_tracker.h | togaen/open_maeve | 5a5916a8519f4184f5b73c74e5a229df45a02af5 | [
"MIT"
] | null | null | null | perception/visual_tracking/struck_node/src/struck_tracker.h | togaen/open_maeve | 5a5916a8519f4184f5b73c74e5a229df45a02af5 | [
"MIT"
] | null | null | null | perception/visual_tracking/struck_node/src/struck_tracker.h | togaen/open_maeve | 5a5916a8519f4184f5b73c74e5a229df45a02af5 | [
"MIT"
] | null | null | null | /*
* Copyright 2017 Maeve Automation
*
* Struck: Structured Output Tracking with Kernels
*
* Derived work of code to accompany the paper:
* Struck: Structured Output Tracking with Kernels
* Sam Hare, Amir Saffari, Philip H. S. Torr
* International Conference on Computer Vision (ICCV), 2011
*
* Copyright (C) 2011 Sam Hare, Oxford Brookes University, Oxford, UK
*
* This file is a derivative work of Struck.
*
* Struck is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Struck is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Struck. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <cv_bridge/cv_bridge.h>
#include <image_transport/image_transport.h>
#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <std_msgs/Bool.h>
#include <cstdint>
#include <memory>
#include <string>
#include "./params.h"
#include "open_maeve/struck/struck.h"
#include "struck_node/ImageBoundingBox.h"
namespace open_maeve {
/**
* @brief Convenience encapsulaton of functions/variable for running tracker.
*/
class StruckTracker {
public:
/**
* @brief Construct an instance of this class using a ROS node handle.
*
* @param nh The handle of the node owning this object.
*/
explicit StruckTracker(ros::NodeHandle& nh);
/**
* @brief Whether this object is probably validly initialized.
*
* @note The tests in this function do not guarantee parameterization is
* correct; they only check for obvious problems.
*
* @return True if the sanity checks pass; otherwise false.
*/
bool valid() const;
private:
/** @brief Flag for whether to initialize the tracker.*/
bool doInitialise;
/** @brief ROS parameter object.*/
StruckVisualTrackingParams params;
/** @brief STRUCK parameter object.*/
Config conf;
/** @brief The STRUCK tracker object.*/
std::unique_ptr<Tracker> tracker;
/** @brief The gemoetry of the initial bounding box.*/
FloatRect initBB;
/** @brief Whether the user has triggered initialization yet.*/
bool is_user_initted;
/** @brief Whether the tracker has been successfully initialized.*/
bool initialized_successfully;
/** @brief Storage for the tracker visualization.*/
cv_bridge::CvImage result;
/** @brief Image transport object for publish/subscribe of images.*/
image_transport::ImageTransport it;
/** @brief ROS publisher for tracker visualization.*/
image_transport::Publisher tracker_image_pub;
/** @brief ROS publisher for tracker bounding box output.*/
ros::Publisher tracker_bb_pub;
/** @brief ROS subscriber for user initialization trigger topic.*/
ros::Subscriber user_init_sub;
/** @brief ROS subscriber for camera topic.*/
image_transport::Subscriber camera_sub;
/**
* @brief Callback to run the tracker on each input image frame.
*
* @param msg The image frame.
*/
void cameraCallback(const sensor_msgs::Image::ConstPtr& msg);
/**
* @brief Callback to initialize the tracker based on the user trigger.
*
* @param msg The boolean flag indicating the user trigger.
*/
void userInitCallback(const std_msgs::Bool::ConstPtr& msg);
/**
* @brief Publish a visualization of tracker output.
*
* @param time The desired stamp that the visualization image should have.
*/
void publishTrackerImage(const ros::Time& time) const;
/**
* @brief Publish the bounding box output of the tracker.
*
* @param time The desired stamp that the bounding box output should have.
*/
void publishBoundingBox(const ros::Time& time) const;
}; // class StruckTracker
} // namespace open_maeve
| 29.035714 | 77 | 0.717589 | [
"object"
] |
b1294ef117a0d08255658b425014f5cb6f0c7572 | 17,717 | h | C | groups/bal/ball/ball_userfieldvalue.h | apaprocki/bde | ba252cb776f92fae082d5d422aa2852a9be46849 | [
"Apache-2.0"
] | 1 | 2021-04-28T13:51:30.000Z | 2021-04-28T13:51:30.000Z | groups/bal/ball/ball_userfieldvalue.h | apaprocki/bde | ba252cb776f92fae082d5d422aa2852a9be46849 | [
"Apache-2.0"
] | null | null | null | groups/bal/ball/ball_userfieldvalue.h | apaprocki/bde | ba252cb776f92fae082d5d422aa2852a9be46849 | [
"Apache-2.0"
] | 1 | 2019-06-26T13:28:48.000Z | 2019-06-26T13:28:48.000Z | // ball_userfieldvalue.h -*-C++-*-
#ifndef INCLUDED_BALL_USERFIELDVALUE
#define INCLUDED_BALL_USERFIELDVALUE
#ifndef INCLUDED_BSLS_IDENT
#include <bsls_ident.h>
#endif
BSLS_IDENT("$Id: $")
//@PURPOSE: Provide a type for the value of a user supplied field.
//
//@CLASSES:
// ball::UserFieldValue: the value of a user supplied field
//
//@SEE_ALSO: ball_userfields, ball_userfieldtype
//
//@DESCRIPTION: This component provides a value-semantic class,
// 'ball::UserFieldValue', that represents the value of a user supplied log
// field value. A user field value acts as a discriminated union, and may
// represent a value of any of types described in 'ball::UserFieldType' or an
// unset value (indicated by the type 'ball::UserFieldType::e_VOID').
//
///Usage
///-----
// This section illustrates intended use of this component.
//
///Example 1: Basic Use of 'ball::UserFieldValue'
/// - - - - - - - - - - - - - - - - - - - - - - -
// The following snippets of code illustrate how to create and use a
// 'ball::UserFieldValue' object. Note that 'ball::UserFieldValue' objects are
// typically used in a description of a sequence of user fields (see
// 'ball_userfields').
//
// First, we create a default 'ball::UserFieldValue', 'valueA', and observe
// that it is in the unset state, meaning that 'isUnset' is true and its type
// is 'ball::UserFieldValue::e_VOID':
//..
// ball::UserFieldValue valueA;
//
// assert(true == valueA.isUnset());
// assert(ball::UserFieldValue::e_VOID == valueA.type());
//..
// Next, we create a second 'ball::UserFieldValue' having the value 5, and then
// confirm its value and observe that it does not compare equal to the
// 'valueA':
//..
// ball::UserFieldValue valueB(5);
//
// assert(false == valueB.isUnset());
// assert(ball::UserFieldValue::e_INT64 == valueB.type());
// assert(5 == valueB.theInt64();
//
// assert(valueA != valueB);
//..
// Finally, we call 'reset' of 'valueB' resetting it to the unset state, and
// observe that 'valueA' now compares equal to 'valueB':
//..
// valueB.reset();
//
// assert(valueA == valueB);
//..
#ifndef INCLUDED_BALSCM_VERSION
#include <balscm_version.h>
#endif
#ifndef INCLUDED_BALL_USERFIELDTYPE
#include <ball_userfieldtype.h>
#endif
#ifndef INCLUDED_BDLB_VARIANT
#include <bdlb_variant.h>
#endif
#ifndef INCLUDED_BDLT_DATETIMETZ
#include <bdlt_datetimetz.h>
#endif
#ifndef INCLUDED_BSLMA_ALLOCATOR
#include <bslma_allocator.h>
#endif
#ifndef INCLUDED_BSLMA_USESBSLMAALLOCATOR
#include <bslma_usesbslmaallocator.h>
#endif
#ifndef INCLUDED_BSLMF_NESTEDTRAITDECLARATION
#include <bslmf_nestedtraitdeclaration.h>
#endif
#ifndef INCLUDED_BSLS_ASSERT
#include <bsls_assert.h>
#endif
#ifndef INCLUDED_BSLS_TYPES
#include <bsls_types.h>
#endif
#ifndef INCLUDED_BSL_STRING
#include <bsl_string.h>
#endif
#ifndef INCLUDED_BSL_VECTOR
#include <bsl_vector.h>
#endif
namespace BloombergLP {
namespace ball {
// ====================
// class UserFieldValue
// ====================
class UserFieldValue {
// This class implements a value-semantic type for representing the value
// of a user field in a log record. A user field value acts as a
// discriminated union, and may represent a value of any of types described
// in 'ball::UserFieldType' or an unset value (indicated type
// 'ball::UserFieldType::e_VOID').
// PRIVATE TYPES
typedef bdlb::Variant<bsls::Types::Int64,
double,
bsl::string,
bdlt::DatetimeTz,
bsl::vector<char> > ValueVariant;
// DATA
ValueVariant d_value; // value
// FRIENDS
friend bool operator==(const UserFieldValue&, const UserFieldValue&);
public:
// TRAITS
BSLMF_NESTED_TRAIT_DECLARATION(UserFieldValue, bslma::UsesBslmaAllocator);
// CREATORS
explicit UserFieldValue(bslma::Allocator *basicAllocator = 0);
// Create a user field value having the unset value. Optionally
// specify a 'basicAllocator' used to supply memory. If
// 'basicAllocator' is 0, the currently installed default allocator is
// used.
explicit UserFieldValue(bsls::Types::Int64 value,
bslma::Allocator *basicAllocator = 0);
explicit UserFieldValue(double value,
bslma::Allocator *basicAllocator = 0);
explicit UserFieldValue(bslstl::StringRef value,
bslma::Allocator *basicAllocator = 0);
explicit UserFieldValue(const bdlt::DatetimeTz& value,
bslma::Allocator *basicAllocator = 0);
explicit UserFieldValue(const bsl::vector<char>& value,
bslma::Allocator *basicAllocator = 0);
// Create a user field value having the specified 'value'. Optionally
// specify a 'basicAllocator' used to supply memory. If
// 'basicAllocator' is 0, the currently installed default allocator is
// used.
template <class INTEGRAL_TYPE>
explicit UserFieldValue(
INTEGRAL_TYPE value,
bslma::Allocator *basicAllocator = 0,
typename bsl::enable_if<
bsl::is_integral<INTEGRAL_TYPE>::value>::type * = 0)
: d_value(static_cast<bsls::Types::Int64>(value), basicAllocator) {}
// Create a user field value having the specified integral 'value'.
// Optionally specify a 'basicAllocator' used to supply memory. If
// 'basicAllocator' is 0, the currently installed default allocator is
// used.
//
// Note that this constructor is provided to disambiguate between
// constructors taking 'double' and 'bsls::Types::Int64' when supplied
// an integer that is not of type 'bsls::Types::Int64'. Also note that
// the implementation is (temporarily) provided inline to avoid issues
// with MSVC 2008.
UserFieldValue(const UserFieldValue& original,
bslma::Allocator *basicAllocator = 0);
// Create a 'UserFieldValue' object having the same value as the
// specified 'original' object. Optionally specify a 'basicAllocator'
// used to supply memory. If 'basicAllocator' is 0, the currently
// installed default allocator is used.
//! ~UserFieldValue() = default;
// Destroy this object.
// MANIPULATORS
UserFieldValue& operator=(const UserFieldValue& rhs);
// Assign to this object the value of the specified 'rhs' object, and
// return a reference providing modifiable access to this object.
void reset();
// Set this object to have the unset value. After this operation,
// 'type() == ball::UserFieldType::e_VOID'.
void setInt64(bsls::Types::Int64 value);
// Set this object to have the specified 'value'. After this
// operation, 'type() == ball::UserFieldType::e_INT64'.
void setDouble(double value);
// Set this object to have the specified 'value'. After this
// operation, 'type() == ball::UserFieldType::e_DOUBLE'.
void setString(bslstl::StringRef value);
// Set this object to have the specified 'value'. After this
// operation, 'type() == ball::UserFieldType::e_STRING'.
void setDatetimeTz(const bdlt::DatetimeTz& value);
// Set this object to have the specified 'value'. After this
// operation, 'type() == ball::UserFieldType::e_DATETIMETZ'.
void setCharArray(const bsl::vector<char>& value);
// Set this object to have the specified 'value'. After this
// operation, 'type() == ball::UserFieldType::e_CHAR_ARRAY'.
// Aspects
void swap(UserFieldValue& other);
// Efficiently exchange the value of this object with the value of the
// specified 'other' object. This method provides the no-throw
// guarantee if 'type()' is the same as 'other.type()'; otherwise, it
// provides the basic guarantee.
// ACCESSORS
bool isUnset() const;
// Return 'true' if this object has the unset value, and 'false'
// otherwise. Note that if 'isUnset()' returns 'true', then 'type()'
// returns 'ball::UserFieldType::e_VOID'.
ball::UserFieldType::Enum type() const;
// Return the type of this user field value. The type
// 'ball::UserFieldValue::e_VOID' represents the unset value.
const bsls::Types::Int64& theInt64() const;
// Return a reference providing non-modifiable access to the 64-bit
// integer value of this object. The behavior is undefined unless
// 'type() == ball::UserFieldType::e_INT64'.
const double& theDouble() const;
// Return a reference providing non-modifiable access to the double
// value of this object. The behavior is undefined unless
// 'type() == ball::UserFieldType::e_DOUBLE'.
const bsl::string& theString() const;
// Return a reference providing non-modifiable access to the string
// value of this object. The behavior is undefined unless
// 'type() == ball::UserFieldType::e_STRING'.
const bdlt::DatetimeTz& theDatetimeTz() const;
// Return a reference providing non-modifiable access to the
// 'DatetimeTz' value of this object. The behavior is undefined
// unless 'type() == ball::UserFieldType::e_DATETIMETZ'.
const bsl::vector<char>& theCharArray() const;
// Return a reference providing non-modifiable access to the
// 'bsl::vector<char>' value of this object. The behavior is undefined
// unless 'type() == ball::UserFieldType::e_CHAR_ARRAY'.
// Aspects
bslma::Allocator *allocator() const;
// Return the allocator used by this object to supply memory. Note
// that if no allocator was supplied at construction the currently
// installed default allocator is used.
bsl::ostream& print(bsl::ostream& stream,
int level = 0,
int spacesPerLevel = 4) const;
// Write the value of this object to the specified output 'stream' in
// a human-readable format, and return a reference to 'stream'.
// Optionally specify an initial indentation 'level', whose absolute
// value is incremented recursively for nested objects. If 'level' is
// specified, optionally specify 'spacesPerLevel', whose absolute
// value indicates the number of spaces per indentation level for this
// and all of its nested objects. If 'level' is negative, suppress
// indentation of the first line. If 'spacesPerLevel' is negative,
// format the entire output on one line, suppressing all but the
// initial indentation (as governed by 'level'). If 'stream' is not
// valid on entry, this operation has no effect. Note that the format
// is not fully specified, and can change without notice.
};
// FREE OPERATORS
bool operator==(const UserFieldValue& lhs, const UserFieldValue& rhs);
// Return 'true' if the specified 'lhs' and 'rhs' objects have the same
// value, and 'false' otherwise. Two 'UserFieldValue' objects have the
// same value if they have the same type, and (if the type is not
// 'e_VOID') the value of that type (as accessed through 'the*' methods)
// is the same.
bool operator!=(const UserFieldValue& lhs, const UserFieldValue& rhs);
// Return 'true' if the specified 'lhs' and 'rhs' objects do not have the
// same value, and 'false' otherwise. Two 'UserFieldValue' objects do not
// have the same value if their type is not the same, or (if their type
// is not 'e_VOID') the value of that type (as accessed through 'the*'
// methods) is not the same.
bsl::ostream& operator<<(bsl::ostream& stream, const UserFieldValue& object);
// Write the value of the specified 'object' to the specified output
// 'stream' in a single-line format, and return a reference to 'stream'.
// If 'stream' is not valid on entry, this operation has no effect. Note
// that this human-readable format is not fully specified, can change
// without notice, and is logically equivalent to:
//..
// print(stream, 0, -1);
//..
// FREE FUNCTIONS
void swap(ball::UserFieldValue& a, ball::UserFieldValue& b);
// Swap the value of the specified 'a' object with the value of the
// specified 'b' object. This method provides the no-throw guarantee if
// 'a.type()' is the same as 'b.type()'; otherwise, it provides the basic
// guarantee.
// ============================================================================
// INLINE DEFINITIONS
// ============================================================================
// --------------------
// class UserFieldValue
// --------------------
// CREATORS
inline
UserFieldValue::UserFieldValue(bslma::Allocator *basicAllocator)
: d_value(basicAllocator)
{
}
inline
UserFieldValue::UserFieldValue(bsls::Types::Int64 value,
bslma::Allocator *basicAllocator)
: d_value(value, basicAllocator)
{
}
inline
UserFieldValue::UserFieldValue(double value, bslma::Allocator *basicAllocator)
: d_value(value, basicAllocator)
{
}
inline
UserFieldValue::UserFieldValue(bslstl::StringRef value,
bslma::Allocator *basicAllocator)
: d_value(basicAllocator)
{
d_value.assign<bsl::string>(value);
}
inline
UserFieldValue::UserFieldValue(const bdlt::DatetimeTz& value,
bslma::Allocator *basicAllocator)
: d_value(value, basicAllocator)
{
}
inline
UserFieldValue::UserFieldValue(const bsl::vector<char>& value,
bslma::Allocator *basicAllocator)
: d_value(value, basicAllocator)
{
}
inline
UserFieldValue::UserFieldValue(const UserFieldValue& original,
bslma::Allocator *basicAllocator)
: d_value(original.d_value, basicAllocator)
{
}
// MANIPULATORS
inline
UserFieldValue& UserFieldValue::operator=(const UserFieldValue& rhs)
{
d_value = rhs.d_value;
return *this;
}
inline
void UserFieldValue::reset()
{
d_value.reset();
}
inline
void UserFieldValue::setInt64(bsls::Types::Int64 value)
{
d_value.assign(value);
}
inline
void UserFieldValue::setDouble(double value)
{
d_value.assign(value);
}
inline
void UserFieldValue::setString(bslstl::StringRef value)
{
d_value.assign<bsl::string>(value);
}
inline
void UserFieldValue::setDatetimeTz(const bdlt::DatetimeTz& value)
{
d_value.assign(value);
}
inline
void UserFieldValue::setCharArray(const bsl::vector<char>& value)
{
d_value.assign(value);
}
inline
void UserFieldValue::swap(UserFieldValue& other)
{
d_value.swap(other.d_value);
}
// ACCESSORS
inline
bool UserFieldValue::isUnset() const
{
return d_value.isUnset();
}
inline
const bsls::Types::Int64& UserFieldValue::theInt64() const
{
BSLS_ASSERT_SAFE(d_value.is<bsls::Types::Int64>());
return d_value.the<bsls::Types::Int64>();
}
inline
const double& UserFieldValue::theDouble() const
{
BSLS_ASSERT_SAFE(d_value.is<double>());
return d_value.the<double>();
}
inline
const bsl::string& UserFieldValue::theString() const
{
BSLS_ASSERT_SAFE(d_value.is<bsl::string>());
return d_value.the<bsl::string>();
}
inline
const bdlt::DatetimeTz& UserFieldValue::theDatetimeTz() const
{
BSLS_ASSERT_SAFE(d_value.is<bdlt::DatetimeTz>());
return d_value.the<bdlt::DatetimeTz>();
}
inline
const bsl::vector<char>& UserFieldValue::theCharArray() const
{
BSLS_ASSERT_SAFE(d_value.is<bsl::vector<char> >());
return d_value.the<bsl::vector<char> >();
}
// Aspects
inline
bslma::Allocator *UserFieldValue::allocator() const
{
return d_value.getAllocator();
}
} // close package namespace
// FREE OPERATORS
inline
bool ball::operator==(const UserFieldValue& lhs, const UserFieldValue& rhs)
{
return lhs.d_value == rhs.d_value;
}
inline
bool ball::operator!=(const UserFieldValue& lhs, const UserFieldValue& rhs)
{
return !(lhs == rhs);
}
inline
bsl::ostream& ball::operator<<(bsl::ostream& stream,
const UserFieldValue& object)
{
return object.print(stream, 0, -1);
}
// FREE FUNCTIONS
inline
void swap(ball::UserFieldValue& a, ball::UserFieldValue& b)
{
a.swap(b);
}
} // close enterprise namespace
#endif
// ----------------------------------------------------------------------------
// Copyright 2015 Bloomberg Finance L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------- END-OF-FILE ----------------------------------
| 34.005758 | 79 | 0.638709 | [
"object",
"vector"
] |
b12a99675b44ae98b46b17b3a6afb5037ff539d0 | 84,178 | h | C | controllers/player/protobuf/include/google/protobuf/util/message_differencer_unittest.pb.h | elsiros/elsiros_webots | 01a5d1e279a5d9d21eb0e8cf9be609d62428a4f3 | [
"MIT"
] | null | null | null | controllers/player/protobuf/include/google/protobuf/util/message_differencer_unittest.pb.h | elsiros/elsiros_webots | 01a5d1e279a5d9d21eb0e8cf9be609d62428a4f3 | [
"MIT"
] | 17 | 2021-07-26T13:57:53.000Z | 2021-09-09T13:16:13.000Z | controllers/player/protobuf/include/google/protobuf/util/message_differencer_unittest.pb.h | RoboCupHSJL/elsiros_webots | 01a5d1e279a5d9d21eb0e8cf9be609d62428a4f3 | [
"MIT"
] | 1 | 2021-11-25T18:51:43.000Z | 2021-11-25T18:51:43.000Z | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/util/message_differencer_unittest.proto
#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2futil_2fmessage_5fdifferencer_5funittest_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2futil_2fmessage_5fdifferencer_5funittest_2eproto
#include <limits>
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3017000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3017003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/map.h> // IWYU pragma: export
#include <google/protobuf/map_entry.h>
#include <google/protobuf/map_field_inl.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/any.pb.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2futil_2fmessage_5fdifferencer_5funittest_2eproto
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
} // namespace internal
PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_google_2fprotobuf_2futil_2fmessage_5fdifferencer_5funittest_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[4]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
};
extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2futil_2fmessage_5fdifferencer_5funittest_2eproto;
namespace protobuf_unittest {
class TestDiffMessage;
struct TestDiffMessageDefaultTypeInternal;
extern TestDiffMessageDefaultTypeInternal _TestDiffMessage_default_instance_;
class TestDiffMessage_Item;
struct TestDiffMessage_ItemDefaultTypeInternal;
extern TestDiffMessage_ItemDefaultTypeInternal _TestDiffMessage_Item_default_instance_;
class TestDiffMessage_Item_MpEntry_DoNotUse;
struct TestDiffMessage_Item_MpEntry_DoNotUseDefaultTypeInternal;
extern TestDiffMessage_Item_MpEntry_DoNotUseDefaultTypeInternal _TestDiffMessage_Item_MpEntry_DoNotUse_default_instance_;
class TestField;
struct TestFieldDefaultTypeInternal;
extern TestFieldDefaultTypeInternal _TestField_default_instance_;
} // namespace protobuf_unittest
PROTOBUF_NAMESPACE_OPEN
template<> ::protobuf_unittest::TestDiffMessage* Arena::CreateMaybeMessage<::protobuf_unittest::TestDiffMessage>(Arena*);
template<> ::protobuf_unittest::TestDiffMessage_Item* Arena::CreateMaybeMessage<::protobuf_unittest::TestDiffMessage_Item>(Arena*);
template<> ::protobuf_unittest::TestDiffMessage_Item_MpEntry_DoNotUse* Arena::CreateMaybeMessage<::protobuf_unittest::TestDiffMessage_Item_MpEntry_DoNotUse>(Arena*);
template<> ::protobuf_unittest::TestField* Arena::CreateMaybeMessage<::protobuf_unittest::TestField>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
namespace protobuf_unittest {
// ===================================================================
class TestField final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.TestField) */ {
public:
inline TestField() : TestField(nullptr) {}
~TestField() override;
explicit constexpr TestField(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
TestField(const TestField& from);
TestField(TestField&& from) noexcept
: TestField() {
*this = ::std::move(from);
}
inline TestField& operator=(const TestField& from) {
CopyFrom(from);
return *this;
}
inline TestField& operator=(TestField&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
&& GetOwningArena() != nullptr
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance);
}
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return default_instance().GetMetadata().descriptor;
}
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return default_instance().GetMetadata().reflection;
}
static const TestField& default_instance() {
return *internal_default_instance();
}
static inline const TestField* internal_default_instance() {
return reinterpret_cast<const TestField*>(
&_TestField_default_instance_);
}
static constexpr int kIndexInFileMessages =
0;
friend void swap(TestField& a, TestField& b) {
a.Swap(&b);
}
inline void Swap(TestField* other) {
if (other == this) return;
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() != nullptr &&
GetOwningArena() == other->GetOwningArena()) {
#else // PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() == other->GetOwningArena()) {
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(TestField* other) {
if (other == this) return;
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline TestField* New() const final {
return new TestField();
}
TestField* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<TestField>(arena);
}
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
void CopyFrom(const TestField& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
void MergeFrom(const TestField& from);
private:
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(TestField* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "protobuf_unittest.TestField";
}
protected:
explicit TestField(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kRcFieldNumber = 2,
kMFieldNumber = 5,
kCFieldNumber = 1,
kAFieldNumber = 3,
kBFieldNumber = 4,
};
// repeated int32 rc = 2;
int rc_size() const;
private:
int _internal_rc_size() const;
public:
void clear_rc();
private:
::PROTOBUF_NAMESPACE_ID::int32 _internal_rc(int index) const;
const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
_internal_rc() const;
void _internal_add_rc(::PROTOBUF_NAMESPACE_ID::int32 value);
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
_internal_mutable_rc();
public:
::PROTOBUF_NAMESPACE_ID::int32 rc(int index) const;
void set_rc(int index, ::PROTOBUF_NAMESPACE_ID::int32 value);
void add_rc(::PROTOBUF_NAMESPACE_ID::int32 value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
rc() const;
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
mutable_rc();
// optional .protobuf_unittest.TestField m = 5;
bool has_m() const;
private:
bool _internal_has_m() const;
public:
void clear_m();
const ::protobuf_unittest::TestField& m() const;
PROTOBUF_MUST_USE_RESULT ::protobuf_unittest::TestField* release_m();
::protobuf_unittest::TestField* mutable_m();
void set_allocated_m(::protobuf_unittest::TestField* m);
private:
const ::protobuf_unittest::TestField& _internal_m() const;
::protobuf_unittest::TestField* _internal_mutable_m();
public:
void unsafe_arena_set_allocated_m(
::protobuf_unittest::TestField* m);
::protobuf_unittest::TestField* unsafe_arena_release_m();
// optional int32 c = 1;
bool has_c() const;
private:
bool _internal_has_c() const;
public:
void clear_c();
::PROTOBUF_NAMESPACE_ID::int32 c() const;
void set_c(::PROTOBUF_NAMESPACE_ID::int32 value);
private:
::PROTOBUF_NAMESPACE_ID::int32 _internal_c() const;
void _internal_set_c(::PROTOBUF_NAMESPACE_ID::int32 value);
public:
// optional int32 a = 3;
bool has_a() const;
private:
bool _internal_has_a() const;
public:
void clear_a();
::PROTOBUF_NAMESPACE_ID::int32 a() const;
void set_a(::PROTOBUF_NAMESPACE_ID::int32 value);
private:
::PROTOBUF_NAMESPACE_ID::int32 _internal_a() const;
void _internal_set_a(::PROTOBUF_NAMESPACE_ID::int32 value);
public:
// optional int32 b = 4;
bool has_b() const;
private:
bool _internal_has_b() const;
public:
void clear_b();
::PROTOBUF_NAMESPACE_ID::int32 b() const;
void set_b(::PROTOBUF_NAMESPACE_ID::int32 value);
private:
::PROTOBUF_NAMESPACE_ID::int32 _internal_b() const;
void _internal_set_b(::PROTOBUF_NAMESPACE_ID::int32 value);
public:
static const int kTfFieldNumber = 100;
static ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::protobuf_unittest::TestDiffMessage,
::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::protobuf_unittest::TestField >, 11, false >
tf;
// @@protoc_insertion_point(class_scope:protobuf_unittest.TestField)
private:
class _Internal;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 > rc_;
::protobuf_unittest::TestField* m_;
::PROTOBUF_NAMESPACE_ID::int32 c_;
::PROTOBUF_NAMESPACE_ID::int32 a_;
::PROTOBUF_NAMESPACE_ID::int32 b_;
friend struct ::TableStruct_google_2fprotobuf_2futil_2fmessage_5fdifferencer_5funittest_2eproto;
};
// -------------------------------------------------------------------
class TestDiffMessage_Item_MpEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID::internal::MapEntry<TestDiffMessage_Item_MpEntry_DoNotUse,
std::string, ::PROTOBUF_NAMESPACE_ID::int32,
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING,
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32> {
public:
typedef ::PROTOBUF_NAMESPACE_ID::internal::MapEntry<TestDiffMessage_Item_MpEntry_DoNotUse,
std::string, ::PROTOBUF_NAMESPACE_ID::int32,
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING,
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32> SuperType;
TestDiffMessage_Item_MpEntry_DoNotUse();
explicit constexpr TestDiffMessage_Item_MpEntry_DoNotUse(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
explicit TestDiffMessage_Item_MpEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena);
void MergeFrom(const TestDiffMessage_Item_MpEntry_DoNotUse& other);
static const TestDiffMessage_Item_MpEntry_DoNotUse* internal_default_instance() { return reinterpret_cast<const TestDiffMessage_Item_MpEntry_DoNotUse*>(&_TestDiffMessage_Item_MpEntry_DoNotUse_default_instance_); }
static bool ValidateKey(std::string* s) {
#ifndef NDEBUG
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
s->data(), static_cast<int>(s->size()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "protobuf_unittest.TestDiffMessage.Item.MpEntry.key");
#else
(void) s;
#endif
return true;
}
static bool ValidateValue(void*) { return true; }
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
};
// -------------------------------------------------------------------
class TestDiffMessage_Item final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.TestDiffMessage.Item) */ {
public:
inline TestDiffMessage_Item() : TestDiffMessage_Item(nullptr) {}
~TestDiffMessage_Item() override;
explicit constexpr TestDiffMessage_Item(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
TestDiffMessage_Item(const TestDiffMessage_Item& from);
TestDiffMessage_Item(TestDiffMessage_Item&& from) noexcept
: TestDiffMessage_Item() {
*this = ::std::move(from);
}
inline TestDiffMessage_Item& operator=(const TestDiffMessage_Item& from) {
CopyFrom(from);
return *this;
}
inline TestDiffMessage_Item& operator=(TestDiffMessage_Item&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
&& GetOwningArena() != nullptr
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance);
}
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return default_instance().GetMetadata().descriptor;
}
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return default_instance().GetMetadata().reflection;
}
static const TestDiffMessage_Item& default_instance() {
return *internal_default_instance();
}
static inline const TestDiffMessage_Item* internal_default_instance() {
return reinterpret_cast<const TestDiffMessage_Item*>(
&_TestDiffMessage_Item_default_instance_);
}
static constexpr int kIndexInFileMessages =
2;
friend void swap(TestDiffMessage_Item& a, TestDiffMessage_Item& b) {
a.Swap(&b);
}
inline void Swap(TestDiffMessage_Item* other) {
if (other == this) return;
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() != nullptr &&
GetOwningArena() == other->GetOwningArena()) {
#else // PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() == other->GetOwningArena()) {
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(TestDiffMessage_Item* other) {
if (other == this) return;
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline TestDiffMessage_Item* New() const final {
return new TestDiffMessage_Item();
}
TestDiffMessage_Item* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<TestDiffMessage_Item>(arena);
}
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
void CopyFrom(const TestDiffMessage_Item& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
void MergeFrom(const TestDiffMessage_Item& from);
private:
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(TestDiffMessage_Item* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "protobuf_unittest.TestDiffMessage.Item";
}
protected:
explicit TestDiffMessage_Item(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kRaFieldNumber = 3,
kRbFieldNumber = 5,
kRmFieldNumber = 7,
kMpFieldNumber = 8,
kBFieldNumber = 4,
kMFieldNumber = 6,
kAFieldNumber = 2,
};
// repeated int32 ra = 3;
int ra_size() const;
private:
int _internal_ra_size() const;
public:
void clear_ra();
private:
::PROTOBUF_NAMESPACE_ID::int32 _internal_ra(int index) const;
const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
_internal_ra() const;
void _internal_add_ra(::PROTOBUF_NAMESPACE_ID::int32 value);
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
_internal_mutable_ra();
public:
::PROTOBUF_NAMESPACE_ID::int32 ra(int index) const;
void set_ra(int index, ::PROTOBUF_NAMESPACE_ID::int32 value);
void add_ra(::PROTOBUF_NAMESPACE_ID::int32 value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
ra() const;
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
mutable_ra();
// repeated string rb = 5;
int rb_size() const;
private:
int _internal_rb_size() const;
public:
void clear_rb();
const std::string& rb(int index) const;
std::string* mutable_rb(int index);
void set_rb(int index, const std::string& value);
void set_rb(int index, std::string&& value);
void set_rb(int index, const char* value);
void set_rb(int index, const char* value, size_t size);
std::string* add_rb();
void add_rb(const std::string& value);
void add_rb(std::string&& value);
void add_rb(const char* value);
void add_rb(const char* value, size_t size);
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& rb() const;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* mutable_rb();
private:
const std::string& _internal_rb(int index) const;
std::string* _internal_add_rb();
public:
// repeated .protobuf_unittest.TestField rm = 7;
int rm_size() const;
private:
int _internal_rm_size() const;
public:
void clear_rm();
::protobuf_unittest::TestField* mutable_rm(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestField >*
mutable_rm();
private:
const ::protobuf_unittest::TestField& _internal_rm(int index) const;
::protobuf_unittest::TestField* _internal_add_rm();
public:
const ::protobuf_unittest::TestField& rm(int index) const;
::protobuf_unittest::TestField* add_rm();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestField >&
rm() const;
// map<string, int32> mp = 8;
int mp_size() const;
private:
int _internal_mp_size() const;
public:
void clear_mp();
private:
const ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::int32 >&
_internal_mp() const;
::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::int32 >*
_internal_mutable_mp();
public:
const ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::int32 >&
mp() const;
::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::int32 >*
mutable_mp();
// optional string b = 4;
bool has_b() const;
private:
bool _internal_has_b() const;
public:
void clear_b();
const std::string& b() const;
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_b(ArgT0&& arg0, ArgT... args);
std::string* mutable_b();
PROTOBUF_MUST_USE_RESULT std::string* release_b();
void set_allocated_b(std::string* b);
private:
const std::string& _internal_b() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_b(const std::string& value);
std::string* _internal_mutable_b();
public:
// optional .protobuf_unittest.TestField m = 6;
bool has_m() const;
private:
bool _internal_has_m() const;
public:
void clear_m();
const ::protobuf_unittest::TestField& m() const;
PROTOBUF_MUST_USE_RESULT ::protobuf_unittest::TestField* release_m();
::protobuf_unittest::TestField* mutable_m();
void set_allocated_m(::protobuf_unittest::TestField* m);
private:
const ::protobuf_unittest::TestField& _internal_m() const;
::protobuf_unittest::TestField* _internal_mutable_m();
public:
void unsafe_arena_set_allocated_m(
::protobuf_unittest::TestField* m);
::protobuf_unittest::TestField* unsafe_arena_release_m();
// optional int32 a = 2;
bool has_a() const;
private:
bool _internal_has_a() const;
public:
void clear_a();
::PROTOBUF_NAMESPACE_ID::int32 a() const;
void set_a(::PROTOBUF_NAMESPACE_ID::int32 value);
private:
::PROTOBUF_NAMESPACE_ID::int32 _internal_a() const;
void _internal_set_a(::PROTOBUF_NAMESPACE_ID::int32 value);
public:
// @@protoc_insertion_point(class_scope:protobuf_unittest.TestDiffMessage.Item)
private:
class _Internal;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 > ra_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> rb_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestField > rm_;
::PROTOBUF_NAMESPACE_ID::internal::MapField<
TestDiffMessage_Item_MpEntry_DoNotUse,
std::string, ::PROTOBUF_NAMESPACE_ID::int32,
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING,
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_INT32> mp_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr b_;
::protobuf_unittest::TestField* m_;
::PROTOBUF_NAMESPACE_ID::int32 a_;
friend struct ::TableStruct_google_2fprotobuf_2futil_2fmessage_5fdifferencer_5funittest_2eproto;
};
// -------------------------------------------------------------------
class TestDiffMessage final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.TestDiffMessage) */ {
public:
inline TestDiffMessage() : TestDiffMessage(nullptr) {}
~TestDiffMessage() override;
explicit constexpr TestDiffMessage(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
TestDiffMessage(const TestDiffMessage& from);
TestDiffMessage(TestDiffMessage&& from) noexcept
: TestDiffMessage() {
*this = ::std::move(from);
}
inline TestDiffMessage& operator=(const TestDiffMessage& from) {
CopyFrom(from);
return *this;
}
inline TestDiffMessage& operator=(TestDiffMessage&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
&& GetOwningArena() != nullptr
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance);
}
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return default_instance().GetMetadata().descriptor;
}
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return default_instance().GetMetadata().reflection;
}
static const TestDiffMessage& default_instance() {
return *internal_default_instance();
}
static inline const TestDiffMessage* internal_default_instance() {
return reinterpret_cast<const TestDiffMessage*>(
&_TestDiffMessage_default_instance_);
}
static constexpr int kIndexInFileMessages =
3;
friend void swap(TestDiffMessage& a, TestDiffMessage& b) {
a.Swap(&b);
}
inline void Swap(TestDiffMessage* other) {
if (other == this) return;
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() != nullptr &&
GetOwningArena() == other->GetOwningArena()) {
#else // PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() == other->GetOwningArena()) {
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(TestDiffMessage* other) {
if (other == this) return;
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline TestDiffMessage* New() const final {
return new TestDiffMessage();
}
TestDiffMessage* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<TestDiffMessage>(arena);
}
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
void CopyFrom(const TestDiffMessage& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
void MergeFrom(const TestDiffMessage& from);
private:
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(TestDiffMessage* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "protobuf_unittest.TestDiffMessage";
}
protected:
explicit TestDiffMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
// nested types ----------------------------------------------------
typedef TestDiffMessage_Item Item;
// accessors -------------------------------------------------------
enum : int {
kItemFieldNumber = 1,
kRwFieldNumber = 10,
kRvFieldNumber = 11,
kRmFieldNumber = 12,
kRanyFieldNumber = 16,
kWFieldNumber = 14,
kMFieldNumber = 15,
kVFieldNumber = 13,
};
// repeated group Item = 1 { ... };
int item_size() const;
private:
int _internal_item_size() const;
public:
void clear_item();
::protobuf_unittest::TestDiffMessage_Item* mutable_item(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestDiffMessage_Item >*
mutable_item();
private:
const ::protobuf_unittest::TestDiffMessage_Item& _internal_item(int index) const;
::protobuf_unittest::TestDiffMessage_Item* _internal_add_item();
public:
const ::protobuf_unittest::TestDiffMessage_Item& item(int index) const;
::protobuf_unittest::TestDiffMessage_Item* add_item();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestDiffMessage_Item >&
item() const;
// repeated string rw = 10;
int rw_size() const;
private:
int _internal_rw_size() const;
public:
void clear_rw();
const std::string& rw(int index) const;
std::string* mutable_rw(int index);
void set_rw(int index, const std::string& value);
void set_rw(int index, std::string&& value);
void set_rw(int index, const char* value);
void set_rw(int index, const char* value, size_t size);
std::string* add_rw();
void add_rw(const std::string& value);
void add_rw(std::string&& value);
void add_rw(const char* value);
void add_rw(const char* value, size_t size);
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>& rw() const;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>* mutable_rw();
private:
const std::string& _internal_rw(int index) const;
std::string* _internal_add_rw();
public:
// repeated int32 rv = 11;
int rv_size() const;
private:
int _internal_rv_size() const;
public:
void clear_rv();
private:
::PROTOBUF_NAMESPACE_ID::int32 _internal_rv(int index) const;
const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
_internal_rv() const;
void _internal_add_rv(::PROTOBUF_NAMESPACE_ID::int32 value);
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
_internal_mutable_rv();
public:
::PROTOBUF_NAMESPACE_ID::int32 rv(int index) const;
void set_rv(int index, ::PROTOBUF_NAMESPACE_ID::int32 value);
void add_rv(::PROTOBUF_NAMESPACE_ID::int32 value);
const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
rv() const;
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
mutable_rv();
// repeated .protobuf_unittest.TestField rm = 12 [deprecated = true];
PROTOBUF_DEPRECATED int rm_size() const;
private:
int _internal_rm_size() const;
public:
PROTOBUF_DEPRECATED void clear_rm();
PROTOBUF_DEPRECATED ::protobuf_unittest::TestField* mutable_rm(int index);
PROTOBUF_DEPRECATED ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestField >*
mutable_rm();
private:
const ::protobuf_unittest::TestField& _internal_rm(int index) const;
::protobuf_unittest::TestField* _internal_add_rm();
public:
PROTOBUF_DEPRECATED const ::protobuf_unittest::TestField& rm(int index) const;
PROTOBUF_DEPRECATED ::protobuf_unittest::TestField* add_rm();
PROTOBUF_DEPRECATED const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestField >&
rm() const;
// repeated .google.protobuf.Any rany = 16;
int rany_size() const;
private:
int _internal_rany_size() const;
public:
void clear_rany();
::PROTOBUF_NAMESPACE_ID::Any* mutable_rany(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any >*
mutable_rany();
private:
const ::PROTOBUF_NAMESPACE_ID::Any& _internal_rany(int index) const;
::PROTOBUF_NAMESPACE_ID::Any* _internal_add_rany();
public:
const ::PROTOBUF_NAMESPACE_ID::Any& rany(int index) const;
::PROTOBUF_NAMESPACE_ID::Any* add_rany();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any >&
rany() const;
// optional string w = 14;
bool has_w() const;
private:
bool _internal_has_w() const;
public:
void clear_w();
const std::string& w() const;
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_w(ArgT0&& arg0, ArgT... args);
std::string* mutable_w();
PROTOBUF_MUST_USE_RESULT std::string* release_w();
void set_allocated_w(std::string* w);
private:
const std::string& _internal_w() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_w(const std::string& value);
std::string* _internal_mutable_w();
public:
// optional .protobuf_unittest.TestField m = 15;
bool has_m() const;
private:
bool _internal_has_m() const;
public:
void clear_m();
const ::protobuf_unittest::TestField& m() const;
PROTOBUF_MUST_USE_RESULT ::protobuf_unittest::TestField* release_m();
::protobuf_unittest::TestField* mutable_m();
void set_allocated_m(::protobuf_unittest::TestField* m);
private:
const ::protobuf_unittest::TestField& _internal_m() const;
::protobuf_unittest::TestField* _internal_mutable_m();
public:
void unsafe_arena_set_allocated_m(
::protobuf_unittest::TestField* m);
::protobuf_unittest::TestField* unsafe_arena_release_m();
// optional int32 v = 13 [deprecated = true];
PROTOBUF_DEPRECATED bool has_v() const;
private:
bool _internal_has_v() const;
public:
PROTOBUF_DEPRECATED void clear_v();
PROTOBUF_DEPRECATED ::PROTOBUF_NAMESPACE_ID::int32 v() const;
PROTOBUF_DEPRECATED void set_v(::PROTOBUF_NAMESPACE_ID::int32 value);
private:
::PROTOBUF_NAMESPACE_ID::int32 _internal_v() const;
void _internal_set_v(::PROTOBUF_NAMESPACE_ID::int32 value);
public:
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline bool HasExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id) const {
return _extensions_.Has(id.number());
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void ClearExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id) {
_extensions_.ClearExtension(id.number());
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline int ExtensionSize(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id) const {
return _extensions_.ExtensionSize(id.number());
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::ConstType GetExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id) const {
return _proto_TypeTraits::Get(id.number(), _extensions_,
id.default_value());
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id) {
return _proto_TypeTraits::Mutable(id.number(), _field_type,
&_extensions_);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::ConstType value) {
_proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetAllocatedExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value,
&_extensions_);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void UnsafeArenaSetAllocatedExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Singular::MutableType value) {
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,
value, &_extensions_);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline PROTOBUF_MUST_USE_RESULT
typename _proto_TypeTraits::Singular::MutableType
ReleaseExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id) {
return _proto_TypeTraits::Release(id.number(), _field_type,
&_extensions_);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Singular::MutableType
UnsafeArenaReleaseExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id) {
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,
&_extensions_);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id,
int index) const {
return _proto_TypeTraits::Get(id.number(), _extensions_, index);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id,
int index) {
return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void SetExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id,
int index, typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Set(id.number(), index, value, &_extensions_);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id) {
typename _proto_TypeTraits::Repeated::MutableType to_add =
_proto_TypeTraits::Add(id.number(), _field_type, &_extensions_);
return to_add;
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline void AddExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id,
typename _proto_TypeTraits::Repeated::ConstType value) {
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value,
&_extensions_);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&
GetRepeatedExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id) const {
return _proto_TypeTraits::GetRepeated(id.number(), _extensions_);
}
template <typename _proto_TypeTraits,
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type,
bool _is_packed>
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*
MutableRepeatedExtension(
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier<
TestDiffMessage, _proto_TypeTraits, _field_type, _is_packed>& id) {
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,
_is_packed, &_extensions_);
}
// @@protoc_insertion_point(class_scope:protobuf_unittest.TestDiffMessage)
private:
class _Internal;
::PROTOBUF_NAMESPACE_ID::internal::ExtensionSet _extensions_;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestDiffMessage_Item > item_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string> rw_;
::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 > rv_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestField > rm_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any > rany_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr w_;
::protobuf_unittest::TestField* m_;
::PROTOBUF_NAMESPACE_ID::int32 v_;
friend struct ::TableStruct_google_2fprotobuf_2futil_2fmessage_5fdifferencer_5funittest_2eproto;
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// TestField
// optional int32 a = 3;
inline bool TestField::_internal_has_a() const {
bool value = (_has_bits_[0] & 0x00000004u) != 0;
return value;
}
inline bool TestField::has_a() const {
return _internal_has_a();
}
inline void TestField::clear_a() {
a_ = 0;
_has_bits_[0] &= ~0x00000004u;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestField::_internal_a() const {
return a_;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestField::a() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestField.a)
return _internal_a();
}
inline void TestField::_internal_set_a(::PROTOBUF_NAMESPACE_ID::int32 value) {
_has_bits_[0] |= 0x00000004u;
a_ = value;
}
inline void TestField::set_a(::PROTOBUF_NAMESPACE_ID::int32 value) {
_internal_set_a(value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestField.a)
}
// optional int32 b = 4;
inline bool TestField::_internal_has_b() const {
bool value = (_has_bits_[0] & 0x00000008u) != 0;
return value;
}
inline bool TestField::has_b() const {
return _internal_has_b();
}
inline void TestField::clear_b() {
b_ = 0;
_has_bits_[0] &= ~0x00000008u;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestField::_internal_b() const {
return b_;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestField::b() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestField.b)
return _internal_b();
}
inline void TestField::_internal_set_b(::PROTOBUF_NAMESPACE_ID::int32 value) {
_has_bits_[0] |= 0x00000008u;
b_ = value;
}
inline void TestField::set_b(::PROTOBUF_NAMESPACE_ID::int32 value) {
_internal_set_b(value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestField.b)
}
// optional int32 c = 1;
inline bool TestField::_internal_has_c() const {
bool value = (_has_bits_[0] & 0x00000002u) != 0;
return value;
}
inline bool TestField::has_c() const {
return _internal_has_c();
}
inline void TestField::clear_c() {
c_ = 0;
_has_bits_[0] &= ~0x00000002u;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestField::_internal_c() const {
return c_;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestField::c() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestField.c)
return _internal_c();
}
inline void TestField::_internal_set_c(::PROTOBUF_NAMESPACE_ID::int32 value) {
_has_bits_[0] |= 0x00000002u;
c_ = value;
}
inline void TestField::set_c(::PROTOBUF_NAMESPACE_ID::int32 value) {
_internal_set_c(value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestField.c)
}
// repeated int32 rc = 2;
inline int TestField::_internal_rc_size() const {
return rc_.size();
}
inline int TestField::rc_size() const {
return _internal_rc_size();
}
inline void TestField::clear_rc() {
rc_.Clear();
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestField::_internal_rc(int index) const {
return rc_.Get(index);
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestField::rc(int index) const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestField.rc)
return _internal_rc(index);
}
inline void TestField::set_rc(int index, ::PROTOBUF_NAMESPACE_ID::int32 value) {
rc_.Set(index, value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestField.rc)
}
inline void TestField::_internal_add_rc(::PROTOBUF_NAMESPACE_ID::int32 value) {
rc_.Add(value);
}
inline void TestField::add_rc(::PROTOBUF_NAMESPACE_ID::int32 value) {
_internal_add_rc(value);
// @@protoc_insertion_point(field_add:protobuf_unittest.TestField.rc)
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
TestField::_internal_rc() const {
return rc_;
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
TestField::rc() const {
// @@protoc_insertion_point(field_list:protobuf_unittest.TestField.rc)
return _internal_rc();
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
TestField::_internal_mutable_rc() {
return &rc_;
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
TestField::mutable_rc() {
// @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestField.rc)
return _internal_mutable_rc();
}
// optional .protobuf_unittest.TestField m = 5;
inline bool TestField::_internal_has_m() const {
bool value = (_has_bits_[0] & 0x00000001u) != 0;
PROTOBUF_ASSUME(!value || m_ != nullptr);
return value;
}
inline bool TestField::has_m() const {
return _internal_has_m();
}
inline void TestField::clear_m() {
if (m_ != nullptr) m_->Clear();
_has_bits_[0] &= ~0x00000001u;
}
inline const ::protobuf_unittest::TestField& TestField::_internal_m() const {
const ::protobuf_unittest::TestField* p = m_;
return p != nullptr ? *p : reinterpret_cast<const ::protobuf_unittest::TestField&>(
::protobuf_unittest::_TestField_default_instance_);
}
inline const ::protobuf_unittest::TestField& TestField::m() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestField.m)
return _internal_m();
}
inline void TestField::unsafe_arena_set_allocated_m(
::protobuf_unittest::TestField* m) {
if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(m_);
}
m_ = m;
if (m) {
_has_bits_[0] |= 0x00000001u;
} else {
_has_bits_[0] &= ~0x00000001u;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:protobuf_unittest.TestField.m)
}
inline ::protobuf_unittest::TestField* TestField::release_m() {
_has_bits_[0] &= ~0x00000001u;
::protobuf_unittest::TestField* temp = m_;
m_ = nullptr;
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp);
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
if (GetArenaForAllocation() == nullptr) { delete old; }
#else // PROTOBUF_FORCE_COPY_IN_RELEASE
if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
}
#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
return temp;
}
inline ::protobuf_unittest::TestField* TestField::unsafe_arena_release_m() {
// @@protoc_insertion_point(field_release:protobuf_unittest.TestField.m)
_has_bits_[0] &= ~0x00000001u;
::protobuf_unittest::TestField* temp = m_;
m_ = nullptr;
return temp;
}
inline ::protobuf_unittest::TestField* TestField::_internal_mutable_m() {
_has_bits_[0] |= 0x00000001u;
if (m_ == nullptr) {
auto* p = CreateMaybeMessage<::protobuf_unittest::TestField>(GetArenaForAllocation());
m_ = p;
}
return m_;
}
inline ::protobuf_unittest::TestField* TestField::mutable_m() {
::protobuf_unittest::TestField* _msg = _internal_mutable_m();
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestField.m)
return _msg;
}
inline void TestField::set_allocated_m(::protobuf_unittest::TestField* m) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
if (message_arena == nullptr) {
delete m_;
}
if (m) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::protobuf_unittest::TestField>::GetOwningArena(m);
if (message_arena != submessage_arena) {
m = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, m, submessage_arena);
}
_has_bits_[0] |= 0x00000001u;
} else {
_has_bits_[0] &= ~0x00000001u;
}
m_ = m;
// @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestField.m)
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// TestDiffMessage_Item
// optional int32 a = 2;
inline bool TestDiffMessage_Item::_internal_has_a() const {
bool value = (_has_bits_[0] & 0x00000004u) != 0;
return value;
}
inline bool TestDiffMessage_Item::has_a() const {
return _internal_has_a();
}
inline void TestDiffMessage_Item::clear_a() {
a_ = 0;
_has_bits_[0] &= ~0x00000004u;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestDiffMessage_Item::_internal_a() const {
return a_;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestDiffMessage_Item::a() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.Item.a)
return _internal_a();
}
inline void TestDiffMessage_Item::_internal_set_a(::PROTOBUF_NAMESPACE_ID::int32 value) {
_has_bits_[0] |= 0x00000004u;
a_ = value;
}
inline void TestDiffMessage_Item::set_a(::PROTOBUF_NAMESPACE_ID::int32 value) {
_internal_set_a(value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestDiffMessage.Item.a)
}
// optional string b = 4;
inline bool TestDiffMessage_Item::_internal_has_b() const {
bool value = (_has_bits_[0] & 0x00000001u) != 0;
return value;
}
inline bool TestDiffMessage_Item::has_b() const {
return _internal_has_b();
}
inline void TestDiffMessage_Item::clear_b() {
b_.ClearToEmpty();
_has_bits_[0] &= ~0x00000001u;
}
inline const std::string& TestDiffMessage_Item::b() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.Item.b)
return _internal_b();
}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void TestDiffMessage_Item::set_b(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
b_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:protobuf_unittest.TestDiffMessage.Item.b)
}
inline std::string* TestDiffMessage_Item::mutable_b() {
std::string* _s = _internal_mutable_b();
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestDiffMessage.Item.b)
return _s;
}
inline const std::string& TestDiffMessage_Item::_internal_b() const {
return b_.Get();
}
inline void TestDiffMessage_Item::_internal_set_b(const std::string& value) {
_has_bits_[0] |= 0x00000001u;
b_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* TestDiffMessage_Item::_internal_mutable_b() {
_has_bits_[0] |= 0x00000001u;
return b_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* TestDiffMessage_Item::release_b() {
// @@protoc_insertion_point(field_release:protobuf_unittest.TestDiffMessage.Item.b)
if (!_internal_has_b()) {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
return b_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
}
inline void TestDiffMessage_Item::set_allocated_b(std::string* b) {
if (b != nullptr) {
_has_bits_[0] |= 0x00000001u;
} else {
_has_bits_[0] &= ~0x00000001u;
}
b_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), b,
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestDiffMessage.Item.b)
}
// repeated int32 ra = 3;
inline int TestDiffMessage_Item::_internal_ra_size() const {
return ra_.size();
}
inline int TestDiffMessage_Item::ra_size() const {
return _internal_ra_size();
}
inline void TestDiffMessage_Item::clear_ra() {
ra_.Clear();
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestDiffMessage_Item::_internal_ra(int index) const {
return ra_.Get(index);
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestDiffMessage_Item::ra(int index) const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.Item.ra)
return _internal_ra(index);
}
inline void TestDiffMessage_Item::set_ra(int index, ::PROTOBUF_NAMESPACE_ID::int32 value) {
ra_.Set(index, value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestDiffMessage.Item.ra)
}
inline void TestDiffMessage_Item::_internal_add_ra(::PROTOBUF_NAMESPACE_ID::int32 value) {
ra_.Add(value);
}
inline void TestDiffMessage_Item::add_ra(::PROTOBUF_NAMESPACE_ID::int32 value) {
_internal_add_ra(value);
// @@protoc_insertion_point(field_add:protobuf_unittest.TestDiffMessage.Item.ra)
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
TestDiffMessage_Item::_internal_ra() const {
return ra_;
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
TestDiffMessage_Item::ra() const {
// @@protoc_insertion_point(field_list:protobuf_unittest.TestDiffMessage.Item.ra)
return _internal_ra();
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
TestDiffMessage_Item::_internal_mutable_ra() {
return &ra_;
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
TestDiffMessage_Item::mutable_ra() {
// @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestDiffMessage.Item.ra)
return _internal_mutable_ra();
}
// repeated string rb = 5;
inline int TestDiffMessage_Item::_internal_rb_size() const {
return rb_.size();
}
inline int TestDiffMessage_Item::rb_size() const {
return _internal_rb_size();
}
inline void TestDiffMessage_Item::clear_rb() {
rb_.Clear();
}
inline std::string* TestDiffMessage_Item::add_rb() {
std::string* _s = _internal_add_rb();
// @@protoc_insertion_point(field_add_mutable:protobuf_unittest.TestDiffMessage.Item.rb)
return _s;
}
inline const std::string& TestDiffMessage_Item::_internal_rb(int index) const {
return rb_.Get(index);
}
inline const std::string& TestDiffMessage_Item::rb(int index) const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.Item.rb)
return _internal_rb(index);
}
inline std::string* TestDiffMessage_Item::mutable_rb(int index) {
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestDiffMessage.Item.rb)
return rb_.Mutable(index);
}
inline void TestDiffMessage_Item::set_rb(int index, const std::string& value) {
rb_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestDiffMessage.Item.rb)
}
inline void TestDiffMessage_Item::set_rb(int index, std::string&& value) {
rb_.Mutable(index)->assign(std::move(value));
// @@protoc_insertion_point(field_set:protobuf_unittest.TestDiffMessage.Item.rb)
}
inline void TestDiffMessage_Item::set_rb(int index, const char* value) {
GOOGLE_DCHECK(value != nullptr);
rb_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:protobuf_unittest.TestDiffMessage.Item.rb)
}
inline void TestDiffMessage_Item::set_rb(int index, const char* value, size_t size) {
rb_.Mutable(index)->assign(
reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:protobuf_unittest.TestDiffMessage.Item.rb)
}
inline std::string* TestDiffMessage_Item::_internal_add_rb() {
return rb_.Add();
}
inline void TestDiffMessage_Item::add_rb(const std::string& value) {
rb_.Add()->assign(value);
// @@protoc_insertion_point(field_add:protobuf_unittest.TestDiffMessage.Item.rb)
}
inline void TestDiffMessage_Item::add_rb(std::string&& value) {
rb_.Add(std::move(value));
// @@protoc_insertion_point(field_add:protobuf_unittest.TestDiffMessage.Item.rb)
}
inline void TestDiffMessage_Item::add_rb(const char* value) {
GOOGLE_DCHECK(value != nullptr);
rb_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:protobuf_unittest.TestDiffMessage.Item.rb)
}
inline void TestDiffMessage_Item::add_rb(const char* value, size_t size) {
rb_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:protobuf_unittest.TestDiffMessage.Item.rb)
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>&
TestDiffMessage_Item::rb() const {
// @@protoc_insertion_point(field_list:protobuf_unittest.TestDiffMessage.Item.rb)
return rb_;
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>*
TestDiffMessage_Item::mutable_rb() {
// @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestDiffMessage.Item.rb)
return &rb_;
}
// optional .protobuf_unittest.TestField m = 6;
inline bool TestDiffMessage_Item::_internal_has_m() const {
bool value = (_has_bits_[0] & 0x00000002u) != 0;
PROTOBUF_ASSUME(!value || m_ != nullptr);
return value;
}
inline bool TestDiffMessage_Item::has_m() const {
return _internal_has_m();
}
inline void TestDiffMessage_Item::clear_m() {
if (m_ != nullptr) m_->Clear();
_has_bits_[0] &= ~0x00000002u;
}
inline const ::protobuf_unittest::TestField& TestDiffMessage_Item::_internal_m() const {
const ::protobuf_unittest::TestField* p = m_;
return p != nullptr ? *p : reinterpret_cast<const ::protobuf_unittest::TestField&>(
::protobuf_unittest::_TestField_default_instance_);
}
inline const ::protobuf_unittest::TestField& TestDiffMessage_Item::m() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.Item.m)
return _internal_m();
}
inline void TestDiffMessage_Item::unsafe_arena_set_allocated_m(
::protobuf_unittest::TestField* m) {
if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(m_);
}
m_ = m;
if (m) {
_has_bits_[0] |= 0x00000002u;
} else {
_has_bits_[0] &= ~0x00000002u;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:protobuf_unittest.TestDiffMessage.Item.m)
}
inline ::protobuf_unittest::TestField* TestDiffMessage_Item::release_m() {
_has_bits_[0] &= ~0x00000002u;
::protobuf_unittest::TestField* temp = m_;
m_ = nullptr;
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp);
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
if (GetArenaForAllocation() == nullptr) { delete old; }
#else // PROTOBUF_FORCE_COPY_IN_RELEASE
if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
}
#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
return temp;
}
inline ::protobuf_unittest::TestField* TestDiffMessage_Item::unsafe_arena_release_m() {
// @@protoc_insertion_point(field_release:protobuf_unittest.TestDiffMessage.Item.m)
_has_bits_[0] &= ~0x00000002u;
::protobuf_unittest::TestField* temp = m_;
m_ = nullptr;
return temp;
}
inline ::protobuf_unittest::TestField* TestDiffMessage_Item::_internal_mutable_m() {
_has_bits_[0] |= 0x00000002u;
if (m_ == nullptr) {
auto* p = CreateMaybeMessage<::protobuf_unittest::TestField>(GetArenaForAllocation());
m_ = p;
}
return m_;
}
inline ::protobuf_unittest::TestField* TestDiffMessage_Item::mutable_m() {
::protobuf_unittest::TestField* _msg = _internal_mutable_m();
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestDiffMessage.Item.m)
return _msg;
}
inline void TestDiffMessage_Item::set_allocated_m(::protobuf_unittest::TestField* m) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
if (message_arena == nullptr) {
delete m_;
}
if (m) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::protobuf_unittest::TestField>::GetOwningArena(m);
if (message_arena != submessage_arena) {
m = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, m, submessage_arena);
}
_has_bits_[0] |= 0x00000002u;
} else {
_has_bits_[0] &= ~0x00000002u;
}
m_ = m;
// @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestDiffMessage.Item.m)
}
// repeated .protobuf_unittest.TestField rm = 7;
inline int TestDiffMessage_Item::_internal_rm_size() const {
return rm_.size();
}
inline int TestDiffMessage_Item::rm_size() const {
return _internal_rm_size();
}
inline void TestDiffMessage_Item::clear_rm() {
rm_.Clear();
}
inline ::protobuf_unittest::TestField* TestDiffMessage_Item::mutable_rm(int index) {
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestDiffMessage.Item.rm)
return rm_.Mutable(index);
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestField >*
TestDiffMessage_Item::mutable_rm() {
// @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestDiffMessage.Item.rm)
return &rm_;
}
inline const ::protobuf_unittest::TestField& TestDiffMessage_Item::_internal_rm(int index) const {
return rm_.Get(index);
}
inline const ::protobuf_unittest::TestField& TestDiffMessage_Item::rm(int index) const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.Item.rm)
return _internal_rm(index);
}
inline ::protobuf_unittest::TestField* TestDiffMessage_Item::_internal_add_rm() {
return rm_.Add();
}
inline ::protobuf_unittest::TestField* TestDiffMessage_Item::add_rm() {
::protobuf_unittest::TestField* _add = _internal_add_rm();
// @@protoc_insertion_point(field_add:protobuf_unittest.TestDiffMessage.Item.rm)
return _add;
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestField >&
TestDiffMessage_Item::rm() const {
// @@protoc_insertion_point(field_list:protobuf_unittest.TestDiffMessage.Item.rm)
return rm_;
}
// map<string, int32> mp = 8;
inline int TestDiffMessage_Item::_internal_mp_size() const {
return mp_.size();
}
inline int TestDiffMessage_Item::mp_size() const {
return _internal_mp_size();
}
inline void TestDiffMessage_Item::clear_mp() {
mp_.Clear();
}
inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::int32 >&
TestDiffMessage_Item::_internal_mp() const {
return mp_.GetMap();
}
inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::int32 >&
TestDiffMessage_Item::mp() const {
// @@protoc_insertion_point(field_map:protobuf_unittest.TestDiffMessage.Item.mp)
return _internal_mp();
}
inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::int32 >*
TestDiffMessage_Item::_internal_mutable_mp() {
return mp_.MutableMap();
}
inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::int32 >*
TestDiffMessage_Item::mutable_mp() {
// @@protoc_insertion_point(field_mutable_map:protobuf_unittest.TestDiffMessage.Item.mp)
return _internal_mutable_mp();
}
// -------------------------------------------------------------------
// TestDiffMessage
// repeated group Item = 1 { ... };
inline int TestDiffMessage::_internal_item_size() const {
return item_.size();
}
inline int TestDiffMessage::item_size() const {
return _internal_item_size();
}
inline void TestDiffMessage::clear_item() {
item_.Clear();
}
inline ::protobuf_unittest::TestDiffMessage_Item* TestDiffMessage::mutable_item(int index) {
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestDiffMessage.item)
return item_.Mutable(index);
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestDiffMessage_Item >*
TestDiffMessage::mutable_item() {
// @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestDiffMessage.item)
return &item_;
}
inline const ::protobuf_unittest::TestDiffMessage_Item& TestDiffMessage::_internal_item(int index) const {
return item_.Get(index);
}
inline const ::protobuf_unittest::TestDiffMessage_Item& TestDiffMessage::item(int index) const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.item)
return _internal_item(index);
}
inline ::protobuf_unittest::TestDiffMessage_Item* TestDiffMessage::_internal_add_item() {
return item_.Add();
}
inline ::protobuf_unittest::TestDiffMessage_Item* TestDiffMessage::add_item() {
::protobuf_unittest::TestDiffMessage_Item* _add = _internal_add_item();
// @@protoc_insertion_point(field_add:protobuf_unittest.TestDiffMessage.item)
return _add;
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestDiffMessage_Item >&
TestDiffMessage::item() const {
// @@protoc_insertion_point(field_list:protobuf_unittest.TestDiffMessage.item)
return item_;
}
// optional int32 v = 13 [deprecated = true];
inline bool TestDiffMessage::_internal_has_v() const {
bool value = (_has_bits_[0] & 0x00000004u) != 0;
return value;
}
inline bool TestDiffMessage::has_v() const {
return _internal_has_v();
}
inline void TestDiffMessage::clear_v() {
v_ = 0;
_has_bits_[0] &= ~0x00000004u;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestDiffMessage::_internal_v() const {
return v_;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestDiffMessage::v() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.v)
return _internal_v();
}
inline void TestDiffMessage::_internal_set_v(::PROTOBUF_NAMESPACE_ID::int32 value) {
_has_bits_[0] |= 0x00000004u;
v_ = value;
}
inline void TestDiffMessage::set_v(::PROTOBUF_NAMESPACE_ID::int32 value) {
_internal_set_v(value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestDiffMessage.v)
}
// optional string w = 14;
inline bool TestDiffMessage::_internal_has_w() const {
bool value = (_has_bits_[0] & 0x00000001u) != 0;
return value;
}
inline bool TestDiffMessage::has_w() const {
return _internal_has_w();
}
inline void TestDiffMessage::clear_w() {
w_.ClearToEmpty();
_has_bits_[0] &= ~0x00000001u;
}
inline const std::string& TestDiffMessage::w() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.w)
return _internal_w();
}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void TestDiffMessage::set_w(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
w_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:protobuf_unittest.TestDiffMessage.w)
}
inline std::string* TestDiffMessage::mutable_w() {
std::string* _s = _internal_mutable_w();
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestDiffMessage.w)
return _s;
}
inline const std::string& TestDiffMessage::_internal_w() const {
return w_.Get();
}
inline void TestDiffMessage::_internal_set_w(const std::string& value) {
_has_bits_[0] |= 0x00000001u;
w_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* TestDiffMessage::_internal_mutable_w() {
_has_bits_[0] |= 0x00000001u;
return w_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* TestDiffMessage::release_w() {
// @@protoc_insertion_point(field_release:protobuf_unittest.TestDiffMessage.w)
if (!_internal_has_w()) {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
return w_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
}
inline void TestDiffMessage::set_allocated_w(std::string* w) {
if (w != nullptr) {
_has_bits_[0] |= 0x00000001u;
} else {
_has_bits_[0] &= ~0x00000001u;
}
w_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), w,
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestDiffMessage.w)
}
// optional .protobuf_unittest.TestField m = 15;
inline bool TestDiffMessage::_internal_has_m() const {
bool value = (_has_bits_[0] & 0x00000002u) != 0;
PROTOBUF_ASSUME(!value || m_ != nullptr);
return value;
}
inline bool TestDiffMessage::has_m() const {
return _internal_has_m();
}
inline void TestDiffMessage::clear_m() {
if (m_ != nullptr) m_->Clear();
_has_bits_[0] &= ~0x00000002u;
}
inline const ::protobuf_unittest::TestField& TestDiffMessage::_internal_m() const {
const ::protobuf_unittest::TestField* p = m_;
return p != nullptr ? *p : reinterpret_cast<const ::protobuf_unittest::TestField&>(
::protobuf_unittest::_TestField_default_instance_);
}
inline const ::protobuf_unittest::TestField& TestDiffMessage::m() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.m)
return _internal_m();
}
inline void TestDiffMessage::unsafe_arena_set_allocated_m(
::protobuf_unittest::TestField* m) {
if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(m_);
}
m_ = m;
if (m) {
_has_bits_[0] |= 0x00000002u;
} else {
_has_bits_[0] &= ~0x00000002u;
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:protobuf_unittest.TestDiffMessage.m)
}
inline ::protobuf_unittest::TestField* TestDiffMessage::release_m() {
_has_bits_[0] &= ~0x00000002u;
::protobuf_unittest::TestField* temp = m_;
m_ = nullptr;
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp);
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
if (GetArenaForAllocation() == nullptr) { delete old; }
#else // PROTOBUF_FORCE_COPY_IN_RELEASE
if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
}
#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
return temp;
}
inline ::protobuf_unittest::TestField* TestDiffMessage::unsafe_arena_release_m() {
// @@protoc_insertion_point(field_release:protobuf_unittest.TestDiffMessage.m)
_has_bits_[0] &= ~0x00000002u;
::protobuf_unittest::TestField* temp = m_;
m_ = nullptr;
return temp;
}
inline ::protobuf_unittest::TestField* TestDiffMessage::_internal_mutable_m() {
_has_bits_[0] |= 0x00000002u;
if (m_ == nullptr) {
auto* p = CreateMaybeMessage<::protobuf_unittest::TestField>(GetArenaForAllocation());
m_ = p;
}
return m_;
}
inline ::protobuf_unittest::TestField* TestDiffMessage::mutable_m() {
::protobuf_unittest::TestField* _msg = _internal_mutable_m();
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestDiffMessage.m)
return _msg;
}
inline void TestDiffMessage::set_allocated_m(::protobuf_unittest::TestField* m) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
if (message_arena == nullptr) {
delete m_;
}
if (m) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<::protobuf_unittest::TestField>::GetOwningArena(m);
if (message_arena != submessage_arena) {
m = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, m, submessage_arena);
}
_has_bits_[0] |= 0x00000002u;
} else {
_has_bits_[0] &= ~0x00000002u;
}
m_ = m;
// @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestDiffMessage.m)
}
// repeated int32 rv = 11;
inline int TestDiffMessage::_internal_rv_size() const {
return rv_.size();
}
inline int TestDiffMessage::rv_size() const {
return _internal_rv_size();
}
inline void TestDiffMessage::clear_rv() {
rv_.Clear();
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestDiffMessage::_internal_rv(int index) const {
return rv_.Get(index);
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestDiffMessage::rv(int index) const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.rv)
return _internal_rv(index);
}
inline void TestDiffMessage::set_rv(int index, ::PROTOBUF_NAMESPACE_ID::int32 value) {
rv_.Set(index, value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestDiffMessage.rv)
}
inline void TestDiffMessage::_internal_add_rv(::PROTOBUF_NAMESPACE_ID::int32 value) {
rv_.Add(value);
}
inline void TestDiffMessage::add_rv(::PROTOBUF_NAMESPACE_ID::int32 value) {
_internal_add_rv(value);
// @@protoc_insertion_point(field_add:protobuf_unittest.TestDiffMessage.rv)
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
TestDiffMessage::_internal_rv() const {
return rv_;
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >&
TestDiffMessage::rv() const {
// @@protoc_insertion_point(field_list:protobuf_unittest.TestDiffMessage.rv)
return _internal_rv();
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
TestDiffMessage::_internal_mutable_rv() {
return &rv_;
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedField< ::PROTOBUF_NAMESPACE_ID::int32 >*
TestDiffMessage::mutable_rv() {
// @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestDiffMessage.rv)
return _internal_mutable_rv();
}
// repeated string rw = 10;
inline int TestDiffMessage::_internal_rw_size() const {
return rw_.size();
}
inline int TestDiffMessage::rw_size() const {
return _internal_rw_size();
}
inline void TestDiffMessage::clear_rw() {
rw_.Clear();
}
inline std::string* TestDiffMessage::add_rw() {
std::string* _s = _internal_add_rw();
// @@protoc_insertion_point(field_add_mutable:protobuf_unittest.TestDiffMessage.rw)
return _s;
}
inline const std::string& TestDiffMessage::_internal_rw(int index) const {
return rw_.Get(index);
}
inline const std::string& TestDiffMessage::rw(int index) const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.rw)
return _internal_rw(index);
}
inline std::string* TestDiffMessage::mutable_rw(int index) {
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestDiffMessage.rw)
return rw_.Mutable(index);
}
inline void TestDiffMessage::set_rw(int index, const std::string& value) {
rw_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestDiffMessage.rw)
}
inline void TestDiffMessage::set_rw(int index, std::string&& value) {
rw_.Mutable(index)->assign(std::move(value));
// @@protoc_insertion_point(field_set:protobuf_unittest.TestDiffMessage.rw)
}
inline void TestDiffMessage::set_rw(int index, const char* value) {
GOOGLE_DCHECK(value != nullptr);
rw_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:protobuf_unittest.TestDiffMessage.rw)
}
inline void TestDiffMessage::set_rw(int index, const char* value, size_t size) {
rw_.Mutable(index)->assign(
reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:protobuf_unittest.TestDiffMessage.rw)
}
inline std::string* TestDiffMessage::_internal_add_rw() {
return rw_.Add();
}
inline void TestDiffMessage::add_rw(const std::string& value) {
rw_.Add()->assign(value);
// @@protoc_insertion_point(field_add:protobuf_unittest.TestDiffMessage.rw)
}
inline void TestDiffMessage::add_rw(std::string&& value) {
rw_.Add(std::move(value));
// @@protoc_insertion_point(field_add:protobuf_unittest.TestDiffMessage.rw)
}
inline void TestDiffMessage::add_rw(const char* value) {
GOOGLE_DCHECK(value != nullptr);
rw_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:protobuf_unittest.TestDiffMessage.rw)
}
inline void TestDiffMessage::add_rw(const char* value, size_t size) {
rw_.Add()->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_add_pointer:protobuf_unittest.TestDiffMessage.rw)
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>&
TestDiffMessage::rw() const {
// @@protoc_insertion_point(field_list:protobuf_unittest.TestDiffMessage.rw)
return rw_;
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<std::string>*
TestDiffMessage::mutable_rw() {
// @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestDiffMessage.rw)
return &rw_;
}
// repeated .protobuf_unittest.TestField rm = 12 [deprecated = true];
inline int TestDiffMessage::_internal_rm_size() const {
return rm_.size();
}
inline int TestDiffMessage::rm_size() const {
return _internal_rm_size();
}
inline void TestDiffMessage::clear_rm() {
rm_.Clear();
}
inline ::protobuf_unittest::TestField* TestDiffMessage::mutable_rm(int index) {
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestDiffMessage.rm)
return rm_.Mutable(index);
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestField >*
TestDiffMessage::mutable_rm() {
// @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestDiffMessage.rm)
return &rm_;
}
inline const ::protobuf_unittest::TestField& TestDiffMessage::_internal_rm(int index) const {
return rm_.Get(index);
}
inline const ::protobuf_unittest::TestField& TestDiffMessage::rm(int index) const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.rm)
return _internal_rm(index);
}
inline ::protobuf_unittest::TestField* TestDiffMessage::_internal_add_rm() {
return rm_.Add();
}
inline ::protobuf_unittest::TestField* TestDiffMessage::add_rm() {
::protobuf_unittest::TestField* _add = _internal_add_rm();
// @@protoc_insertion_point(field_add:protobuf_unittest.TestDiffMessage.rm)
return _add;
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::protobuf_unittest::TestField >&
TestDiffMessage::rm() const {
// @@protoc_insertion_point(field_list:protobuf_unittest.TestDiffMessage.rm)
return rm_;
}
// repeated .google.protobuf.Any rany = 16;
inline int TestDiffMessage::_internal_rany_size() const {
return rany_.size();
}
inline int TestDiffMessage::rany_size() const {
return _internal_rany_size();
}
inline ::PROTOBUF_NAMESPACE_ID::Any* TestDiffMessage::mutable_rany(int index) {
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestDiffMessage.rany)
return rany_.Mutable(index);
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any >*
TestDiffMessage::mutable_rany() {
// @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestDiffMessage.rany)
return &rany_;
}
inline const ::PROTOBUF_NAMESPACE_ID::Any& TestDiffMessage::_internal_rany(int index) const {
return rany_.Get(index);
}
inline const ::PROTOBUF_NAMESPACE_ID::Any& TestDiffMessage::rany(int index) const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestDiffMessage.rany)
return _internal_rany(index);
}
inline ::PROTOBUF_NAMESPACE_ID::Any* TestDiffMessage::_internal_add_rany() {
return rany_.Add();
}
inline ::PROTOBUF_NAMESPACE_ID::Any* TestDiffMessage::add_rany() {
::PROTOBUF_NAMESPACE_ID::Any* _add = _internal_add_rany();
// @@protoc_insertion_point(field_add:protobuf_unittest.TestDiffMessage.rany)
return _add;
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any >&
TestDiffMessage::rany() const {
// @@protoc_insertion_point(field_list:protobuf_unittest.TestDiffMessage.rany)
return rany_;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf_unittest
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2futil_2fmessage_5fdifferencer_5funittest_2eproto
| 38.4199 | 215 | 0.74011 | [
"object"
] |
b12b14c5fcafdc34389c88780b75cc34de75bc2d | 3,353 | h | C | power_manager/powerd/system/display/display_watcher.h | doitmovin/chromiumos-platform2 | 6462aaf43072307b5a40eb045a89e473381b5fda | [
"BSD-3-Clause"
] | null | null | null | power_manager/powerd/system/display/display_watcher.h | doitmovin/chromiumos-platform2 | 6462aaf43072307b5a40eb045a89e473381b5fda | [
"BSD-3-Clause"
] | null | null | null | power_manager/powerd/system/display/display_watcher.h | doitmovin/chromiumos-platform2 | 6462aaf43072307b5a40eb045a89e473381b5fda | [
"BSD-3-Clause"
] | 2 | 2021-01-26T12:37:19.000Z | 2021-05-18T13:37:57.000Z | // Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef POWER_MANAGER_POWERD_SYSTEM_DISPLAY_DISPLAY_WATCHER_H_
#define POWER_MANAGER_POWERD_SYSTEM_DISPLAY_DISPLAY_WATCHER_H_
#include <string>
#include <vector>
#include <base/compiler_specific.h>
#include <base/files/file_path.h>
#include <base/macros.h>
#include <base/observer_list.h>
#include "power_manager/powerd/system/display/display_info.h"
#include "power_manager/powerd/system/display/display_watcher_observer.h"
#include "power_manager/powerd/system/udev_subsystem_observer.h"
namespace power_manager {
namespace system {
class UdevInterface;
// Watches for displays being connected or disconnected.
class DisplayWatcherInterface {
public:
virtual ~DisplayWatcherInterface() {}
// Returns the current list of connected displays.
virtual const std::vector<DisplayInfo>& GetDisplays() const = 0;
// Adds or removes an observer.
virtual void AddObserver(DisplayWatcherObserver* observer) = 0;
virtual void RemoveObserver(DisplayWatcherObserver* observer) = 0;
};
// Real implementation of DisplayWatcherInterface that reports devices from
// /sys.
class DisplayWatcher : public DisplayWatcherInterface,
public UdevSubsystemObserver {
public:
// Udev subsystems used for display-related changes.
static const char kI2CUdevSubsystem[];
static const char kDrmUdevSubsystem[];
// Filename within a DRM device directory containing the device's hotplug
// status.
static const char kDrmStatusFile[];
// Value in |kDrmStatusFile| indicating that the device is connected.
static const char kDrmStatusConnected[];
DisplayWatcher();
virtual ~DisplayWatcher();
void set_sysfs_drm_path_for_testing(const base::FilePath& path) {
sysfs_drm_path_for_testing_ = path;
}
void set_i2c_dev_path_for_testing(const base::FilePath& path) {
i2c_dev_path_for_testing_ = path;
}
// Ownership of |udev| remains with the caller.
void Init(UdevInterface* udev);
// DisplayWatcherInterface implementation:
const std::vector<DisplayInfo>& GetDisplays() const override;
void AddObserver(DisplayWatcherObserver* observer) override;
void RemoveObserver(DisplayWatcherObserver* observer) override;
// UdevSubsystemObserver implementation:
void OnUdevEvent(const std::string& subsystem,
const std::string& sysname,
UdevAction action) override;
private:
// Returns the path to the I2C device used for communicating with the display
// connected to the device described by |drm_dir|. Returns an empty path if
// the device isn't found.
base::FilePath GetI2CDevicePath(const base::FilePath& drm_dir);
// Scans /sys and updates |displays_|.
void UpdateDisplays();
UdevInterface* udev_; // weak pointer
base::ObserverList<DisplayWatcherObserver> observers_;
// Currently-connected displays.
std::vector<DisplayInfo> displays_;
// Used instead of the default paths if non-empty.
base::FilePath sysfs_drm_path_for_testing_;
base::FilePath i2c_dev_path_for_testing_;
DISALLOW_COPY_AND_ASSIGN(DisplayWatcher);
};
} // namespace system
} // namespace power_manager
#endif // POWER_MANAGER_POWERD_SYSTEM_DISPLAY_DISPLAY_WATCHER_H_
| 32.240385 | 79 | 0.765583 | [
"vector"
] |
b12c7a32a95d5902bac6464e59be1c03dc7e4a49 | 2,597 | h | C | Wrapping/Generators/Python/PyUtils/itkPyCommand.h | nalinimsingh/ITK_4D | 95a2eacaeaffe572889832ef0894239f89e3f303 | [
"Apache-2.0"
] | 3 | 2018-10-01T20:46:17.000Z | 2019-12-17T19:39:50.000Z | Wrapping/Generators/Python/PyUtils/itkPyCommand.h | nalinimsingh/ITK_4D | 95a2eacaeaffe572889832ef0894239f89e3f303 | [
"Apache-2.0"
] | null | null | null | Wrapping/Generators/Python/PyUtils/itkPyCommand.h | nalinimsingh/ITK_4D | 95a2eacaeaffe572889832ef0894239f89e3f303 | [
"Apache-2.0"
] | 4 | 2018-05-17T16:34:54.000Z | 2020-09-24T02:12:40.000Z | /*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkPyCommand_h
#define itkPyCommand_h
#include "itkCommand.h"
// The python header defines _POSIX_C_SOURCE without a preceding #undef
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
// For Python 2.7 hypot bug, see https://bugs.python.org/issue11566
#include "PatchedPython27pyconfig.h"
#include <Python.h>
namespace itk
{
/** \class PyCommand
* \brief Command subclass that calls a Python callable object, e.g.
* a Python function.
*
* With this class, arbitrary Python callable objects (e.g. functions)
* can be associated with an instance to be used in AddObserver calls.
* This is analogous to itk::TclCommand, but then a tad more flexible. ;)
*
* This class was contributed by Charl P. Botha <cpbotha |AT| ieee.org>
*/
class PyCommand : public Command
{
public:
///! Standard "Self" typedef.
typedef PyCommand Self;
///! Smart pointer typedef support.
typedef SmartPointer<Self> Pointer;
///! Run-time type information (and related methods).
itkTypeMacro(PyCommand,Command);
///! Method for creation through the object factory.
itkNewMacro(Self);
/**
* Assign a Python callable object to be used. You don't have to keep
* a binding to the callable, PyCommand will also take out a reference
* to make sure the Callable sticks around.
*/
void SetCommandCallable(PyObject *obj);
PyObject * GetCommandCallable();
void Execute(Object *, const EventObject&);
void Execute(const Object *, const EventObject&);
protected:
PyCommand();
~PyCommand();
void PyExecute();
PyCommand(const Self&); // Not implemented.
PyCommand & operator=(const Self&); // Not implemented.
private:
PyObject *m_Object;
};
} // namespace itk
#endif // _itkPyCommand_h
| 30.197674 | 78 | 0.653446 | [
"object"
] |
b1356a392db45a9e373bf07c9ba946df562daadc | 5,783 | h | C | src/ripple/nodestore/Database.h | globalpaylab/GLPd | 83bf1c224037a21a06835c16fffc33b017783f10 | [
"BSL-1.0"
] | 89 | 2015-04-23T20:24:58.000Z | 2022-03-20T12:35:30.000Z | src/ripple/nodestore/Database.h | globalpaylab/GLPd | 83bf1c224037a21a06835c16fffc33b017783f10 | [
"BSL-1.0"
] | 14 | 2020-05-25T15:42:18.000Z | 2022-03-20T12:44:56.000Z | src/ripple/nodestore/Database.h | globalpaylab/GLPd | 83bf1c224037a21a06835c16fffc33b017783f10 | [
"BSL-1.0"
] | 41 | 2015-01-19T05:26:34.000Z | 2022-02-23T03:47:39.000Z | //------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_NODESTORE_DATABASE_H_INCLUDED
#define RIPPLE_NODESTORE_DATABASE_H_INCLUDED
#include <ripple/nodestore/NodeObject.h>
#include <ripple/nodestore/Backend.h>
#include <ripple/basics/TaggedCache.h>
namespace ripple {
namespace NodeStore {
/** Persistency layer for NodeObject
A Node is a ledger object which is uniquely identified by a key, which is
the 256-bit hash of the body of the node. The payload is a variable length
block of serialized data.
All ledger data is stored as node objects and as such, needs to be persisted
between launches. Furthermore, since the set of node objects will in
general be larger than the amount of available memory, purged node objects
which are later accessed must be retrieved from the node store.
@see NodeObject
*/
class Database
{
public:
/** Destroy the node store.
All pending operations are completed, pending writes flushed,
and files closed before this returns.
*/
virtual ~Database() = default;
/** Retrieve the name associated with this backend.
This is used for diagnostics and may not reflect the actual path
or paths used by the underlying backend.
*/
virtual std::string getName () const = 0;
/** Close the database.
This allows the caller to catch exceptions.
*/
virtual void close() = 0;
/** Fetch an object.
If the object is known to be not in the database, isn't found in the
database during the fetch, or failed to load correctly during the fetch,
`nullptr` is returned.
@note This can be called concurrently.
@param hash The key of the object to retrieve.
@return The object, or nullptr if it couldn't be retrieved.
*/
virtual std::shared_ptr<NodeObject> fetch (uint256 const& hash) = 0;
/** Fetch an object without waiting.
If I/O is required to determine whether or not the object is present,
`false` is returned. Otherwise, `true` is returned and `object` is set
to refer to the object, or `nullptr` if the object is not present.
If I/O is required, the I/O is scheduled.
@note This can be called concurrently.
@param hash The key of the object to retrieve
@param object The object retrieved
@return Whether the operation completed
*/
virtual bool asyncFetch (uint256 const& hash, std::shared_ptr<NodeObject>& object) = 0;
/** Wait for all currently pending async reads to complete.
*/
virtual void waitReads () = 0;
/** Get the maximum number of async reads the node store prefers.
@return The number of async reads preferred.
*/
virtual int getDesiredAsyncReadCount () = 0;
/** Store the object.
The caller's Blob parameter is overwritten.
@param type The type of object.
@param ledgerIndex The ledger in which the object appears.
@param data The payload of the object. The caller's
variable is overwritten.
@param hash The 256-bit hash of the payload data.
@return `true` if the object was stored?
*/
virtual void store (NodeObjectType type,
Blob&& data,
uint256 const& hash) = 0;
/** Visit every object in the database
This is usually called during import.
@note This routine will not be called concurrently with itself
or other methods.
@see import
*/
virtual void for_each(std::function <void(std::shared_ptr<NodeObject>)> f) = 0;
/** Import objects from another database. */
virtual void import (Database& source) = 0;
/** Retrieve the estimated number of pending write operations.
This is used for diagnostics.
*/
virtual std::int32_t getWriteLoad() const = 0;
/** Get the positive cache hits to total attempts ratio. */
virtual float getCacheHitRate () = 0;
/** Set the maximum number of entries and maximum cache age for both caches.
@param size Number of cache entries (0 = ignore)
@param age Maximum cache age in seconds
*/
virtual void tune (int size, int age) = 0;
/** Remove expired entries from the positive and negative caches. */
virtual void sweep () = 0;
/** Gather statistics pertaining to read and write activities.
Return the reads and writes, and total read and written bytes.
*/
virtual std::uint32_t getStoreCount () const = 0;
virtual std::uint32_t getFetchTotalCount () const = 0;
virtual std::uint32_t getFetchHitCount () const = 0;
virtual std::uint32_t getStoreSize () const = 0;
virtual std::uint32_t getFetchSize () const = 0;
};
}
}
#endif
| 37.070513 | 91 | 0.659001 | [
"object"
] |
b139d93d52ef40bd170e05e183c48871b7d6ff12 | 863 | h | C | src/render/ctf_flag_action_renderer.h | MrPepperoni/Reaping2-1 | 4ffef3cca1145ddc06ca87d2968c7b0ffd3ba3fd | [
"MIT"
] | 3 | 2015-02-22T20:34:28.000Z | 2020-03-04T08:55:25.000Z | src/render/ctf_flag_action_renderer.h | MrPepperoni/Reaping2-1 | 4ffef3cca1145ddc06ca87d2968c7b0ffd3ba3fd | [
"MIT"
] | 22 | 2015-12-13T16:29:40.000Z | 2017-03-04T15:45:44.000Z | src/render/ctf_flag_action_renderer.h | Reaping2/Reaping2 | 0d4c988c99413e50cc474f6206cf64176eeec95d | [
"MIT"
] | 14 | 2015-11-23T21:25:09.000Z | 2020-07-17T17:03:23.000Z | #ifndef INCLUDED_RENDER_CTF_FLAG_ACTION_RENDERER_H
#define INCLUDED_RENDER_CTF_FLAG_ACTION_RENDERER_H
#include "platform/i_platform.h"
#include "render/action_renderer.h"
#include "core/actor.h"
#include "renderable_sprite.h"
#include "renderable_repo.h"
#include "hat_action_renderer.h"
namespace render {
namespace ctf {
class CtfFlagActionRenderer : public ActionRenderer
{
ColorRepo& mColorRepo;
public:
CtfFlagActionRenderer( int32_t Id );
virtual void FillRenderableSprites( const Actor& actor, IRenderableComponent const& renderableC, RenderableSprites_t& renderableSprites );
protected:
virtual glm::vec4 GetRenderableColor( Actor const& actor ) const;
};
} // namespace ctf
} // namespace render
#endif//INCLUDED_RENDER_CTF_FLAG_ACTION_RENDERER_H
//command: "classgenerator.exe" -g "action_renderer" -c "ctf_flag_action_renderer"
| 27.83871 | 142 | 0.799537 | [
"render"
] |
b13a21e28d53b2ac89b903945e0448e8d16364d7 | 5,138 | h | C | include/votca/xtp/grid.h | choudarykvsp/xtp | 9a249fd34615abcf790d5f0ecd3ddf1ed0ac0e7a | [
"Apache-2.0"
] | 1 | 2018-03-05T17:36:53.000Z | 2018-03-05T17:36:53.000Z | include/votca/xtp/grid.h | choudarykvsp/xtp | 9a249fd34615abcf790d5f0ecd3ddf1ed0ac0e7a | [
"Apache-2.0"
] | null | null | null | include/votca/xtp/grid.h | choudarykvsp/xtp | 9a249fd34615abcf790d5f0ecd3ddf1ed0ac0e7a | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2009-2017 The VOTCA Development Team
* (http://www.votca.org)
*
* Licensed under the Apache License, Version 2.0 (the "License")
*
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef __XTP_GRID__H
#define __XTP_GRID__H
#include <votca/xtp/elements.h>
#include <string>
#include <vector>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/lu.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <votca/ctp/qmatom.h>
#include <votca/ctp/logger.h>
#include <votca/ctp/apolarsite.h>
#include <votca/ctp/polarseg.h>
/**
* \brief Takes a list of atoms, and creates different grids for it. Right now only CHELPG grid.
*
*
*
*/
using namespace std;
using namespace votca::tools;
namespace votca { namespace xtp {
namespace ub = boost::numeric::ublas;
class Grid{
public:
Grid( bool createpolarsites, bool useVdWcutoff, bool useVdWcutoff_inside)
:_cutoff(3),_gridspacing(0.3),_cutoff_inside(1.5),_shift_cutoff(0.0),_shift_cutoff_inside(0.0),
_useVdWcutoff(useVdWcutoff),_useVdWcutoff_inside(useVdWcutoff_inside),_cubegrid(false),_padding(3.0),
_createpolarsites(createpolarsites), _atomlist(NULL),
_lowerbound(vec(0,0,0)), _xsteps(0),_ysteps(0),_zsteps(0) {};
Grid()
:_cutoff(3),_gridspacing(0.3),_cutoff_inside(1.5),_shift_cutoff(0.0),_shift_cutoff_inside(0.0),
_useVdWcutoff(false),_useVdWcutoff_inside(false),_cubegrid(false),_padding(3.0),
_createpolarsites(false), _atomlist(NULL),
_lowerbound(vec(0,0,0)),_xsteps(0),_ysteps(0),_zsteps(0) {};
Grid(std::vector< vec > points)
:_gridpoints(points){};
~Grid();
Grid(const Grid &obj);
Grid& operator=(const Grid &obj);
const std::vector< vec > &getGrid() const {return _gridpoints;}
std::vector< ctp::APolarSite* > &Sites() {return _gridsites;}
std::vector< ctp::APolarSite*>* getSites() {return &_gridsites;}
void setCutoffs(double cutoff, double cutoff_inside){_cutoff=cutoff;_cutoff_inside=cutoff_inside;}
void setCutoffshifts(double shift_cutoff, double shift_cutoff_inside){_shift_cutoff=shift_cutoff;_shift_cutoff_inside=shift_cutoff_inside;}
void setSpacing(double spacing){_gridspacing=spacing;}
void setPadding(double padding){_padding=padding;}
void setCubegrid(bool cubegrid){_cubegrid=cubegrid;_createpolarsites=true;}
bool getCubegrid(void){return(_cubegrid);}
void setAtomlist(std::vector< ctp::QMAtom* >* Atomlist){_atomlist=Atomlist;}
int getsize(){return _gridpoints.size();}
int getTotalSize(){
int size=0.0;
if(_cubegrid){size=_all_gridsites.size();}
else{size=_gridpoints.size();}
return size;
}
void printGridtoxyzfile(const char* _filename);
void readgridfromCubeFile(std::string filename, bool ignore_zeros=true);
void printgridtoCubefile(std::string filename);
void setupradialgrid(int depth);
void setupgrid();
void setup2D(std::vector< vec > points);
void setupCHELPgrid(){
//_padding=2.8; // Additional distance from molecule to set up grid according to CHELPG paper [Journal of Computational Chemistry 11, 361, 1990]
_gridspacing=0.3; // Grid spacing according to same paper
_cutoff=2.8;
_useVdWcutoff_inside=true;
_shift_cutoff_inside=0.0;
_useVdWcutoff=false;
setupgrid();
}
private:
std::vector< vec > _gridpoints;
std::vector< ctp::APolarSite* > _gridsites;
std::vector< ctp::APolarSite* > _all_gridsites;
double _gridspacingX, _gridspacingY, _gridspacingZ;
double _cutoff;
double _gridspacing;
double _cutoff_inside;
double _shift_cutoff;
double _shift_cutoff_inside;
bool _useVdWcutoff;
bool _useVdWcutoff_inside;
bool _cubegrid;
double _padding;
bool _createpolarsites;
std::vector< ctp::QMAtom* >* _atomlist;
vec _lowerbound;
int _xsteps, _ysteps, _zsteps;
void subdivide(const vec &v1, const vec &v2, const vec &v3, std::vector<vec> &spherepoints, const int depth);
void initialize_sphere(std::vector<vec> &spherepoints, const int depth);
};
}}
#endif /* GRID_H */ | 33.802632 | 156 | 0.635851 | [
"vector"
] |
b13a401d07c0e2df2e7cf558519c5923b0effe3d | 1,705 | h | C | SelectChatServer/ChatServer2/LogicLib/Lobby.h | cjwcjswo/com2us_cppNetStudy_work | 3aab26cfd2e9bf1544fa41a0f2694d81167b2584 | [
"MIT"
] | 25 | 2019-05-20T08:07:39.000Z | 2021-08-17T11:25:02.000Z | SelectChatServer/ChatServer2/LogicLib/Lobby.h | cjwcjswo/com2us_cppNetStudy_work | 3aab26cfd2e9bf1544fa41a0f2694d81167b2584 | [
"MIT"
] | null | null | null | SelectChatServer/ChatServer2/LogicLib/Lobby.h | cjwcjswo/com2us_cppNetStudy_work | 3aab26cfd2e9bf1544fa41a0f2694d81167b2584 | [
"MIT"
] | 17 | 2019-07-07T12:20:16.000Z | 2022-01-11T08:27:44.000Z | #pragma once
#include <vector>
#include <unordered_map>
namespace NServerNetLib
{
class ITcpNetwork;
}
namespace NServerNetLib
{
class ILog;
}
namespace NCommon
{
enum class ERROR_CODE :short;
}
using ERROR_CODE = NCommon::ERROR_CODE;
namespace NLogicLib
{
using TcpNet = NServerNetLib::ITcpNetwork;
using ILog = NServerNetLib::ILog;
class User;
class Room;
struct LobbyUser
{
short Index = 0;
User* pUser = nullptr;
};
class Lobby
{
public:
Lobby();
virtual ~Lobby();
void Init(const short lobbyIndex, const short maxLobbyUserCount, const short maxRoomCountByLobby, const short maxRoomUserCount);
void Release();
void SetNetwork(TcpNet* pNetwork, ILog* pLogger);
short GetIndex() { return m_LobbyIndex; }
ERROR_CODE EnterUser(User* pUser);
ERROR_CODE LeaveUser(const int userIndex);
short GetUserCount();
Room* CreateRoom();
Room* GetRoom(const short roomIndex);
auto MaxUserCount() { return (short)m_MaxUserCount; }
auto MaxRoomCount() { return (short)m_RoomList.size(); }
protected:
void SendToAllUser(const short packetId, const short dataSize, char* pData, const int passUserindex = -1);
protected:
User* FindUser(const int userIndex);
ERROR_CODE AddUser(User* pUser);
void RemoveUser(const int userIndex);
protected:
ILog* m_pRefLogger;
TcpNet* m_pRefNetwork;
short m_LobbyIndex = 0;
short m_MaxUserCount = 0;
std::vector<LobbyUser> m_UserList;
std::unordered_map<int, User*> m_UserIndexDic;
std::unordered_map<const char*, User*> m_UserIDDic;
std::vector<Room*> m_RoomList;
};
}
| 17.947368 | 131 | 0.67566 | [
"vector"
] |
b13bd4063326985adf1f725a71f61ba0c808fcb5 | 55,545 | h | C | tools/clang/lib/SPIRV/SpirvEmitter.h | ashleysmithgpu/DirectXShaderCompiler | dffbf4de98efcbaa78529e1c5a77dd6b6a692804 | [
"NCSA"
] | 65 | 2017-03-20T16:29:29.000Z | 2021-10-21T00:59:22.000Z | tools/clang/lib/SPIRV/SpirvEmitter.h | ashleysmithgpu/DirectXShaderCompiler | dffbf4de98efcbaa78529e1c5a77dd6b6a692804 | [
"NCSA"
] | 322 | 2017-03-21T17:18:29.000Z | 2020-09-11T17:29:11.000Z | tools/clang/lib/SPIRV/SpirvEmitter.h | ashleysmithgpu/DirectXShaderCompiler | dffbf4de98efcbaa78529e1c5a77dd6b6a692804 | [
"NCSA"
] | 15 | 2017-03-28T03:57:43.000Z | 2021-10-21T00:59:16.000Z | //===------- SpirvEmitter.h - SPIR-V Binary Code Emitter --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//===----------------------------------------------------------------------===//
//
// This file defines a SPIR-V emitter class that takes in HLSL AST and emits
// SPIR-V binary words.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_LIB_SPIRV_SPIRVEMITTER_H
#define LLVM_CLANG_LIB_SPIRV_SPIRVEMITTER_H
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include "dxc/DXIL/DxilShaderModel.h"
#include "dxc/HlslIntrinsicOp.h"
#include "spirv/unified1/GLSL.std.450.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/TypeOrdering.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/SPIRV/FeatureManager.h"
#include "clang/SPIRV/SpirvBuilder.h"
#include "clang/SPIRV/SpirvContext.h"
#include "llvm/ADT/STLExtras.h"
#include "DeclResultIdMapper.h"
namespace clang {
namespace spirv {
/// SPIR-V emitter class. It consumes the HLSL AST and emits SPIR-V words.
///
/// This class only overrides the HandleTranslationUnit() method; Traversing
/// through the AST is done manually instead of using ASTConsumer's harness.
class SpirvEmitter : public ASTConsumer {
public:
SpirvEmitter(CompilerInstance &ci);
void HandleTranslationUnit(ASTContext &context) override;
ASTContext &getASTContext() { return astContext; }
SpirvBuilder &getSpirvBuilder() { return spvBuilder; }
DiagnosticsEngine &getDiagnosticsEngine() { return diags; }
CompilerInstance &getCompilerInstance() { return theCompilerInstance; }
SpirvCodeGenOptions &getSpirvOptions() { return spirvOptions; }
void doDecl(const Decl *decl);
void doStmt(const Stmt *stmt, llvm::ArrayRef<const Attr *> attrs = {});
SpirvInstruction *doExpr(const Expr *expr);
/// Processes the given expression and emits SPIR-V instructions. If the
/// result is a GLValue, does an additional load.
///
/// This method is useful for cases where ImplicitCastExpr (LValueToRValue) is
/// missing when using an lvalue as rvalue in the AST, e.g., DeclRefExpr will
/// not be wrapped in ImplicitCastExpr (LValueToRValue) when appearing in
/// HLSLVectorElementExpr since the generated HLSLVectorElementExpr itself can
/// be lvalue or rvalue.
SpirvInstruction *loadIfGLValue(const Expr *expr);
/// Casts the given value from fromType to toType. fromType and toType should
/// both be scalar or vector types of the same size.
SpirvInstruction *castToType(SpirvInstruction *value, QualType fromType,
QualType toType, SourceLocation);
private:
void doFunctionDecl(const FunctionDecl *decl);
void doVarDecl(const VarDecl *decl);
void doRecordDecl(const RecordDecl *decl);
void doEnumDecl(const EnumDecl *decl);
void doHLSLBufferDecl(const HLSLBufferDecl *decl);
void doImplicitDecl(const Decl *decl);
void doBreakStmt(const BreakStmt *stmt);
void doDiscardStmt(const DiscardStmt *stmt);
inline void doDeclStmt(const DeclStmt *stmt);
void doForStmt(const ForStmt *, llvm::ArrayRef<const Attr *> attrs = {});
void doIfStmt(const IfStmt *ifStmt, llvm::ArrayRef<const Attr *> attrs = {});
void doReturnStmt(const ReturnStmt *stmt);
void doSwitchStmt(const SwitchStmt *stmt,
llvm::ArrayRef<const Attr *> attrs = {});
void doWhileStmt(const WhileStmt *, llvm::ArrayRef<const Attr *> attrs = {});
void doDoStmt(const DoStmt *, llvm::ArrayRef<const Attr *> attrs = {});
void doContinueStmt(const ContinueStmt *);
SpirvInstruction *doArraySubscriptExpr(const ArraySubscriptExpr *expr);
SpirvInstruction *doBinaryOperator(const BinaryOperator *expr);
SpirvInstruction *doCallExpr(const CallExpr *callExpr);
SpirvInstruction *doCastExpr(const CastExpr *expr);
SpirvInstruction *doCompoundAssignOperator(const CompoundAssignOperator *);
SpirvInstruction *doConditionalOperator(const ConditionalOperator *expr);
SpirvInstruction *doCXXMemberCallExpr(const CXXMemberCallExpr *expr);
SpirvInstruction *doCXXOperatorCallExpr(const CXXOperatorCallExpr *expr);
SpirvInstruction *doExtMatrixElementExpr(const ExtMatrixElementExpr *expr);
SpirvInstruction *doHLSLVectorElementExpr(const HLSLVectorElementExpr *expr);
SpirvInstruction *doInitListExpr(const InitListExpr *expr);
SpirvInstruction *doMemberExpr(const MemberExpr *expr);
SpirvInstruction *doUnaryOperator(const UnaryOperator *expr);
/// Overload with pre computed SpirvEvalInfo.
///
/// The given expr will not be evaluated again.
SpirvInstruction *loadIfGLValue(const Expr *expr, SpirvInstruction *info);
/// Loads the pointer of the aliased-to-variable if the given expression is a
/// DeclRefExpr referencing an alias variable. See DeclResultIdMapper for
/// more explanation regarding this.
///
/// Note: legalization specific code
SpirvInstruction *loadIfAliasVarRef(const Expr *expr);
/// Loads the pointer of the aliased-to-variable and ajusts aliasVarInfo
/// accordingly if aliasVarExpr is referencing an alias variable. Returns true
/// if aliasVarInfo is changed, false otherwise.
///
/// Note: legalization specific code
bool loadIfAliasVarRef(const Expr *aliasVarExpr,
SpirvInstruction **aliasVarInstr);
private:
/// Translates the given frontend binary operator into its SPIR-V equivalent
/// taking consideration of the operand type.
spv::Op translateOp(BinaryOperator::Opcode op, QualType type);
spv::Op translateWaveOp(hlsl::IntrinsicOp op, QualType type, SourceLocation);
/// Generates SPIR-V instructions for the given normal (non-intrinsic and
/// non-operator) standalone or member function call.
SpirvInstruction *processCall(const CallExpr *expr);
/// Generates the necessary instructions for assigning rhs to lhs. If lhsPtr
/// is not zero, it will be used as the pointer from lhs instead of evaluating
/// lhs again.
SpirvInstruction *processAssignment(const Expr *lhs, SpirvInstruction *rhs,
bool isCompoundAssignment,
SpirvInstruction *lhsPtr = nullptr);
/// Generates SPIR-V instructions to store rhsVal into lhsPtr. This will be
/// recursive if lhsValType is a composite type. rhsExpr will be used as a
/// reference to adjust the CodeGen if not nullptr.
void storeValue(SpirvInstruction *lhsPtr, SpirvInstruction *rhsVal,
QualType lhsValType, SourceLocation loc);
/// Decomposes and reconstructs the given srcVal of the given valType to meet
/// the requirements of the dstLR layout rule.
SpirvInstruction *reconstructValue(SpirvInstruction *srcVal, QualType valType,
SpirvLayoutRule dstLR, SourceLocation loc);
/// Generates the necessary instructions for conducting the given binary
/// operation on lhs and rhs.
///
/// computationType is the type for LHS and RHS when doing computation, while
/// resultType is the type of the whole binary operation. They can be
/// different for compound assignments like <some-int-value> *=
/// <some-float-value>, where computationType is float and resultType is int.
///
/// If lhsResultId is not nullptr, the evaluated pointer from lhs during the
/// process will be written into it. If mandateGenOpcode is not spv::Op::Max,
/// it will used as the SPIR-V opcode instead of deducing from Clang frontend
/// opcode.
SpirvInstruction *
processBinaryOp(const Expr *lhs, const Expr *rhs, BinaryOperatorKind opcode,
QualType computationType, QualType resultType, SourceRange,
SourceLocation, SpirvInstruction **lhsInfo = nullptr,
spv::Op mandateGenOpcode = spv::Op::Max);
/// Generates SPIR-V instructions to initialize the given variable once.
void initOnce(QualType varType, std::string varName, SpirvVariable *,
const Expr *varInit);
/// Returns true if the given expression will be translated into a vector
/// shuffle instruction in SPIR-V.
///
/// We emit a vector shuffle instruction iff
/// * We are not selecting only one element from the vector (OpAccessChain
/// or OpCompositeExtract for such case);
/// * We are not selecting all elements in their original order (essentially
/// the original vector, no shuffling needed).
bool isVectorShuffle(const Expr *expr);
/// \brief Returns true if the given CXXOperatorCallExpr is indexing into a
/// Buffer/RWBuffer/Texture/RWTexture using operator[].
/// On success, writes the base buffer into *base if base is not nullptr, and
/// writes the index into *index if index is not nullptr.
bool isBufferTextureIndexing(const CXXOperatorCallExpr *,
const Expr **base = nullptr,
const Expr **index = nullptr);
/// \brief Returns true if the given CXXOperatorCallExpr is the .mips[][]
/// access into a Texture or .sample[][] access into Texture2DMS(Array). On
/// success, writes base texture object into *base if base is not nullptr,
/// writes the index into *index if index is not nullptr, and writes the mip
/// level (lod) to *lod if lod is not nullptr.
bool isTextureMipsSampleIndexing(const CXXOperatorCallExpr *indexExpr,
const Expr **base = nullptr,
const Expr **index = nullptr,
const Expr **lod = nullptr);
/// Condenses a sequence of HLSLVectorElementExpr starting from the given
/// expr into one. Writes the original base into *basePtr and the condensed
/// accessor into *flattenedAccessor.
void condenseVectorElementExpr(
const HLSLVectorElementExpr *expr, const Expr **basePtr,
hlsl::VectorMemberAccessPositions *flattenedAccessor);
/// Generates necessary SPIR-V instructions to create a vector splat out of
/// the given scalarExpr. The generated vector will have the same element
/// type as scalarExpr and of the given size. If resultIsConstant is not
/// nullptr, writes true to it if the generated instruction is a constant.
SpirvInstruction *createVectorSplat(const Expr *scalarExpr, uint32_t size);
/// Splits the given vector into the last element and the rest (as a new
/// vector).
void splitVecLastElement(QualType vecType, SpirvInstruction *vec,
SpirvInstruction **residual,
SpirvInstruction **lastElement, SourceLocation loc);
/// Converts a vector value into the given struct type with its element type's
/// <result-id> as elemTypeId.
///
/// Assumes the vector and the struct have matching number of elements. Panics
/// otherwise.
SpirvInstruction *convertVectorToStruct(QualType structType,
QualType elemType,
SpirvInstruction *vector,
SourceLocation loc);
/// Translates a floatN * float multiplication into SPIR-V instructions and
/// returns the <result-id>. Returns 0 if the given binary operation is not
/// floatN * float.
SpirvInstruction *tryToGenFloatVectorScale(const BinaryOperator *expr);
/// Translates a floatMxN * float multiplication into SPIR-V instructions and
/// returns the <result-id>. Returns 0 if the given binary operation is not
/// floatMxN * float.
SpirvInstruction *tryToGenFloatMatrixScale(const BinaryOperator *expr);
/// Tries to emit instructions for assigning to the given vector element
/// accessing expression. Returns 0 if the trial fails and no instructions
/// are generated.
SpirvInstruction *tryToAssignToVectorElements(const Expr *lhs,
SpirvInstruction *rhs);
/// Tries to emit instructions for assigning to the given matrix element
/// accessing expression. Returns 0 if the trial fails and no instructions
/// are generated.
SpirvInstruction *tryToAssignToMatrixElements(const Expr *lhs,
SpirvInstruction *rhs);
/// Tries to emit instructions for assigning to the given RWBuffer/RWTexture
/// object. Returns 0 if the trial fails and no instructions are generated.
SpirvInstruction *tryToAssignToRWBufferRWTexture(const Expr *lhs,
SpirvInstruction *rhs);
/// Tries to emit instructions for assigning to the given mesh out attribute
/// or indices object. Returns 0 if the trial fails and no instructions are
/// generated.
SpirvInstruction *
tryToAssignToMSOutAttrsOrIndices(const Expr *lhs, SpirvInstruction *rhs,
SpirvInstruction *vecComponent = nullptr,
bool noWriteBack = false);
/// Emit instructions for assigning to the given mesh out attribute.
void assignToMSOutAttribute(
const DeclaratorDecl *decl, SpirvInstruction *value,
const llvm::SmallVector<SpirvInstruction *, 4> &indices);
/// Emit instructions for assigning to the given mesh out indices object.
void
assignToMSOutIndices(const DeclaratorDecl *decl, SpirvInstruction *value,
const llvm::SmallVector<SpirvInstruction *, 4> &indices);
/// Processes each vector within the given matrix by calling actOnEachVector.
/// matrixVal should be the loaded value of the matrix. actOnEachVector takes
/// three parameters for the current vector: the index, the <type-id>, and
/// the value. It returns the <result-id> of the processed vector.
SpirvInstruction *processEachVectorInMatrix(
const Expr *matrix, SpirvInstruction *matrixVal,
llvm::function_ref<SpirvInstruction *(uint32_t, QualType,
SpirvInstruction *)>
actOnEachVector,
SourceLocation loc = {});
/// Translates the given varDecl into a spec constant.
void createSpecConstant(const VarDecl *varDecl);
/// Generates the necessary instructions for conducting the given binary
/// operation on lhs and rhs.
///
/// This method expects that both lhs and rhs are SPIR-V acceptable matrices.
SpirvInstruction *processMatrixBinaryOp(const Expr *lhs, const Expr *rhs,
const BinaryOperatorKind opcode,
SourceRange, SourceLocation);
/// Creates a temporary local variable in the current function of the given
/// varType and varName. Initializes the variable with the given initValue.
/// Returns the instruction pointer for the variable.
SpirvVariable *createTemporaryVar(QualType varType, llvm::StringRef varName,
SpirvInstruction *initValue,
SourceLocation loc);
/// Collects all indices from consecutive MemberExprs, ArraySubscriptExprs and
/// CXXOperatorCallExprs. Also special handles all mesh shader out attributes
/// to return the entire expression in order for caller to extract the member
/// expression.
const Expr *
collectArrayStructIndices(const Expr *expr, bool rawIndex,
llvm::SmallVectorImpl<uint32_t> *rawIndices,
llvm::SmallVectorImpl<SpirvInstruction *> *indices,
bool *isMSOutAttribute = nullptr);
/// Creates an access chain to index into the given SPIR-V evaluation result
/// and returns the new SPIR-V evaluation result.
SpirvInstruction *
turnIntoElementPtr(QualType baseType, SpirvInstruction *base,
QualType elemType,
const llvm::SmallVector<SpirvInstruction *, 4> &indices,
SourceLocation loc);
private:
/// Validates that vk::* attributes are used correctly and returns false if
/// errors are found.
bool validateVKAttributes(const NamedDecl *decl);
private:
/// Converts the given value from the bitwidth of 'fromType' to the bitwidth
/// of 'toType'. If the two have the same bitwidth, returns the value itself.
/// If resultType is not nullptr, the resulting value's type will be written
/// to resultType. Panics if the given types are not scalar or vector of
/// float/integer type.
SpirvInstruction *convertBitwidth(SpirvInstruction *value, SourceLocation loc,
QualType fromType, QualType toType,
QualType *resultType = nullptr);
/// Processes the given expr, casts the result into the given bool (vector)
/// type and returns the <result-id> of the casted value.
SpirvInstruction *castToBool(SpirvInstruction *value, QualType fromType,
QualType toType, SourceLocation loc);
/// Processes the given expr, casts the result into the given integer (vector)
/// type and returns the <result-id> of the casted value.
SpirvInstruction *castToInt(SpirvInstruction *value, QualType fromType,
QualType toType, SourceLocation);
/// Processes the given expr, casts the result into the given float (vector)
/// type and returns the <result-id> of the casted value.
SpirvInstruction *castToFloat(SpirvInstruction *value, QualType fromType,
QualType toType, SourceLocation);
private:
/// Processes HLSL instrinsic functions.
SpirvInstruction *processIntrinsicCallExpr(const CallExpr *);
/// Processes the 'clip' intrinsic function. Discards the current pixel if the
/// specified value is less than zero.
SpirvInstruction *processIntrinsicClip(const CallExpr *);
/// Processes the 'dst' intrinsic function.
SpirvInstruction *processIntrinsicDst(const CallExpr *);
/// Processes the 'clamp' intrinsic function.
SpirvInstruction *processIntrinsicClamp(const CallExpr *);
/// Processes the 'frexp' intrinsic function.
SpirvInstruction *processIntrinsicFrexp(const CallExpr *);
/// Processes the 'ldexp' intrinsic function.
SpirvInstruction *processIntrinsicLdexp(const CallExpr *);
/// Processes the 'D3DCOLORtoUBYTE4' intrinsic function.
SpirvInstruction *processD3DCOLORtoUBYTE4(const CallExpr *);
/// Processes the 'lit' intrinsic function.
SpirvInstruction *processIntrinsicLit(const CallExpr *);
/// Processes the 'GroupMemoryBarrier', 'GroupMemoryBarrierWithGroupSync',
/// 'DeviceMemoryBarrier', 'DeviceMemoryBarrierWithGroupSync',
/// 'AllMemoryBarrier', and 'AllMemoryBarrierWithGroupSync' intrinsic
/// functions.
SpirvInstruction *processIntrinsicMemoryBarrier(const CallExpr *,
bool isDevice, bool groupSync,
bool isAllBarrier);
/// Processes the 'mad' intrinsic function.
SpirvInstruction *processIntrinsicMad(const CallExpr *);
/// Processes the 'modf' intrinsic function.
SpirvInstruction *processIntrinsicModf(const CallExpr *);
/// Processes the 'msad4' intrinsic function.
SpirvInstruction *processIntrinsicMsad4(const CallExpr *);
/// Processes the 'mul' intrinsic function.
SpirvInstruction *processIntrinsicMul(const CallExpr *);
/// Transposes a non-floating point matrix and returns the result-id of the
/// transpose.
SpirvInstruction *processNonFpMatrixTranspose(QualType matType,
SpirvInstruction *matrix,
SourceLocation loc);
/// Processes the dot product of two non-floating point vectors. The SPIR-V
/// OpDot only accepts float vectors. Assumes that the two vectors are of the
/// same size and have the same element type (elemType).
SpirvInstruction *processNonFpDot(SpirvInstruction *vec1Id,
SpirvInstruction *vec2Id, uint32_t vecSize,
QualType elemType, SourceLocation loc);
/// Processes the multiplication of a *non-floating point* matrix by a scalar.
/// Assumes that the matrix element type and the scalar type are the same.
SpirvInstruction *processNonFpScalarTimesMatrix(QualType scalarType,
SpirvInstruction *scalar,
QualType matType,
SpirvInstruction *matrix,
SourceLocation loc);
/// Processes the multiplication of a *non-floating point* matrix by a vector.
/// Assumes the matrix element type and the vector element type are the same.
/// Notice that the vector in this case is a "row vector" and will be
/// multiplied by the matrix columns (dot product). As a result, the given
/// matrix must be transposed in order to easily get each column. If
/// 'matrixTranspose' is non-zero, it will be used as the transpose matrix
/// result-id; otherwise the function will perform the transpose itself.
SpirvInstruction *
processNonFpVectorTimesMatrix(QualType vecType, SpirvInstruction *vector,
QualType matType, SpirvInstruction *matrix,
SourceLocation loc,
SpirvInstruction *matrixTranspose = nullptr);
/// Processes the multiplication of a vector by a *non-floating point* matrix.
/// Assumes the matrix element type and the vector element type are the same.
SpirvInstruction *processNonFpMatrixTimesVector(QualType matType,
SpirvInstruction *matrix,
QualType vecType,
SpirvInstruction *vector,
SourceLocation loc);
/// Processes a non-floating point matrix multiplication. Assumes that the
/// number of columns in lhs matrix is the same as number of rows in the rhs
/// matrix. Also assumes that the two matrices have the same element type.
SpirvInstruction *processNonFpMatrixTimesMatrix(QualType lhsType,
SpirvInstruction *lhs,
QualType rhsType,
SpirvInstruction *rhs,
SourceLocation loc);
/// Processes the 'dot' intrinsic function.
SpirvInstruction *processIntrinsicDot(const CallExpr *);
/// Processes the 'log10' intrinsic function.
SpirvInstruction *processIntrinsicLog10(const CallExpr *);
/// Processes the 'all' and 'any' intrinsic functions.
SpirvInstruction *processIntrinsicAllOrAny(const CallExpr *, spv::Op);
/// Processes the 'asfloat', 'asint', and 'asuint' intrinsic functions.
SpirvInstruction *processIntrinsicAsType(const CallExpr *);
/// Processes the 'saturate' intrinsic function.
SpirvInstruction *processIntrinsicSaturate(const CallExpr *);
/// Processes the 'sincos' intrinsic function.
SpirvInstruction *processIntrinsicSinCos(const CallExpr *);
/// Processes the 'isFinite' intrinsic function.
SpirvInstruction *processIntrinsicIsFinite(const CallExpr *);
/// Processes the 'rcp' intrinsic function.
SpirvInstruction *processIntrinsicRcp(const CallExpr *);
/// Processes the 'sign' intrinsic function for float types.
/// The FSign instruction in the GLSL instruction set returns a floating point
/// result. The HLSL sign function, however, returns an integer. An extra
/// casting from float to integer is therefore performed by this method.
SpirvInstruction *processIntrinsicFloatSign(const CallExpr *);
/// Processes the 'f16to32' intrinsic function.
SpirvInstruction *processIntrinsicF16ToF32(const CallExpr *);
/// Processes the 'f32tof16' intrinsic function.
SpirvInstruction *processIntrinsicF32ToF16(const CallExpr *);
/// Processes the given intrinsic function call using the given GLSL
/// extended instruction. If the given instruction cannot operate on matrices,
/// it performs the instruction on each row of the matrix and uses composite
/// construction to generate the resulting matrix.
SpirvInstruction *processIntrinsicUsingGLSLInst(const CallExpr *,
GLSLstd450 instr,
bool canOperateOnMatrix,
SourceLocation);
/// Processes the given intrinsic function call using the given SPIR-V
/// instruction. If the given instruction cannot operate on matrices, it
/// performs the instruction on each row of the matrix and uses composite
/// construction to generate the resulting matrix.
SpirvInstruction *processIntrinsicUsingSpirvInst(const CallExpr *, spv::Op,
bool canOperateOnMatrix);
/// Processes the given intrinsic member call.
SpirvInstruction *processIntrinsicMemberCall(const CXXMemberCallExpr *expr,
hlsl::IntrinsicOp opcode);
/// Processes Interlocked* intrinsic functions.
SpirvInstruction *processIntrinsicInterlockedMethod(const CallExpr *,
hlsl::IntrinsicOp);
/// Processes SM6.0 wave query intrinsic calls.
SpirvInstruction *processWaveQuery(const CallExpr *, spv::Op opcode);
/// Processes SM6.0 wave vote intrinsic calls.
SpirvInstruction *processWaveVote(const CallExpr *, spv::Op opcode);
/// Processes SM6.0 wave active/prefix count bits.
SpirvInstruction *processWaveCountBits(const CallExpr *,
spv::GroupOperation groupOp);
/// Processes SM6.0 wave reduction or scan/prefix intrinsic calls.
SpirvInstruction *processWaveReductionOrPrefix(const CallExpr *, spv::Op op,
spv::GroupOperation groupOp);
/// Processes SM6.0 wave broadcast intrinsic calls.
SpirvInstruction *processWaveBroadcast(const CallExpr *);
/// Processes SM6.0 quad-wide shuffle.
SpirvInstruction *processWaveQuadWideShuffle(const CallExpr *,
hlsl::IntrinsicOp op);
/// Processes the NonUniformResourceIndex intrinsic function.
SpirvInstruction *processIntrinsicNonUniformResourceIndex(const CallExpr *);
/// Process builtins specific to raytracing.
SpirvInstruction *processRayBuiltins(const CallExpr *, hlsl::IntrinsicOp op);
/// Process raytracing intrinsics.
SpirvInstruction *processReportHit(const CallExpr *);
void processCallShader(const CallExpr *callExpr);
void processTraceRay(const CallExpr *callExpr);
/// Process amplification shader intrinsics.
void processDispatchMesh(const CallExpr *callExpr);
/// Process mesh shader intrinsics.
void processMeshOutputCounts(const CallExpr *callExpr);
private:
/// Returns the <result-id> for constant value 0 of the given type.
SpirvConstant *getValueZero(QualType type);
/// Returns the <result-id> for a constant zero vector of the given size and
/// element type.
SpirvConstant *getVecValueZero(QualType elemType, uint32_t size);
/// Returns the <result-id> for constant value 1 of the given type.
SpirvConstant *getValueOne(QualType type);
/// Returns the <result-id> for a constant one vector of the given size and
/// element type.
SpirvConstant *getVecValueOne(QualType elemType, uint32_t size);
/// Returns the <result-id> for a constant one (vector) having the same
/// element type as the given matrix type.
///
/// If a 1x1 matrix is given, the returned value one will be a scalar;
/// if a Mx1 or 1xN matrix is given, the returned value one will be a
/// vector of size M or N; if a MxN matrix is given, the returned value
/// one will be a vector of size N.
SpirvConstant *getMatElemValueOne(QualType type);
/// Returns a SPIR-V constant equal to the bitwdith of the given type minus
/// one. The returned constant has the same component count and bitwidth as
/// the given type.
SpirvConstant *getMaskForBitwidthValue(QualType type);
private:
/// \brief Performs a FlatConversion implicit cast. Fills an instance of the
/// given type with initializer <result-id>. The initializer is of type
/// initType.
SpirvInstruction *processFlatConversion(const QualType type,
const QualType initType,
SpirvInstruction *initId,
SourceLocation);
private:
/// Translates the given frontend APValue into its SPIR-V equivalent for the
/// given targetType.
SpirvConstant *translateAPValue(const APValue &value,
const QualType targetType);
/// Translates the given frontend APInt into its SPIR-V equivalent for the
/// given targetType.
SpirvConstant *translateAPInt(const llvm::APInt &intValue,
QualType targetType);
/// Translates the given frontend APFloat into its SPIR-V equivalent for the
/// given targetType.
SpirvConstant *translateAPFloat(llvm::APFloat floatValue,
QualType targetType);
/// Tries to evaluate the given Expr as a constant and returns the <result-id>
/// if success. Otherwise, returns 0.
SpirvConstant *tryToEvaluateAsConst(const Expr *expr);
/// Tries to evaluate the given APFloat as a 32-bit float. If the evaluation
/// can be performed without loss, it returns the <result-id> of the SPIR-V
/// constant for that value. Returns zero otherwise.
SpirvConstant *tryToEvaluateAsFloat32(const llvm::APFloat &);
/// Tries to evaluate the given APInt as a 32-bit integer. If the evaluation
/// can be performed without loss, it returns the <result-id> of the SPIR-V
/// constant for that value.
SpirvConstant *tryToEvaluateAsInt32(const llvm::APInt &, bool isSigned);
/// Returns true iff the given expression is a literal integer that cannot be
/// represented in a 32-bit integer type or a literal float that cannot be
/// represented in a 32-bit float type without losing info. Returns false
/// otherwise.
bool isLiteralLargerThan32Bits(const Expr *expr);
private:
/// Translates the given HLSL loop attribute into SPIR-V loop control mask.
/// Emits an error if the given attribute is not a loop attribute.
spv::LoopControlMask translateLoopAttribute(const Stmt *, const Attr &);
static hlsl::ShaderModel::Kind getShaderModelKind(StringRef stageName);
static spv::ExecutionModel getSpirvShaderStage(hlsl::ShaderModel::Kind smk);
/// \brief Adds necessary execution modes for the hull/domain shaders based on
/// the HLSL attributes of the entry point function.
/// In the case of hull shaders, also writes the number of output control
/// points to *numOutputControlPoints. Returns true on success, and false on
/// failure.
bool processTessellationShaderAttributes(const FunctionDecl *entryFunction,
uint32_t *numOutputControlPoints);
/// \brief Adds necessary execution modes for the geometry shader based on the
/// HLSL attributes of the entry point function. Also writes the array size of
/// the input, which depends on the primitive type, to *arraySize.
bool processGeometryShaderAttributes(const FunctionDecl *entryFunction,
uint32_t *arraySize);
/// \brief Adds necessary execution modes for the pixel shader based on the
/// HLSL attributes of the entry point function.
void processPixelShaderAttributes(const FunctionDecl *decl);
/// \brief Adds necessary execution modes for the compute shader based on the
/// HLSL attributes of the entry point function.
void processComputeShaderAttributes(const FunctionDecl *entryFunction);
/// \brief Adds necessary execution modes for the mesh/amplification shader
/// based on the HLSL attributes of the entry point function.
bool
processMeshOrAmplificationShaderAttributes(const FunctionDecl *decl,
uint32_t *outVerticesArraySize);
/// \brief Emits a wrapper function for the entry function and returns true
/// on success.
///
/// The wrapper function loads the values of all stage input variables and
/// creates composites as expected by the source code entry function. It then
/// calls the source code entry point and writes out stage output variables
/// by extracting sub-values from the return value. In this way, we can handle
/// the source code entry point as a normal function.
///
/// The wrapper function is also responsible for initializing global static
/// variables for some cases.
bool emitEntryFunctionWrapper(const FunctionDecl *entryFunction,
SpirvFunction *entryFuncId);
/// \brief Emits a wrapper function for the entry functions for raytracing
/// stages and returns true on success.
///
/// Wrapper is specific to raytracing stages since for specific stages we
/// create specific module scoped stage variables and perform copies to them.
/// The wrapper function is also responsible for initializing global static
/// variables for some cases.
bool emitEntryFunctionWrapperForRayTracing(const FunctionDecl *entryFunction,
SpirvFunction *entryFuncId);
/// \brief Performs the following operations for the Hull shader:
/// * Creates an output variable which is an Array containing results for all
/// control points.
///
/// * If the Patch Constant Function (PCF) takes the Hull main entry function
/// results (OutputPatch), it creates a temporary function-scope variable that
/// is then passed to the PCF.
///
/// * Adds a control barrier (OpControlBarrier) to ensure all invocations are
/// done before PCF is called.
///
/// * Prepares the necessary parameters to pass to the PCF (Can be one or more
/// of InputPatch, OutputPatch, PrimitiveId).
///
/// * The execution thread with ControlPointId (invocationID) of 0 calls the
/// PCF. e.g. if(id == 0) pcf();
///
/// * Gathers the results of the PCF and assigns them to stage output
/// variables.
///
/// The method panics if it is called for any shader kind other than Hull
/// shaders.
bool processHSEntryPointOutputAndPCF(
const FunctionDecl *hullMainFuncDecl, QualType retType,
SpirvInstruction *retVal, uint32_t numOutputControlPoints,
SpirvInstruction *outputControlPointId, SpirvInstruction *primitiveId,
SpirvInstruction *viewId, SpirvInstruction *hullMainInputPatch);
private:
/// \brief Returns true iff *all* the case values in the given switch
/// statement are integer literals. In such cases OpSwitch can be used to
/// represent the switch statement.
/// We only care about the case values to be compared with the selector. They
/// may appear in the top level CaseStmt or be nested in a CompoundStmt.Fall
/// through cases will result in the second situation.
bool allSwitchCasesAreIntegerLiterals(const Stmt *root);
/// \brief Recursively discovers all CaseStmt and DefaultStmt under the
/// sub-tree of the given root. Recursively goes down the tree iff it finds a
/// CaseStmt, DefaultStmt, or CompoundStmt. It does not recurse on other
/// statement types. For each discovered case, a basic block is created and
/// registered within the module, and added as a successor to the current
/// active basic block.
///
/// Writes a vector of (integer, basic block label) pairs for all cases to the
/// given 'targets' argument. If a DefaultStmt is found, it also returns the
/// label for the default basic block through the defaultBB parameter. This
/// method panics if it finds a case value that is not an integer literal.
void discoverAllCaseStmtInSwitchStmt(
const Stmt *root, SpirvBasicBlock **defaultBB,
std::vector<std::pair<uint32_t, SpirvBasicBlock *>> *targets);
/// Flattens structured AST of the given switch statement into a vector of AST
/// nodes and stores into flatSwitch.
///
/// The AST for a switch statement may look arbitrarily different based on
/// several factors such as placement of cases, placement of breaks, placement
/// of braces, and fallthrough cases.
///
/// A CaseStmt for instance is the child node of a CompoundStmt for
/// regular cases and it is the child node of another CaseStmt for fallthrough
/// cases.
///
/// A BreakStmt for instance could be the child node of a CompoundStmt
/// for regular cases, or the child node of a CaseStmt for some fallthrough
/// cases.
///
/// This method flattens the AST representation of a switch statement to make
/// it easier to process for translation.
/// For example:
///
/// switch(a) {
/// case 1:
/// <Stmt1>
/// case 2:
/// <Stmt2>
/// break;
/// case 3:
/// case 4:
/// <Stmt4>
/// break;
/// deafult:
/// <Stmt5>
/// }
///
/// is flattened to the following vector:
///
/// +-----+-----+-----+-----+-----+-----+-----+-----+-----+-------+-----+
/// |Case1|Stmt1|Case2|Stmt2|Break|Case3|Case4|Stmt4|Break|Default|Stmt5|
/// +-----+-----+-----+-----+-----+-----+-----+-----+-----+-------+-----+
///
void flattenSwitchStmtAST(const Stmt *root,
std::vector<const Stmt *> *flatSwitch);
void processCaseStmtOrDefaultStmt(const Stmt *stmt);
void processSwitchStmtUsingSpirvOpSwitch(const SwitchStmt *switchStmt);
/// Translates a switch statement into SPIR-V conditional branches.
///
/// This is done by constructing AST if statements out of the cases using the
/// following pattern:
/// if { ... } else if { ... } else if { ... } else { ... }
/// And then calling the SPIR-V codegen methods for these if statements.
///
/// Each case comparison is turned into an if statement, and the "then" body
/// of the if statement will be the body of the case.
/// If a default statements exists, it becomes the body of the "else"
/// statement.
void processSwitchStmtUsingIfStmts(const SwitchStmt *switchStmt);
private:
/// Handles the offset argument in the given method call at the given argument
/// index. Panics if the argument at the given index does not exist. Writes
/// the <result-id> to either *constOffset or *varOffset, depending on the
/// constantness of the offset.
void handleOffsetInMethodCall(const CXXMemberCallExpr *expr, uint32_t index,
SpirvInstruction **constOffset,
SpirvInstruction **varOffset);
/// \brief Processes .Load() method call for Buffer/RWBuffer and texture
/// objects.
SpirvInstruction *processBufferTextureLoad(const CXXMemberCallExpr *);
/// \brief Loads one element from the given Buffer/RWBuffer/Texture object at
/// the given location. The type of the loaded element matches the type in the
/// declaration for the Buffer/Texture object.
/// If residencyCodeId is not zero, the SPIR-V instruction for storing the
/// resulting residency code will also be emitted.
SpirvInstruction *
processBufferTextureLoad(const Expr *object, SpirvInstruction *location,
SpirvInstruction *constOffset,
SpirvInstruction *varOffset, SpirvInstruction *lod,
SpirvInstruction *residencyCode, SourceLocation loc);
/// \brief Processes .Sample() and .Gather() method calls for texture objects.
SpirvInstruction *processTextureSampleGather(const CXXMemberCallExpr *expr,
bool isSample);
/// \brief Processes .SampleBias() and .SampleLevel() method calls for texture
/// objects.
SpirvInstruction *processTextureSampleBiasLevel(const CXXMemberCallExpr *expr,
bool isBias);
/// \brief Processes .SampleGrad() method call for texture objects.
SpirvInstruction *processTextureSampleGrad(const CXXMemberCallExpr *expr);
/// \brief Processes .SampleCmp() or .SampleCmpLevelZero() method call for
/// texture objects.
SpirvInstruction *
processTextureSampleCmpCmpLevelZero(const CXXMemberCallExpr *expr,
bool isCmp);
/// \brief Handles .Gather{|Cmp}{Red|Green|Blue|Alpha}() calls on texture
/// types.
SpirvInstruction *
processTextureGatherRGBACmpRGBA(const CXXMemberCallExpr *expr, bool isCmp,
uint32_t component);
/// \brief Handles .GatherCmp() calls on texture types.
SpirvInstruction *processTextureGatherCmp(const CXXMemberCallExpr *expr);
/// \brief Returns the calculated level-of-detail (a single float value) for
/// the given texture. Handles intrinsic HLSL CalculateLevelOfDetail or
/// CalculateLevelOfDetailUnclamped function depending on the given unclamped
/// parameter.
SpirvInstruction *processTextureLevelOfDetail(const CXXMemberCallExpr *expr,
bool unclamped);
/// \brief Processes the .GetDimensions() call on supported objects.
SpirvInstruction *processGetDimensions(const CXXMemberCallExpr *);
/// \brief Queries the given (RW)Buffer/(RW)Texture image in the given expr
/// for the requested information. Based on the dimension of the image, the
/// following info can be queried: width, height, depth, number of mipmap
/// levels.
SpirvInstruction *
processBufferTextureGetDimensions(const CXXMemberCallExpr *);
/// \brief Generates an OpAccessChain instruction for the given
/// (RW)StructuredBuffer.Load() method call.
SpirvInstruction *processStructuredBufferLoad(const CXXMemberCallExpr *expr);
/// \brief Increments or decrements the counter for RW/Append/Consume
/// structured buffer. If loadObject is true, the object upon which the call
/// is made will be evaluated and translated into SPIR-V.
SpirvInstruction *incDecRWACSBufferCounter(const CXXMemberCallExpr *call,
bool isInc,
bool loadObject = true);
/// Assigns the counter variable associated with srcExpr to the one associated
/// with dstDecl if the dstDecl is an internal RW/Append/Consume structured
/// buffer. Returns false if there is no associated counter variable for
/// srcExpr or dstDecl.
///
/// Note: legalization specific code
bool tryToAssignCounterVar(const DeclaratorDecl *dstDecl,
const Expr *srcExpr);
bool tryToAssignCounterVar(const Expr *dstExpr, const Expr *srcExpr);
/// Returns the counter variable's information associated with the entity
/// represented by the given decl.
///
/// This method only handles final alias structured buffers, which means
/// AssocCounter#1 and AssocCounter#2.
const CounterIdAliasPair *getFinalACSBufferCounter(const Expr *expr);
/// This method handles AssocCounter#3 and AssocCounter#4.
const CounterVarFields *
getIntermediateACSBufferCounter(const Expr *expr,
llvm::SmallVector<uint32_t, 4> *indices);
/// Gets or creates an ImplicitParamDecl to represent the implicit object
/// parameter of the given method.
const ImplicitParamDecl *
getOrCreateDeclForMethodObject(const CXXMethodDecl *method);
/// \brief Loads numWords 32-bit unsigned integers or stores numWords 32-bit
/// unsigned integers (based on the doStore parameter) to the given
/// ByteAddressBuffer. Loading is allowed from a ByteAddressBuffer or
/// RWByteAddressBuffer. Storing is allowed only to RWByteAddressBuffer.
/// Panics if it is not the case.
SpirvInstruction *processByteAddressBufferLoadStore(const CXXMemberCallExpr *,
uint32_t numWords,
bool doStore);
/// \brief Processes the GetDimensions intrinsic function call on a
/// (RW)ByteAddressBuffer by querying the image in the given expr.
SpirvInstruction *processByteAddressBufferStructuredBufferGetDimensions(
const CXXMemberCallExpr *);
/// \brief Processes the Interlocked* intrinsic function call on a
/// RWByteAddressBuffer.
SpirvInstruction *
processRWByteAddressBufferAtomicMethods(hlsl::IntrinsicOp opcode,
const CXXMemberCallExpr *);
/// \brief Processes the GetSamplePosition intrinsic method call on a
/// Texture2DMS(Array).
SpirvInstruction *processGetSamplePosition(const CXXMemberCallExpr *);
/// \brief Processes the SubpassLoad intrinsic function call on a
/// SubpassInput(MS).
SpirvInstruction *processSubpassLoad(const CXXMemberCallExpr *);
/// \brief Generates SPIR-V instructions for the .Append()/.Consume() call on
/// the given {Append|Consume}StructuredBuffer. Returns the <result-id> of
/// the loaded value for .Consume; returns zero for .Append().
SpirvInstruction *
processACSBufferAppendConsume(const CXXMemberCallExpr *expr);
/// \brief Generates SPIR-V instructions to emit the current vertex in GS.
SpirvInstruction *processStreamOutputAppend(const CXXMemberCallExpr *expr);
/// \brief Generates SPIR-V instructions to end emitting the current
/// primitive in GS.
SpirvInstruction *processStreamOutputRestart(const CXXMemberCallExpr *expr);
/// \brief Emulates GetSamplePosition() for standard sample settings, i.e.,
/// with 1, 2, 4, 8, or 16 samples. Returns float2(0) for other cases.
SpirvInstruction *emitGetSamplePosition(SpirvInstruction *sampleCount,
SpirvInstruction *sampleIndex,
SourceLocation loc);
private:
/// \brief Takes a vector of size 4, and returns a vector of size 1 or 2 or 3
/// or 4. Creates a CompositeExtract or VectorShuffle instruction to extract
/// a scalar or smaller vector from the beginning of the input vector if
/// necessary. Assumes that 'fromId' is the <result-id> of a vector of size 4.
/// Panics if the target vector size is not 1, 2, 3, or 4.
SpirvInstruction *extractVecFromVec4(SpirvInstruction *fromInstr,
uint32_t targetVecSize,
QualType targetElemType,
SourceLocation loc);
/// \brief Creates SPIR-V instructions for sampling the given image.
/// It utilizes the ModuleBuilder's createImageSample and it ensures that the
/// returned type is handled correctly.
/// HLSL image sampling methods may return a scalar, vec1, vec2, vec3, or
/// vec4. But non-Dref image sampling instructions in SPIR-V must always
/// return a vec4. As a result, an extra processing step is necessary.
SpirvInstruction *
createImageSample(QualType retType, QualType imageType,
SpirvInstruction *image, SpirvInstruction *sampler,
SpirvInstruction *coordinate, SpirvInstruction *compareVal,
SpirvInstruction *bias, SpirvInstruction *lod,
std::pair<SpirvInstruction *, SpirvInstruction *> grad,
SpirvInstruction *constOffset, SpirvInstruction *varOffset,
SpirvInstruction *constOffsets, SpirvInstruction *sample,
SpirvInstruction *minLod, SpirvInstruction *residencyCodeId,
SourceLocation loc);
private:
/// \brief If the given FunctionDecl is not already in the workQueue, creates
/// a FunctionInfo object for it, and inserts it into the workQueue. It also
/// updates the functionInfoMap with the proper mapping.
void addFunctionToWorkQueue(hlsl::DXIL::ShaderKind,
const clang::FunctionDecl *,
bool isEntryFunction);
public:
/// \brief Wrapper method to create a fatal error message and report it
/// in the diagnostic engine associated with this consumer.
template <unsigned N>
DiagnosticBuilder emitFatalError(const char (&message)[N],
SourceLocation loc) {
const auto diagId =
diags.getCustomDiagID(clang::DiagnosticsEngine::Fatal, message);
return diags.Report(loc, diagId);
}
/// \brief Wrapper method to create an error message and report it
/// in the diagnostic engine associated with this consumer.
template <unsigned N>
DiagnosticBuilder emitError(const char (&message)[N], SourceLocation loc) {
const auto diagId =
diags.getCustomDiagID(clang::DiagnosticsEngine::Error, message);
return diags.Report(loc, diagId);
}
/// \brief Wrapper method to create a warning message and report it
/// in the diagnostic engine associated with this consumer
template <unsigned N>
DiagnosticBuilder emitWarning(const char (&message)[N], SourceLocation loc) {
const auto diagId =
diags.getCustomDiagID(clang::DiagnosticsEngine::Warning, message);
return diags.Report(loc, diagId);
}
/// \brief Wrapper method to create a note message and report it
/// in the diagnostic engine associated with this consumer
template <unsigned N>
DiagnosticBuilder emitNote(const char (&message)[N], SourceLocation loc) {
const auto diagId =
diags.getCustomDiagID(clang::DiagnosticsEngine::Note, message);
return diags.Report(loc, diagId);
}
private:
CompilerInstance &theCompilerInstance;
ASTContext &astContext;
DiagnosticsEngine &diags;
SpirvCodeGenOptions &spirvOptions;
/// \brief Entry function name, derived from the command line
/// and should be const.
const llvm::StringRef entryFunctionName;
/// \brief Structure to maintain record of all entry functions and any
/// reachable functions.
struct FunctionInfo {
public:
hlsl::ShaderModel::Kind shaderModelKind;
const DeclaratorDecl *funcDecl;
SpirvFunction *entryFunction;
bool isEntryFunction;
FunctionInfo() = default;
FunctionInfo(hlsl::ShaderModel::Kind smk, const DeclaratorDecl *fDecl,
SpirvFunction *entryFunc, bool isEntryFunc)
: shaderModelKind(smk), funcDecl(fDecl), entryFunction(entryFunc),
isEntryFunction(isEntryFunc) {}
};
SpirvContext spvContext;
FeatureManager featureManager;
SpirvBuilder spvBuilder;
DeclResultIdMapper declIdMapper;
/// \brief A map of funcDecl to its FunctionInfo. Consists of all entry
/// functions followed by all reachable functions from the entry functions.
llvm::DenseMap<const DeclaratorDecl *, FunctionInfo *> functionInfoMap;
/// A queue of FunctionInfo reachable from all the entry functions.
std::vector<const FunctionInfo *> workQueue;
/// <result-id> for the entry function. Initially it is zero and will be reset
/// when starting to translate the entry function.
SpirvFunction *entryFunction;
/// The current function under traversal.
const FunctionDecl *curFunction;
/// The SPIR-V function parameter for the current this object.
SpirvInstruction *curThis;
/// The source location of a push constant block we have previously seen.
/// Invalid means no push constant blocks defined thus far.
SourceLocation seenPushConstantAt;
/// Indicates whether the current emitter is in specialization constant mode:
/// all 32-bit scalar constants will be translated into OpSpecConstant.
bool isSpecConstantMode;
/// Whether the translated SPIR-V binary needs legalization.
///
/// The following cases will require legalization:
///
/// 1. Opaque types (textures, samplers) within structs
/// 2. Structured buffer aliasing
/// 3. Using SPIR-V instructions not allowed in the currect shader stage
///
/// This covers the first and third case.
///
/// If this is true, SPIRV-Tools legalization passes will be executed after
/// the translation to legalize the generated SPIR-V binary.
///
/// Note: legalization specific code
bool needsLegalization;
/// Whether the translated SPIR-V binary passes --before-hlsl-legalization
/// option to spirv-val because of illegal function parameter scope.
bool beforeHlslLegalization;
/// Mapping from methods to the decls to represent their implicit object
/// parameters
///
/// We need this map because that we need to update the associated counters on
/// the implicit object when invoking method calls. The ImplicitParamDecl
/// mapped to serves as a key to find the associated counters in
/// DeclResultIdMapper.
///
/// Note: legalization specific code
llvm::DenseMap<const CXXMethodDecl *, const ImplicitParamDecl *> thisDecls;
/// Global variables that should be initialized once at the begining of the
/// entry function.
llvm::SmallVector<const VarDecl *, 4> toInitGloalVars;
/// For loops, while loops, and switch statements may encounter "break"
/// statements that alter their control flow. At any point the break statement
/// is observed, the control flow jumps to the inner-most scope's merge block.
/// For instance: the break in the following example should cause a branch to
/// the SwitchMergeBB, not ForLoopMergeBB:
/// for (...) {
/// switch(...) {
/// case 1: break;
/// }
/// <--- SwitchMergeBB
/// }
/// <---- ForLoopMergeBB
/// This stack keeps track of the basic blocks to which branching could occur.
std::stack<SpirvBasicBlock *> breakStack;
/// Loops (do, while, for) may encounter "continue" statements that alter
/// their control flow. At any point the continue statement is observed, the
/// control flow jumps to the inner-most scope's continue block.
/// This stack keeps track of the basic blocks to which such branching could
/// occur.
std::stack<SpirvBasicBlock *> continueStack;
/// Maps a given statement to the basic block that is associated with it.
llvm::DenseMap<const Stmt *, SpirvBasicBlock *> stmtBasicBlock;
/// Maintains mapping from a type to SPIR-V variable along with SPIR-V
/// instruction for id of location decoration Used for raytracing stage
/// variables of storage class RayPayloadNV, CallableDataNV and
/// HitAttributeNV.
llvm::SmallDenseMap<QualType,
std::pair<SpirvInstruction *, SpirvInstruction *>, 4>
rayPayloadMap;
llvm::SmallDenseMap<QualType, SpirvInstruction *, 4> hitAttributeMap;
llvm::SmallDenseMap<QualType,
std::pair<SpirvInstruction *, SpirvInstruction *>, 4>
callDataMap;
/// Incoming ray payload for current entry function being translated.
/// Only valid for any-hit/closest-hit ray tracing shaders.
SpirvInstruction *currentRayPayload;
/// This is the Patch Constant Function. This function is not explicitly
/// called from the entry point function.
FunctionDecl *patchConstFunc;
/// The <result-id> of the OpString containing the main source file's path.
SpirvString *mainSourceFile;
};
void SpirvEmitter::doDeclStmt(const DeclStmt *declStmt) {
for (auto *decl : declStmt->decls())
doDecl(decl);
}
} // end namespace spirv
} // end namespace clang
#endif
| 47.474359 | 80 | 0.689009 | [
"mesh",
"geometry",
"object",
"vector"
] |
b144042729608fe2780944ab521dd7937b5e072d | 6,199 | h | C | include/visnav/matching_utils.h | vingoh/visual_odometry | c1fbcfbf818a2701327849ee3b7387adae372185 | [
"BSD-3-Clause"
] | null | null | null | include/visnav/matching_utils.h | vingoh/visual_odometry | c1fbcfbf818a2701327849ee3b7387adae372185 | [
"BSD-3-Clause"
] | null | null | null | include/visnav/matching_utils.h | vingoh/visual_odometry | c1fbcfbf818a2701327849ee3b7387adae372185 | [
"BSD-3-Clause"
] | null | null | null | /**
BSD 3-Clause License
Copyright (c) 2018, Vladyslav Usenko and Nikolaus Demmel.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <bitset>
#include <set>
#include <Eigen/Dense>
#include <sophus/se3.hpp>
#include <opengv/relative_pose/CentralRelativeAdapter.hpp>
#include <opengv/relative_pose/methods.hpp>
#include <opengv/sac/Ransac.hpp>
#include <opengv/sac_problems/relative_pose/CentralRelativePoseSacProblem.hpp>
#include <visnav/camera_models.h>
#include <visnav/common_types.h>
using namespace opengv;
namespace visnav {
void computeEssential(const Sophus::SE3d& T_0_1, Eigen::Matrix3d& E) {
const Eigen::Vector3d t_0_1 = T_0_1.translation();
const Eigen::Matrix3d R_0_1 = T_0_1.rotationMatrix();
// TODO SHEET 3: compute essential matrix
UNUSED(E);
UNUSED(t_0_1);
UNUSED(R_0_1);
Eigen::Matrix3d t_cap = Sophus::SO3<double>::hat(t_0_1.normalized());
E = t_cap * R_0_1;
}
void findInliersEssential(const KeypointsData& kd1, const KeypointsData& kd2,
const std::shared_ptr<AbstractCamera<double>>& cam1,
const std::shared_ptr<AbstractCamera<double>>& cam2,
const Eigen::Matrix3d& E,
double epipolar_error_threshold, MatchData& md) {
md.inliers.clear();
for (size_t j = 0; j < md.matches.size(); j++) {
const Eigen::Vector2d p0_2d = kd1.corners[md.matches[j].first];
const Eigen::Vector2d p1_2d = kd2.corners[md.matches[j].second];
// TODO SHEET 3: determine inliers and store in md.inliers
UNUSED(cam1);
UNUSED(cam2);
UNUSED(E);
UNUSED(epipolar_error_threshold);
UNUSED(p0_2d);
UNUSED(p1_2d);
double err =
cam1->unproject(p0_2d).transpose() * E * cam2->unproject(p1_2d);
if (abs(err) < epipolar_error_threshold)
md.inliers.push_back(
make_pair(md.matches[j].first, md.matches[j].second));
}
}
void findInliersRansac(const KeypointsData& kd1, const KeypointsData& kd2,
const std::shared_ptr<AbstractCamera<double>>& cam1,
const std::shared_ptr<AbstractCamera<double>>& cam2,
const double ransac_thresh, const int ransac_min_inliers,
MatchData& md) {
md.inliers.clear();
md.T_i_j = Sophus::SE3d();
// TODO SHEET 3: Run RANSAC with using opengv's CentralRelativePose and store
// the final inlier indices in md.inliers and the final relative pose in
// md.T_i_j (normalize translation). If the number of inliers is smaller than
// ransac_min_inliers, leave md.inliers empty. Note that if the initial RANSAC
// was successful, you should do non-linear refinement of the model parameters
// using all inliers, and then re-estimate the inlier set with the refined
// model parameters.
UNUSED(kd1);
UNUSED(kd2);
UNUSED(cam1);
UNUSED(cam2);
UNUSED(ransac_thresh);
UNUSED(ransac_min_inliers);
bearingVectors_t bVectors1, bVectors2;
for (size_t i = 0; i < md.matches.size(); i++) {
bearingVector_t bvec1 = cam1->unproject(kd1.corners[md.matches[i].first]);
bearingVector_t bvec2 = cam2->unproject(kd2.corners[md.matches[i].second]);
bVectors1.push_back(bvec1);
bVectors2.push_back(bvec2);
}
relative_pose::CentralRelativeAdapter adapter(bVectors1, bVectors2);
// create a RANSAC object
sac::Ransac<sac_problems::relative_pose::CentralRelativePoseSacProblem>
ransac;
// create a CentralRelativePoseSacProblem
// (set algorithm to STEWENIUS, NISTER, SEVENPT, or EIGHTPT)
std::shared_ptr<sac_problems::relative_pose::CentralRelativePoseSacProblem>
relposeproblem_ptr(
new sac_problems::relative_pose::CentralRelativePoseSacProblem(
adapter, sac_problems::relative_pose::
CentralRelativePoseSacProblem::NISTER));
// run ransac
ransac.sac_model_ = relposeproblem_ptr;
ransac.threshold_ = ransac_thresh;
ransac.max_iterations_ = 50;
ransac.computeModel();
transformation_t new_transformation =
relative_pose::optimize_nonlinear(adapter, ransac.inliers_);
// optimize transformation using inliers
Eigen::Matrix3d R = new_transformation.block(0, 0, 3, 3);
Eigen::Matrix<double, 3, 1> t = new_transformation.block(0, 3, 3, 1);
Sophus::SE3d T(R, t.normalized());
md.T_i_j = T;
// compute inliers again using new T, trying to replace adapter
vector<int> inliers_indices;
ransac.sac_model_->selectWithinDistance(new_transformation, ransac_thresh,
inliers_indices);
if (int(inliers_indices.size()) > ransac_min_inliers) {
for (size_t i = 0; i < inliers_indices.size(); i++)
md.inliers.push_back(md.matches[inliers_indices[i]]);
}
}
} // namespace visnav
| 38.503106 | 80 | 0.71931 | [
"object",
"vector",
"model"
] |
b1440b83ef59b24fcc03d66ba7f8561abee4737a | 30,233 | h | C | tests/test_class_db.h | perezdouglas935/godot | 4236d8a37136c9127184c1182372bca96de23ebb | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | null | null | null | tests/test_class_db.h | perezdouglas935/godot | 4236d8a37136c9127184c1182372bca96de23ebb | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | null | null | null | tests/test_class_db.h | perezdouglas935/godot | 4236d8a37136c9127184c1182372bca96de23ebb | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | null | null | null | /*************************************************************************/
/* test_class_db.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef TEST_CLASS_DB_H
#define TEST_CLASS_DB_H
#include "core/register_core_types.h"
#include "core/core_constants.h"
#include "core/os/os.h"
#include "core/string/string_name.h"
#include "core/string/ustring.h"
#include "core/templates/ordered_hash_map.h"
#include "core/variant/variant.h"
#include "tests/test_macros.h"
namespace TestClassDB {
struct TypeReference {
StringName name;
bool is_enum = false;
};
struct ConstantData {
String name;
int value = 0;
};
struct EnumData {
StringName name;
List<ConstantData> constants;
_FORCE_INLINE_ bool operator==(const EnumData &p_enum) const {
return p_enum.name == name;
}
};
struct PropertyData {
StringName name;
int index = 0;
StringName getter;
StringName setter;
};
struct ArgumentData {
TypeReference type;
String name;
bool has_defval = false;
Variant defval;
};
struct MethodData {
StringName name;
TypeReference return_type;
List<ArgumentData> arguments;
bool is_virtual = false;
bool is_vararg = false;
};
struct SignalData {
StringName name;
List<ArgumentData> arguments;
};
struct ExposedClass {
StringName name;
StringName base;
bool is_singleton = false;
bool is_instantiable = false;
bool is_reference = false;
ClassDB::APIType api_type;
List<ConstantData> constants;
List<EnumData> enums;
List<PropertyData> properties;
List<MethodData> methods;
List<SignalData> signals_;
const PropertyData *find_property_by_name(const StringName &p_name) const {
for (const List<PropertyData>::Element *E = properties.front(); E; E = E->next()) {
if (E->get().name == p_name) {
return &E->get();
}
}
return nullptr;
}
const MethodData *find_method_by_name(const StringName &p_name) const {
for (const List<MethodData>::Element *E = methods.front(); E; E = E->next()) {
if (E->get().name == p_name) {
return &E->get();
}
}
return nullptr;
}
};
struct NamesCache {
StringName variant_type = StaticCString::create("Variant");
StringName object_class = StaticCString::create("Object");
StringName reference_class = StaticCString::create("Reference");
StringName string_type = StaticCString::create("String");
StringName string_name_type = StaticCString::create("StringName");
StringName node_path_type = StaticCString::create("NodePath");
StringName bool_type = StaticCString::create("bool");
StringName int_type = StaticCString::create("int");
StringName float_type = StaticCString::create("float");
StringName void_type = StaticCString::create("void");
StringName vararg_stub_type = StaticCString::create("@VarArg@");
StringName vector2_type = StaticCString::create("Vector2");
StringName rect2_type = StaticCString::create("Rect2");
StringName vector3_type = StaticCString::create("Vector3");
// Object not included as it must be checked for all derived classes
static constexpr int nullable_types_count = 17;
StringName nullable_types[nullable_types_count] = {
string_type,
string_name_type,
node_path_type,
StaticCString::create(_STR(Array)),
StaticCString::create(_STR(Dictionary)),
StaticCString::create(_STR(Callable)),
StaticCString::create(_STR(Signal)),
StaticCString::create(_STR(PackedByteArray)),
StaticCString::create(_STR(PackedInt32Array)),
StaticCString::create(_STR(PackedInt64rray)),
StaticCString::create(_STR(PackedFloat32Array)),
StaticCString::create(_STR(PackedFloat64Array)),
StaticCString::create(_STR(PackedStringArray)),
StaticCString::create(_STR(PackedVector2Array)),
StaticCString::create(_STR(PackedVector3Array)),
StaticCString::create(_STR(PackedColorArray)),
};
bool is_nullable_type(const StringName &p_type) const {
for (int i = 0; i < nullable_types_count; i++) {
if (p_type == nullable_types[i]) {
return true;
}
}
return false;
}
};
typedef OrderedHashMap<StringName, ExposedClass> ExposedClasses;
struct Context {
Vector<StringName> enum_types;
Vector<StringName> builtin_types;
ExposedClasses exposed_classes;
List<EnumData> global_enums;
NamesCache names_cache;
const ExposedClass *find_exposed_class(const StringName &p_name) const {
ExposedClasses::ConstElement elem = exposed_classes.find(p_name);
return elem ? &elem.value() : nullptr;
}
const ExposedClass *find_exposed_class(const TypeReference &p_type_ref) const {
ExposedClasses::ConstElement elem = exposed_classes.find(p_type_ref.name);
return elem ? &elem.value() : nullptr;
}
bool has_type(const TypeReference &p_type_ref) const {
if (builtin_types.find(p_type_ref.name) >= 0) {
return true;
}
if (p_type_ref.is_enum) {
if (enum_types.find(p_type_ref.name) >= 0) {
return true;
}
// Enum not found. Most likely because none of its constants were bound, so it's empty. That's fine. Use int instead.
return builtin_types.find(names_cache.int_type);
}
return false;
}
};
bool arg_default_value_is_assignable_to_type(const Context &p_context, const Variant &p_val, const TypeReference &p_arg_type, String *r_err_msg = nullptr) {
if (p_arg_type.name == p_context.names_cache.variant_type) {
// Variant can take anything
return true;
}
switch (p_val.get_type()) {
case Variant::NIL:
return p_context.find_exposed_class(p_arg_type) ||
p_context.names_cache.is_nullable_type(p_arg_type.name);
case Variant::BOOL:
return p_arg_type.name == p_context.names_cache.bool_type;
case Variant::INT:
return p_arg_type.name == p_context.names_cache.int_type ||
p_arg_type.name == p_context.names_cache.float_type ||
p_arg_type.is_enum;
case Variant::FLOAT:
return p_arg_type.name == p_context.names_cache.float_type;
case Variant::STRING:
case Variant::STRING_NAME:
return p_arg_type.name == p_context.names_cache.string_type ||
p_arg_type.name == p_context.names_cache.string_name_type ||
p_arg_type.name == p_context.names_cache.node_path_type;
case Variant::NODE_PATH:
return p_arg_type.name == p_context.names_cache.node_path_type;
case Variant::TRANSFORM:
case Variant::TRANSFORM2D:
case Variant::BASIS:
case Variant::QUAT:
case Variant::PLANE:
case Variant::AABB:
case Variant::COLOR:
case Variant::VECTOR2:
case Variant::RECT2:
case Variant::VECTOR3:
case Variant::RID:
case Variant::ARRAY:
case Variant::DICTIONARY:
case Variant::PACKED_BYTE_ARRAY:
case Variant::PACKED_INT32_ARRAY:
case Variant::PACKED_INT64_ARRAY:
case Variant::PACKED_FLOAT32_ARRAY:
case Variant::PACKED_FLOAT64_ARRAY:
case Variant::PACKED_STRING_ARRAY:
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
case Variant::CALLABLE:
case Variant::SIGNAL:
return p_arg_type.name == Variant::get_type_name(p_val.get_type());
case Variant::OBJECT:
return p_context.find_exposed_class(p_arg_type);
case Variant::VECTOR2I:
return p_arg_type.name == p_context.names_cache.vector2_type ||
p_arg_type.name == Variant::get_type_name(p_val.get_type());
case Variant::RECT2I:
return p_arg_type.name == p_context.names_cache.rect2_type ||
p_arg_type.name == Variant::get_type_name(p_val.get_type());
case Variant::VECTOR3I:
return p_arg_type.name == p_context.names_cache.vector3_type ||
p_arg_type.name == Variant::get_type_name(p_val.get_type());
default:
if (r_err_msg) {
*r_err_msg = "Unexpected Variant type: " + itos(p_val.get_type());
}
break;
}
return false;
}
void validate_property(const Context &p_context, const ExposedClass &p_class, const PropertyData &p_prop) {
const MethodData *setter = p_class.find_method_by_name(p_prop.setter);
// Search it in base classes too
const ExposedClass *top = &p_class;
while (!setter && top->base != StringName()) {
top = p_context.find_exposed_class(top->base);
TEST_FAIL_COND(!top, "Class not found '", top->base, "'. Inherited by '", top->name, "'.");
setter = top->find_method_by_name(p_prop.setter);
}
const MethodData *getter = p_class.find_method_by_name(p_prop.getter);
// Search it in base classes too
top = &p_class;
while (!getter && top->base != StringName()) {
top = p_context.find_exposed_class(top->base);
TEST_FAIL_COND(!top, "Class not found '", top->base, "'. Inherited by '", top->name, "'.");
getter = top->find_method_by_name(p_prop.getter);
}
TEST_FAIL_COND((!setter && !getter),
"Couldn't find neither the setter nor the getter for property: '", p_class.name, ".", String(p_prop.name), "'.");
if (setter) {
int setter_argc = p_prop.index != -1 ? 2 : 1;
TEST_FAIL_COND(setter->arguments.size() != setter_argc,
"Invalid property setter argument count: '", p_class.name, ".", String(p_prop.name), "'.");
}
if (getter) {
int getter_argc = p_prop.index != -1 ? 1 : 0;
TEST_FAIL_COND(getter->arguments.size() != getter_argc,
"Invalid property setter argument count: '", p_class.name, ".", String(p_prop.name), "'.");
}
if (getter && setter) {
const ArgumentData &setter_first_arg = setter->arguments.back()->get();
if (getter->return_type.name != setter_first_arg.type.name) {
// Special case for Node::set_name
bool whitelisted = getter->return_type.name == p_context.names_cache.string_name_type &&
setter_first_arg.type.name == p_context.names_cache.string_type;
TEST_FAIL_COND(!whitelisted,
"Return type from getter doesn't match first argument of setter, for property: '", p_class.name, ".", String(p_prop.name), "'.");
}
}
const TypeReference &prop_type_ref = getter ? getter->return_type : setter->arguments.back()->get().type;
const ExposedClass *prop_class = p_context.find_exposed_class(prop_type_ref);
if (prop_class) {
TEST_COND(prop_class->is_singleton,
"Property type is a singleton: '", p_class.name, ".", String(p_prop.name), "'.");
} else {
TEST_FAIL_COND(!p_context.has_type(prop_type_ref),
"Property type '", prop_type_ref.name, "' not found: '", p_class.name, ".", String(p_prop.name), "'.");
}
if (getter) {
if (p_prop.index != -1) {
const ArgumentData &idx_arg = getter->arguments.front()->get();
if (idx_arg.type.name != p_context.names_cache.int_type) {
// If not an int, it can be an enum
TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0,
"Invalid type '", idx_arg.type.name, "' for index argument of property getter: '", p_class.name, ".", String(p_prop.name), "'.");
}
}
}
if (setter) {
if (p_prop.index != -1) {
const ArgumentData &idx_arg = setter->arguments.front()->get();
if (idx_arg.type.name != p_context.names_cache.int_type) {
// Assume the index parameter is an enum
// If not an int, it can be an enum
TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0,
"Invalid type '", idx_arg.type.name, "' for index argument of property setter: '", p_class.name, ".", String(p_prop.name), "'.");
}
}
}
}
void validate_method(const Context &p_context, const ExposedClass &p_class, const MethodData &p_method) {
const ExposedClass *return_class = p_context.find_exposed_class(p_method.return_type);
if (return_class) {
TEST_COND(return_class->is_singleton,
"Method return type is a singleton: '", p_class.name, ".", p_method.name, "'.");
}
for (const List<ArgumentData>::Element *F = p_method.arguments.front(); F; F = F->next()) {
const ArgumentData &arg = F->get();
const ExposedClass *arg_class = p_context.find_exposed_class(arg.type);
if (arg_class) {
TEST_COND(arg_class->is_singleton,
"Argument type is a singleton: '", arg.name, "' of method '", p_class.name, ".", p_method.name, "'.");
} else {
TEST_FAIL_COND(!p_context.has_type(arg.type),
"Argument type '", arg.type.name, "' not found: '", arg.name, "' of method", p_class.name, ".", p_method.name, "'.");
}
if (arg.has_defval) {
String type_error_msg;
bool arg_defval_assignable_to_type = arg_default_value_is_assignable_to_type(p_context, arg.defval, arg.type, &type_error_msg);
String err_msg = vformat("Invalid default value for parameter '%s' of method '%s.%s'.", arg.name, p_class.name, p_method.name);
if (!type_error_msg.is_empty()) {
err_msg += " " + type_error_msg;
}
TEST_COND(!arg_defval_assignable_to_type, err_msg.utf8().get_data());
}
}
}
void validate_signal(const Context &p_context, const ExposedClass &p_class, const SignalData &p_signal) {
for (const List<ArgumentData>::Element *F = p_signal.arguments.front(); F; F = F->next()) {
const ArgumentData &arg = F->get();
const ExposedClass *arg_class = p_context.find_exposed_class(arg.type);
if (arg_class) {
TEST_COND(arg_class->is_singleton,
"Argument class is a singleton: '", arg.name, "' of signal", p_class.name, ".", p_signal.name, "'.");
} else {
TEST_FAIL_COND(!p_context.has_type(arg.type),
"Argument type '", arg.type.name, "' not found: '", arg.name, "' of signal", p_class.name, ".", p_signal.name, "'.");
}
}
}
void validate_class(const Context &p_context, const ExposedClass &p_exposed_class) {
bool is_derived_type = p_exposed_class.base != StringName();
if (!is_derived_type) {
// Asserts about the base Object class
TEST_FAIL_COND(p_exposed_class.name != p_context.names_cache.object_class,
"Class '", p_exposed_class.name, "' has no base class.");
TEST_FAIL_COND(!p_exposed_class.is_instantiable,
"Object class is not instantiable.");
TEST_FAIL_COND(p_exposed_class.api_type != ClassDB::API_CORE,
"Object class is API is not API_CORE.");
TEST_FAIL_COND(p_exposed_class.is_singleton,
"Object class is registered as a singleton.");
}
TEST_FAIL_COND((p_exposed_class.is_singleton && p_exposed_class.base != p_context.names_cache.object_class),
"Singleton base class '", String(p_exposed_class.base), "' is not Object, for class '", p_exposed_class.name, "'.");
TEST_FAIL_COND((is_derived_type && !p_context.exposed_classes.has(p_exposed_class.base)),
"Base type '", p_exposed_class.base.operator String(), "' does not exist, for class '", p_exposed_class.name, "'.");
for (const List<PropertyData>::Element *F = p_exposed_class.properties.front(); F; F = F->next()) {
validate_property(p_context, p_exposed_class, F->get());
}
for (const List<MethodData>::Element *F = p_exposed_class.methods.front(); F; F = F->next()) {
validate_method(p_context, p_exposed_class, F->get());
}
for (const List<SignalData>::Element *F = p_exposed_class.signals_.front(); F; F = F->next()) {
validate_signal(p_context, p_exposed_class, F->get());
}
}
void add_exposed_classes(Context &r_context) {
List<StringName> class_list;
ClassDB::get_class_list(&class_list);
class_list.sort_custom<StringName::AlphCompare>();
while (class_list.size()) {
StringName class_name = class_list.front()->get();
ClassDB::APIType api_type = ClassDB::get_api_type(class_name);
if (api_type == ClassDB::API_NONE) {
class_list.pop_front();
continue;
}
if (!ClassDB::is_class_exposed(class_name)) {
MESSAGE(vformat("Ignoring class '%s' because it's not exposed.", class_name).utf8().get_data());
class_list.pop_front();
continue;
}
if (!ClassDB::is_class_enabled(class_name)) {
MESSAGE(vformat("Ignoring class '%s' because it's not enabled.", class_name).utf8().get_data());
class_list.pop_front();
continue;
}
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(class_name);
ExposedClass exposed_class;
exposed_class.name = class_name;
exposed_class.api_type = api_type;
exposed_class.is_singleton = Engine::get_singleton()->has_singleton(class_name);
exposed_class.is_instantiable = class_info->creation_func && !exposed_class.is_singleton;
exposed_class.is_reference = ClassDB::is_parent_class(class_name, "Reference");
exposed_class.base = ClassDB::get_parent_class(class_name);
// Add properties
List<PropertyInfo> property_list;
ClassDB::get_property_list(class_name, &property_list, true);
Map<StringName, StringName> accessor_methods;
for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
const PropertyInfo &property = E->get();
if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) {
continue;
}
PropertyData prop;
prop.name = property.name;
prop.setter = ClassDB::get_property_setter(class_name, prop.name);
prop.getter = ClassDB::get_property_getter(class_name, prop.name);
if (prop.setter != StringName()) {
accessor_methods[prop.setter] = prop.name;
}
if (prop.getter != StringName()) {
accessor_methods[prop.getter] = prop.name;
}
bool valid = false;
prop.index = ClassDB::get_property_index(class_name, prop.name, &valid);
TEST_FAIL_COND(!valid, "Invalid property: '", exposed_class.name, ".", String(prop.name), "'.");
exposed_class.properties.push_back(prop);
}
// Add methods
List<MethodInfo> virtual_method_list;
ClassDB::get_virtual_methods(class_name, &virtual_method_list, true);
List<MethodInfo> method_list;
ClassDB::get_method_list(class_name, &method_list, true);
method_list.sort();
for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
const MethodInfo &method_info = E->get();
int argc = method_info.arguments.size();
if (method_info.name.is_empty()) {
continue;
}
MethodData method;
method.name = method_info.name;
if (method_info.flags & METHOD_FLAG_VIRTUAL) {
method.is_virtual = true;
}
PropertyInfo return_info = method_info.return_val;
MethodBind *m = method.is_virtual ? nullptr : ClassDB::get_method(class_name, method_info.name);
method.is_vararg = m && m->is_vararg();
if (!m && !method.is_virtual) {
TEST_FAIL_COND(!virtual_method_list.find(method_info),
"Missing MethodBind for non-virtual method: '", exposed_class.name, ".", method.name, "'.");
// A virtual method without the virtual flag. This is a special case.
// The method Object.free is registered as a virtual method, but without the virtual flag.
// This is because this method is not supposed to be overridden, but called.
// We assume the return type is void.
method.return_type.name = r_context.names_cache.void_type;
// Actually, more methods like this may be added in the future, which could return
// something different. Let's put this check to notify us if that ever happens.
String warn_msg = vformat(
"Notification: New unexpected virtual non-overridable method found. "
"We only expected Object.free, but found '%s.%s'.",
exposed_class.name, method.name);
TEST_FAIL_COND_WARN(
(exposed_class.name != r_context.names_cache.object_class || String(method.name) != "free"),
warn_msg.utf8().get_data());
} else if (return_info.type == Variant::INT && return_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
method.return_type.name = return_info.class_name;
method.return_type.is_enum = true;
} else if (return_info.class_name != StringName()) {
method.return_type.name = return_info.class_name;
bool bad_reference_hint = !method.is_virtual && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE &&
ClassDB::is_parent_class(return_info.class_name, r_context.names_cache.reference_class);
TEST_COND(bad_reference_hint, "Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'.", " Are you returning a reference type by pointer? Method: '",
exposed_class.name, ".", method.name, "'.");
} else if (return_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
method.return_type.name = return_info.hint_string;
} else if (return_info.type == Variant::NIL && return_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT) {
method.return_type.name = r_context.names_cache.variant_type;
} else if (return_info.type == Variant::NIL) {
method.return_type.name = r_context.names_cache.void_type;
} else {
// NOTE: We don't care about the size and sign of int and float in these tests
method.return_type.name = Variant::get_type_name(return_info.type);
}
for (int i = 0; i < argc; i++) {
PropertyInfo arg_info = method_info.arguments[i];
String orig_arg_name = arg_info.name;
ArgumentData arg;
arg.name = orig_arg_name;
if (arg_info.type == Variant::INT && arg_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
arg.type.name = arg_info.class_name;
arg.type.is_enum = true;
} else if (arg_info.class_name != StringName()) {
arg.type.name = arg_info.class_name;
} else if (arg_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
arg.type.name = arg_info.hint_string;
} else if (arg_info.type == Variant::NIL) {
arg.type.name = r_context.names_cache.variant_type;
} else {
// NOTE: We don't care about the size and sign of int and float in these tests
arg.type.name = Variant::get_type_name(arg_info.type);
}
if (m && m->has_default_argument(i)) {
arg.has_defval = true;
arg.defval = m->get_default_argument(i);
}
method.arguments.push_back(arg);
}
if (method.is_vararg) {
ArgumentData vararg;
vararg.type.name = r_context.names_cache.vararg_stub_type;
vararg.name = "@varargs@";
method.arguments.push_back(vararg);
}
TEST_COND(exposed_class.find_property_by_name(method.name),
"Method name conflicts with property: '", String(class_name), ".", String(method.name), "'.");
// Classes starting with an underscore are ignored unless they're used as a property setter or getter
if (!method.is_virtual && String(method.name)[0] == '_') {
for (const List<PropertyData>::Element *F = exposed_class.properties.front(); F; F = F->next()) {
const PropertyData &prop = F->get();
if (prop.setter == method.name || prop.getter == method.name) {
exposed_class.methods.push_back(method);
break;
}
}
} else {
exposed_class.methods.push_back(method);
}
}
// Add signals
const HashMap<StringName, MethodInfo> &signal_map = class_info->signal_map;
const StringName *k = nullptr;
while ((k = signal_map.next(k))) {
SignalData signal;
const MethodInfo &method_info = signal_map.get(*k);
signal.name = method_info.name;
int argc = method_info.arguments.size();
for (int i = 0; i < argc; i++) {
PropertyInfo arg_info = method_info.arguments[i];
String orig_arg_name = arg_info.name;
ArgumentData arg;
arg.name = orig_arg_name;
if (arg_info.type == Variant::INT && arg_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
arg.type.name = arg_info.class_name;
arg.type.is_enum = true;
} else if (arg_info.class_name != StringName()) {
arg.type.name = arg_info.class_name;
} else if (arg_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
arg.type.name = arg_info.hint_string;
} else if (arg_info.type == Variant::NIL) {
arg.type.name = r_context.names_cache.variant_type;
} else {
// NOTE: We don't care about the size and sign of int and float in these tests
arg.type.name = Variant::get_type_name(arg_info.type);
}
signal.arguments.push_back(arg);
}
bool method_conflict = exposed_class.find_property_by_name(signal.name);
// TODO:
// ClassDB allows signal names that conflict with method or property names.
// However registering a signal with a conflicting name is still considered wrong.
// Unfortunately there are some existing cases that are yet to be fixed.
// Until those are fixed we will print a warning instead of failing the test.
String warn_msg = vformat(
"Signal name conflicts with %s: '%s.%s.",
method_conflict ? "method" : "property", class_name, signal.name);
TEST_FAIL_COND_WARN((method_conflict || exposed_class.find_method_by_name(signal.name)),
warn_msg.utf8().get_data());
exposed_class.signals_.push_back(signal);
}
// Add enums and constants
List<String> constants;
ClassDB::get_integer_constant_list(class_name, &constants, true);
const HashMap<StringName, List<StringName>> &enum_map = class_info->enum_map;
k = nullptr;
while ((k = enum_map.next(k))) {
EnumData enum_;
enum_.name = *k;
const List<StringName> &enum_constants = enum_map.get(*k);
for (const List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) {
const StringName &constant_name = E->get();
int *value = class_info->constant_map.getptr(constant_name);
TEST_FAIL_COND(!value, "Missing enum constant value: '",
String(class_name), ".", String(enum_.name), ".", String(constant_name), "'.");
constants.erase(constant_name);
ConstantData constant;
constant.name = constant_name;
constant.value = *value;
enum_.constants.push_back(constant);
}
exposed_class.enums.push_back(enum_);
r_context.enum_types.push_back(String(class_name) + "." + String(*k));
}
for (const List<String>::Element *E = constants.front(); E; E = E->next()) {
const String &constant_name = E->get();
int *value = class_info->constant_map.getptr(StringName(E->get()));
TEST_FAIL_COND(!value, "Missing enum constant value: '", String(class_name), ".", String(constant_name), "'.");
ConstantData constant;
constant.name = constant_name;
constant.value = *value;
exposed_class.constants.push_back(constant);
}
r_context.exposed_classes.insert(class_name, exposed_class);
class_list.pop_front();
}
}
void add_builtin_types(Context &r_context) {
// NOTE: We don't care about the size and sign of int and float in these tests
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
r_context.builtin_types.push_back(Variant::get_type_name(Variant::Type(i)));
}
r_context.builtin_types.push_back(_STR(Variant));
r_context.builtin_types.push_back(r_context.names_cache.vararg_stub_type);
r_context.builtin_types.push_back("void");
}
void add_global_enums(Context &r_context) {
int global_constants_count = CoreConstants::get_global_constant_count();
if (global_constants_count > 0) {
for (int i = 0; i < global_constants_count; i++) {
StringName enum_name = CoreConstants::get_global_constant_enum(i);
if (enum_name != StringName()) {
ConstantData constant;
constant.name = CoreConstants::get_global_constant_name(i);
constant.value = CoreConstants::get_global_constant_value(i);
EnumData enum_;
enum_.name = enum_name;
List<EnumData>::Element *enum_match = r_context.global_enums.find(enum_);
if (enum_match) {
enum_match->get().constants.push_back(constant);
} else {
enum_.constants.push_back(constant);
r_context.global_enums.push_back(enum_);
}
}
}
for (List<EnumData>::Element *E = r_context.global_enums.front(); E; E = E->next()) {
r_context.enum_types.push_back(E->get().name);
}
}
// HARDCODED
List<StringName> hardcoded_enums;
hardcoded_enums.push_back("Vector2.Axis");
hardcoded_enums.push_back("Vector2i.Axis");
hardcoded_enums.push_back("Vector3.Axis");
hardcoded_enums.push_back("Vector3i.Axis");
for (List<StringName>::Element *E = hardcoded_enums.front(); E; E = E->next()) {
// These enums are not generated and must be written manually (e.g.: Vector3.Axis)
// Here, we assume core types do not begin with underscore
r_context.enum_types.push_back(E->get());
}
}
TEST_SUITE("[ClassDB]") {
TEST_CASE("[ClassDB] Add exposed classes, builtin types, and global enums") {
Context context;
add_exposed_classes(context);
add_builtin_types(context);
add_global_enums(context);
SUBCASE("[ClassDB] Find exposed class") {
const ExposedClass *object_class = context.find_exposed_class(context.names_cache.object_class);
TEST_FAIL_COND(!object_class, "Object class not found.");
TEST_FAIL_COND(object_class->base != StringName(),
"Object class derives from another class: '", object_class->base, "'.");
for (ExposedClasses::Element E = context.exposed_classes.front(); E; E = E.next()) {
validate_class(context, E.value());
}
}
}
}
} // namespace TestClassDB
#endif // TEST_CLASS_DB_H
| 36.425301 | 179 | 0.691695 | [
"object",
"vector",
"transform"
] |
b144eca7de50926366aaf882585def505a257754 | 10,643 | h | C | include/git2/odb.h | acured/Test | 765a62975b8933e35be70105fd14043ee336e958 | [
"Apache-2.0"
] | null | null | null | include/git2/odb.h | acured/Test | 765a62975b8933e35be70105fd14043ee336e958 | [
"Apache-2.0"
] | null | null | null | include/git2/odb.h | acured/Test | 765a62975b8933e35be70105fd14043ee336e958 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (C) 2009-2011 the libgit2 contributors
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_git_odb_h__
#define INCLUDE_git_odb_h__
#include "common.h"
#include "types.h"
#include "oid.h"
#include "odb_backend.h"
/**
* @file git2/odb.h
* @brief Git object database routines
* @defgroup git_odb Git object database routines
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL
/**
* Create a new object database with no backends.
*
* Before the ODB can be used for read/writing, a custom database
* backend must be manually added using `git_odb_add_backend()`
*
* @param out location to store the database pointer, if opened.
* Set to NULL if the open failed.
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN(int) git_odb_new(git_odb **out);
/**
* Create a new object database and automatically add
* the two default backends:
*
* - git_odb_backend_loose: read and write loose object files
* from disk, assuming `objects_dir` as the Objects folder
*
* - git_odb_backend_pack: read objects from packfiles,
* assuming `objects_dir` as the Objects folder which
* contains a 'pack/' folder with the corresponding data
*
* @param out location to store the database pointer, if opened.
* Set to NULL if the open failed.
* @param objects_dir path of the backends' "objects" directory.
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir);
/**
* Add a custom backend to an existing Object DB
*
* The backends are checked in relative ordering, based on the
* value of the `priority` parameter.
*
* Read <odb_backends.h> for more information.
*
* @param odb database to add the backend to
* @param backend pointer to a git_odb_backend instance
* @param priority Value for ordering the backends queue
* @return 0 on sucess; error code otherwise
*/
GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority);
/**
* Add a custom backend to an existing Object DB; this
* backend will work as an alternate.
*
* Alternate backends are always checked for objects *after*
* all the main backends have been exhausted.
*
* The backends are checked in relative ordering, based on the
* value of the `priority` parameter.
*
* Writing is disabled on alternate backends.
*
* Read <odb_backends.h> for more information.
*
* @param odb database to add the backend to
* @param backend pointer to a git_odb_backend instance
* @param priority Value for ordering the backends queue
* @return 0 on sucess; error code otherwise
*/
GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
/**
* Close an open object database.
*
* @param db database pointer to close. If NULL no action is taken.
*/
GIT_EXTERN(void) git_odb_free(git_odb *db);
/**
* Read an object from the database.
*
* This method queries all available ODB backends
* trying to read the given OID.
*
* The returned object is reference counted and
* internally cached, so it should be closed
* by the user once it's no longer in use.
*
* @param out pointer where to store the read object
* @param db database to search for the object in.
* @param id identity of the object to read.
* @return
* - GIT_SUCCESS if the object was read;
* - GIT_ENOTFOUND if the object is not in the database.
*/
GIT_EXTERN(int) git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id);
/**
* Read an object from the database, given a prefix
* of its identifier.
*
* This method queries all available ODB backends
* trying to match the 'len' first hexadecimal
* characters of the 'short_id'.
* The remaining (GIT_OID_HEXSZ-len)*4 bits of
* 'short_id' must be 0s.
* 'len' must be at least GIT_OID_MINPREFIXLEN,
* and the prefix must be long enough to identify
* a unique object in all the backends; the
* method will fail otherwise.
*
* The returned object is reference counted and
* internally cached, so it should be closed
* by the user once it's no longer in use.
*
* @param out pointer where to store the read object
* @param db database to search for the object in.
* @param short_id a prefix of the id of the object to read.
* @param len the length of the prefix
* @return GIT_SUCCESS if the object was read;
* GIT_ENOTFOUND if the object is not in the database.
* GIT_EAMBIGUOUS if the prefix is ambiguous (several objects match the prefix)
*/
GIT_EXTERN(int) git_odb_read_prefix(git_odb_object **out, git_odb *db, const git_oid *short_id, unsigned int len);
/**
* Read the header of an object from the database, without
* reading its full contents.
*
* The header includes the length and the type of an object.
*
* Note that most backends do not support reading only the header
* of an object, so the whole object will be read and then the
* header will be returned.
*
* @param len_p pointer where to store the length
* @param type_p pointer where to store the type
* @param db database to search for the object in.
* @param id identity of the object to read.
* @return
* - GIT_SUCCESS if the object was read;
* - GIT_ENOTFOUND if the object is not in the database.
*/
GIT_EXTERN(int) git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id);
/**
* Determine if the given object can be found in the object database.
*
* @param db database to be searched for the given object.
* @param id the object to search for.
* @return
* - 1, if the object was found
* - 0, otherwise
*/
GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
/**
* Write an object directly into the ODB
*
* This method writes a full object straight into the ODB.
* For most cases, it is preferred to write objects through a write
* stream, which is both faster and less memory intensive, specially
* for big objects.
*
* This method is provided for compatibility with custom backends
* which are not able to support streaming writes
*
* @param oid pointer to store the OID result of the write
* @param odb object database where to store the object
* @param data buffer with the data to storr
* @param len size of the buffer
* @param type type of the data to store
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN(int) git_odb_write(git_oid *oid, git_odb *odb, const void *data, size_t len, git_otype type);
/**
* Open a stream to write an object into the ODB
*
* The type and final length of the object must be specified
* when opening the stream.
*
* The returned stream will be of type `GIT_STREAM_WRONLY` and
* will have the following methods:
*
* - stream->write: write `n` bytes into the stream
* - stream->finalize_write: close the stream and store the object in
* the odb
* - stream->free: free the stream
*
* The streaming write won't be effective until `stream->finalize_write`
* is called and returns without an error
*
* The stream must always be free'd or will leak memory.
*
* @see git_odb_stream
*
* @param stream pointer where to store the stream
* @param db object database where the stream will write
* @param size final size of the object that will be written
* @param type type of the object that will be written
* @return 0 if the stream was created; error code otherwise
*/
GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **stream, git_odb *db, size_t size, git_otype type);
/**
* Open a stream to read an object from the ODB
*
* Note that most backends do *not* support streaming reads
* because they store their objects as compressed/delta'ed blobs.
*
* It's recommended to use `git_odb_read` instead, which is
* assured to work on all backends.
*
* The returned stream will be of type `GIT_STREAM_RDONLY` and
* will have the following methods:
*
* - stream->read: read `n` bytes from the stream
* - stream->free: free the stream
*
* The stream must always be free'd or will leak memory.
*
* @see git_odb_stream
*
* @param stream pointer where to store the stream
* @param db object database where the stream will read from
* @param oid oid of the object the stream will read from
* @return 0 if the stream was created; error code otherwise
*/
GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oid);
/**
* Determine the object-ID (sha1 hash) of a data buffer
*
* The resulting SHA-1 OID will the itentifier for the data
* buffer as if the data buffer it were to written to the ODB.
*
* @param id the resulting object-ID.
* @param data data to hash
* @param len size of the data
* @param type of the data to hash
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN(int) git_odb_hash(git_oid *id, const void *data, size_t len, git_otype type);
/**
* Read a file from disk and fill a git_oid with the object id
* that the file would have if it were written to the Object
* Database as an object of the given type. Similar functionality
* to git.git's `git hash-object` without the `-w` flag.
*
* @param out oid structure the result is written into.
* @param path file to read and determine object id for
* @param type the type of the object that will be hashed
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type);
/**
* Close an ODB object
*
* This method must always be called once a `git_odb_object` is no
* longer needed, otherwise memory will leak.
*
* @param object object to close
*/
GIT_EXTERN(void) git_odb_object_free(git_odb_object *object);
/**
* Return the OID of an ODB object
*
* This is the OID from which the object was read from
*
* @param object the object
* @return a pointer to the OID
*/
GIT_EXTERN(const git_oid *) git_odb_object_id(git_odb_object *object);
/**
* Return the data of an ODB object
*
* This is the uncompressed, raw data as read from the ODB,
* without the leading header.
*
* This pointer is owned by the object and shall not be free'd.
*
* @param object the object
* @return a pointer to the data
*/
GIT_EXTERN(const void *) git_odb_object_data(git_odb_object *object);
/**
* Return the size of an ODB object
*
* This is the real size of the `data` buffer, not the
* actual size of the object.
*
* @param object the object
* @return the size
*/
GIT_EXTERN(size_t) git_odb_object_size(git_odb_object *object);
/**
* Return the type of an ODB object
*
* @param object the object
* @return the type
*/
GIT_EXTERN(git_otype) git_odb_object_type(git_odb_object *object);
/** @} */
GIT_END_DECL
#endif
| 32.057229 | 114 | 0.726863 | [
"object"
] |
b145e891b77b74883580d195cde147e458807f7b | 3,277 | h | C | services/ui/demo/mus_demo_internal.h | metux/chromium-deb | 3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | services/ui/demo/mus_demo_internal.h | metux/chromium-deb | 3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | services/ui/demo/mus_demo_internal.h | metux/chromium-deb | 3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_UI_DEMO_MUS_DEMO_INTERNAL_H_
#define SERVICES_UI_DEMO_MUS_DEMO_INTERNAL_H_
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "services/ui/demo/mus_demo.h"
#include "ui/aura/mus/window_manager_delegate.h"
namespace ui {
namespace demo {
// MusDemoInternal demonstrates Mus operating in "internal" mode: There is a
// single acceleratedWidget for a single display and all aura windows are
// contained in that display.
class MusDemoInternal : public MusDemo, public aura::WindowManagerDelegate {
public:
MusDemoInternal();
~MusDemoInternal() final;
private:
// ui::demo::MusDemo:
void OnStartImpl() final;
std::unique_ptr<aura::WindowTreeClient> CreateWindowTreeClient() final;
// aura::WindowManagerDelegate:
void SetWindowManagerClient(aura::WindowManagerClient* client) final;
void OnWmSetBounds(aura::Window* window, const gfx::Rect& bounds) final;
bool OnWmSetProperty(aura::Window* window,
const std::string& name,
std::unique_ptr<std::vector<uint8_t>>* new_data) final;
void OnWmSetModalType(aura::Window* window, ModalType type) final;
void OnWmSetCanFocus(aura::Window* window, bool can_focus) final;
aura::Window* OnWmCreateTopLevelWindow(
ui::mojom::WindowType window_type,
std::map<std::string, std::vector<uint8_t>>* properties) final;
void OnWmClientJankinessChanged(const std::set<aura::Window*>& client_windows,
bool janky) final;
void OnWmBuildDragImage(const gfx::Point& screen_location,
const SkBitmap& drag_image,
const gfx::Vector2d& drag_image_offset,
ui::mojom::PointerKind source) final;
void OnWmMoveDragImage(const gfx::Point& screen_location) final;
void OnWmDestroyDragImage() final;
void OnWmWillCreateDisplay(const display::Display& display) final;
void OnWmNewDisplay(std::unique_ptr<aura::WindowTreeHostMus> window_tree_host,
const display::Display& display) final;
void OnWmDisplayRemoved(aura::WindowTreeHostMus* window_tree_host) final;
void OnWmDisplayModified(const display::Display& display) final;
ui::mojom::EventResult OnAccelerator(
uint32_t id,
const ui::Event& event,
std::unordered_map<std::string, std::vector<uint8_t>>* properties) final;
void OnWmPerformMoveLoop(aura::Window* window,
ui::mojom::MoveLoopSource source,
const gfx::Point& cursor_location,
const base::Callback<void(bool)>& on_done) final;
void OnWmCancelMoveLoop(aura::Window* window) final;
void OnWmSetClientArea(
aura::Window* window,
const gfx::Insets& insets,
const std::vector<gfx::Rect>& additional_client_areas) final;
bool IsWindowActive(aura::Window* window) final;
void OnWmDeactivateWindow(aura::Window* window) final;
DISALLOW_COPY_AND_ASSIGN(MusDemoInternal);
};
} // namespace demo
} // namespace ui
#endif // SERVICES_UI_DEMO_MUS_DEMO_INTERNAL_H_
| 40.9625 | 80 | 0.706744 | [
"vector"
] |
b1477acfa61e9a5a318377345fa14f4d59823c61 | 47,953 | c | C | src/state.c | mad4j/rogue.js | bccd85f4e7fb2a61242404455577bc73e216ca40 | [
"BSD-3-Clause"
] | 41 | 2016-01-16T10:02:27.000Z | 2022-02-03T12:53:14.000Z | src/state.c | mad4j/rogue.js | bccd85f4e7fb2a61242404455577bc73e216ca40 | [
"BSD-3-Clause"
] | 12 | 2016-01-14T20:20:41.000Z | 2016-03-28T10:23:41.000Z | src/state.c | mad4j/rogue.js | bccd85f4e7fb2a61242404455577bc73e216ca40 | [
"BSD-3-Clause"
] | 4 | 2016-01-20T10:31:09.000Z | 2021-09-23T16:16:15.000Z | /*
state.c - Portable Rogue Save State Code
Copyright (C) 1999, 2000, 2005 Nicholas J. Kisseberth
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name(s) of the author(s) nor the names of other contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#include <stdlib.h>
#include <string.h>
#include <curses.h>
#include "rogue.h"
/************************************************************************/
/* Save State Code */
/************************************************************************/
#define RSID_STATS 0xABCD0001
#define RSID_THING 0xABCD0002
#define RSID_THING_NULL 0xDEAD0002
#define RSID_OBJECT 0xABCD0003
#define RSID_MAGICITEMS 0xABCD0004
#define RSID_KNOWS 0xABCD0005
#define RSID_GUESSES 0xABCD0006
#define RSID_OBJECTLIST 0xABCD0007
#define RSID_BAGOBJECT 0xABCD0008
#define RSID_MONSTERLIST 0xABCD0009
#define RSID_MONSTERSTATS 0xABCD000A
#define RSID_MONSTERS 0xABCD000B
#define RSID_TRAP 0xABCD000C
#define RSID_WINDOW 0xABCD000D
#define RSID_DAEMONS 0xABCD000E
#define RSID_IWEAPS 0xABCD000F
#define RSID_IARMOR 0xABCD0010
#define RSID_SPELLS 0xABCD0011
#define RSID_ILIST 0xABCD0012
#define RSID_HLIST 0xABCD0013
#define RSID_DEATHTYPE 0xABCD0014
#define RSID_CTYPES 0XABCD0015
#define RSID_COORDLIST 0XABCD0016
#define RSID_ROOMS 0XABCD0017
#define READSTAT (format_error || read_error )
#define WRITESTAT (write_error)
static int read_error = FALSE;
static int write_error = FALSE;
static int format_error = FALSE;
static int endian = 0x01020304;
#define big_endian ( *((char *)&endian) == 0x01 )
int
rs_write(FILE *savef, void *ptr, size_t size)
{
if (write_error)
return(WRITESTAT);
if (encwrite(ptr, size, savef) != size)
write_error = 1;
return(WRITESTAT);
}
int
rs_read(FILE *inf, void *ptr, size_t size)
{
if (read_error || format_error)
return(READSTAT);
if (encread(ptr, size, inf) != size)
read_error = 1;
return(READSTAT);
}
int
rs_write_int(FILE *savef, int c)
{
unsigned char bytes[4];
unsigned char *buf = (unsigned char *) &c;
if (write_error)
return(WRITESTAT);
if (big_endian)
{
bytes[3] = buf[0];
bytes[2] = buf[1];
bytes[1] = buf[2];
bytes[0] = buf[3];
buf = bytes;
}
rs_write(savef, buf, 4);
return(WRITESTAT);
}
int
rs_read_int(FILE *inf, int *i)
{
unsigned char bytes[4];
int input = 0;
unsigned char *buf = (unsigned char *)&input;
if (read_error || format_error)
return(READSTAT);
rs_read(inf, &input, 4);
if (big_endian)
{
bytes[3] = buf[0];
bytes[2] = buf[1];
bytes[1] = buf[2];
bytes[0] = buf[3];
buf = bytes;
}
*i = *((int *) buf);
return(READSTAT);
}
int
rs_write_char(FILE *savef, char c)
{
if (write_error)
return(WRITESTAT);
rs_write(savef, &c, 1);
return(WRITESTAT);
}
int
rs_read_char(FILE *inf, char *c)
{
if (read_error || format_error)
return(READSTAT);
rs_read(inf, c, 1);
return(READSTAT);
}
int
rs_write_chars(FILE *savef, char *c, int count)
{
if (write_error)
return(WRITESTAT);
rs_write_int(savef, count);
rs_write(savef, c, count);
return(WRITESTAT);
}
int
rs_read_chars(FILE *inf, char *i, int count)
{
int value = 0;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf, &value);
if (value != count)
format_error = TRUE;
rs_read(inf, i, count);
return(READSTAT);
}
int
rs_write_ints(FILE *savef, int *c, int count)
{
int n = 0;
if (write_error)
return(WRITESTAT);
rs_write_int(savef, count);
for(n = 0; n < count; n++)
if( rs_write_int(savef,c[n]) != 0)
break;
return(WRITESTAT);
}
int
rs_read_ints(FILE *inf, int *i, int count)
{
int n, value;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf,&value);
if (value != count)
format_error = TRUE;
for(n = 0; n < count; n++)
if (rs_read_int(inf, &i[n]) != 0)
break;
return(READSTAT);
}
int
rs_write_boolean(FILE *savef, int c)
{
unsigned char buf = (c == 0) ? 0 : 1;
if (write_error)
return(WRITESTAT);
rs_write(savef, &buf, 1);
return(WRITESTAT);
}
int
rs_read_boolean(FILE *inf, bool *i)
{
unsigned char buf = 0;
if (read_error || format_error)
return(READSTAT);
rs_read(inf, &buf, 1);
*i = (buf != 0);
return(READSTAT);
}
int
rs_write_booleans(FILE *savef, bool *c, int count)
{
int n = 0;
if (write_error)
return(WRITESTAT);
rs_write_int(savef, count);
for(n = 0; n < count; n++)
if (rs_write_boolean(savef, c[n]) != 0)
break;
return(WRITESTAT);
}
int
rs_read_booleans(FILE *inf, bool *i, int count)
{
int n = 0, value = 0;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf,&value);
if (value != count)
format_error = TRUE;
for(n = 0; n < count; n++)
if (rs_read_boolean(inf, &i[n]) != 0)
break;
return(READSTAT);
}
int
rs_write_short(FILE *savef, short c)
{
unsigned char bytes[2];
unsigned char *buf = (unsigned char *) &c;
if (write_error)
return(WRITESTAT);
if (big_endian)
{
bytes[1] = buf[0];
bytes[0] = buf[1];
buf = bytes;
}
rs_write(savef, buf, 2);
return(WRITESTAT);
}
int
rs_read_short(FILE *inf, short *i)
{
unsigned char bytes[2];
short input;
unsigned char *buf = (unsigned char *)&input;
if (read_error || format_error)
return(READSTAT);
rs_read(inf, &input, 2);
if (big_endian)
{
bytes[1] = buf[0];
bytes[0] = buf[1];
buf = bytes;
}
*i = *((short *) buf);
return(READSTAT);
}
int
rs_write_shorts(FILE *savef, short *c, int count)
{
int n = 0;
if (write_error)
return(WRITESTAT);
rs_write_int(savef, count);
for(n = 0; n < count; n++)
if (rs_write_short(savef, c[n]) != 0)
break;
return(WRITESTAT);
}
int
rs_read_shorts(FILE *inf, short *i, int count)
{
int n = 0, value = 0;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf,&value);
if (value != count)
format_error = TRUE;
for(n = 0; n < value; n++)
if (rs_read_short(inf, &i[n]) != 0)
break;
return(READSTAT);
}
int
rs_write_ushort(FILE *savef, unsigned short c)
{
unsigned char bytes[2];
unsigned char *buf = (unsigned char *) &c;
if (write_error)
return(WRITESTAT);
if (big_endian)
{
bytes[1] = buf[0];
bytes[0] = buf[1];
buf = bytes;
}
rs_write(savef, buf, 2);
return(WRITESTAT);
}
int
rs_read_ushort(FILE *inf, unsigned short *i)
{
unsigned char bytes[2];
unsigned short input;
unsigned char *buf = (unsigned char *)&input;
if (read_error || format_error)
return(READSTAT);
rs_read(inf, &input, 2);
if (big_endian)
{
bytes[1] = buf[0];
bytes[0] = buf[1];
buf = bytes;
}
*i = *((unsigned short *) buf);
return(READSTAT);
}
int
rs_write_uint(FILE *savef, unsigned int c)
{
unsigned char bytes[4];
unsigned char *buf = (unsigned char *) &c;
if (write_error)
return(WRITESTAT);
if (big_endian)
{
bytes[3] = buf[0];
bytes[2] = buf[1];
bytes[1] = buf[2];
bytes[0] = buf[3];
buf = bytes;
}
rs_write(savef, buf, 4);
return(WRITESTAT);
}
int
rs_read_uint(FILE *inf, unsigned int *i)
{
unsigned char bytes[4];
int input;
unsigned char *buf = (unsigned char *)&input;
if (read_error || format_error)
return(READSTAT);
rs_read(inf, &input, 4);
if (big_endian)
{
bytes[3] = buf[0];
bytes[2] = buf[1];
bytes[1] = buf[2];
bytes[0] = buf[3];
buf = bytes;
}
*i = *((unsigned int *) buf);
return(READSTAT);
}
int
rs_write_marker(FILE *savef, int id)
{
if (write_error)
return(WRITESTAT);
rs_write_int(savef, id);
return(WRITESTAT);
}
int
rs_read_marker(FILE *inf, int id)
{
int nid;
if (read_error || format_error)
return(READSTAT);
if (rs_read_int(inf, &nid) == 0)
if (id != nid)
format_error = 1;
return(READSTAT);
}
/******************************************************************************/
int
rs_write_string(FILE *savef, char *s)
{
int len = 0;
if (write_error)
return(WRITESTAT);
len = (s == NULL) ? 0 : (int) strlen(s) + 1;
rs_write_int(savef, len);
rs_write_chars(savef, s, len);
return(WRITESTAT);
}
int
rs_read_string(FILE *inf, char *s, int max)
{
int len = 0;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf, &len);
if (len > max)
format_error = TRUE;
rs_read_chars(inf, s, len);
return(READSTAT);
}
int
rs_read_new_string(FILE *inf, char **s)
{
int len=0;
char *buf=0;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf, &len);
if (len == 0)
buf = NULL;
else
{
buf = malloc(len);
if (buf == NULL)
read_error = TRUE;
}
rs_read_chars(inf, buf, len);
*s = buf;
return(READSTAT);
}
int
rs_write_strings(FILE *savef, char *s[], int count)
{
int n = 0;
if (write_error)
return(WRITESTAT);
rs_write_int(savef, count);
for(n = 0; n < count; n++)
if (rs_write_string(savef, s[n]) != 0)
break;
return(WRITESTAT);
}
int
rs_read_strings(FILE *inf, char **s, int count, int max)
{
int n = 0;
int value = 0;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf, &value);
if (value != count)
format_error = TRUE;
for(n = 0; n < count; n++)
if (rs_read_string(inf, s[n], max) != 0)
break;
return(READSTAT);
}
int
rs_read_new_strings(FILE *inf, char **s, int count)
{
int n = 0;
int value = 0;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf, &value);
if (value != count)
format_error = TRUE;
for(n = 0; n < count; n++)
if (rs_read_new_string(inf, &s[n]) != 0)
break;
return(READSTAT);
}
int
rs_write_string_index(FILE *savef, char *master[], int max, const char *str)
{
int i;
if (write_error)
return(WRITESTAT);
for(i = 0; i < max; i++)
if (str == master[i])
return( rs_write_int(savef, i) );
return( rs_write_int(savef,-1) );
}
int
rs_read_string_index(FILE *inf, char *master[], int maxindex, char **str)
{
int i;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf, &i);
if (i > maxindex)
format_error = TRUE;
else if (i >= 0)
*str = master[i];
else
*str = NULL;
return(READSTAT);
}
int
rs_write_str_t(FILE *savef, str_t st)
{
if (write_error)
return(WRITESTAT);
rs_write_uint(savef, st);
return( WRITESTAT );
}
int
rs_read_str_t(FILE *inf, str_t *st)
{
if (read_error || format_error)
return(READSTAT);
rs_read_uint(inf, st);
return(READSTAT);
}
int
rs_write_coord(FILE *savef, coord c)
{
if (write_error)
return(WRITESTAT);
rs_write_int(savef, c.x);
rs_write_int(savef, c.y);
return(WRITESTAT);
}
int
rs_read_coord(FILE *inf, coord *c)
{
coord in;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf,&in.x);
rs_read_int(inf,&in.y);
if (READSTAT == 0)
{
c->x = in.x;
c->y = in.y;
}
return(READSTAT);
}
int
rs_write_window(FILE *savef, WINDOW *win)
{
int row,col,height,width;
if (write_error)
return(WRITESTAT);
width = getmaxx(win);
height = getmaxy(win);
rs_write_marker(savef,RSID_WINDOW);
rs_write_int(savef,height);
rs_write_int(savef,width);
for(row=0;row<height;row++)
for(col=0;col<width;col++)
if (rs_write_int(savef, mvwinch(win,row,col)) != 0)
return(WRITESTAT);
return(WRITESTAT);
}
int
rs_read_window(FILE *inf, WINDOW *win)
{
int row,col,maxlines,maxcols,value,width,height;
if (read_error || format_error)
return(READSTAT);
width = getmaxx(win);
height = getmaxy(win);
rs_read_marker(inf, RSID_WINDOW);
rs_read_int(inf, &maxlines);
rs_read_int(inf, &maxcols);
for(row = 0; row < maxlines; row++)
for(col = 0; col < maxcols; col++)
{
if (rs_read_int(inf, &value) != 0)
return(READSTAT);
if ((row < height) && (col < width))
mvwaddch(win,row,col,value);
}
return(READSTAT);
}
/******************************************************************************/
void *
get_list_item(THING *l, int i)
{
int count;
for(count = 0; l != NULL; count++, l = l->l_next)
if (count == i)
return(l);
return(NULL);
}
int
find_list_ptr(THING *l, void *ptr)
{
int count;
for(count = 0; l != NULL; count++, l = l->l_next)
if (l == ptr)
return(count);
return(-1);
}
int
list_size(THING *l)
{
int count;
for(count = 0; l != NULL; count++, l = l->l_next)
;
return(count);
}
/******************************************************************************/
int
rs_write_stats(FILE *savef, struct stats *s)
{
if (write_error)
return(WRITESTAT);
rs_write_marker(savef, RSID_STATS);
rs_write_str_t(savef, s->s_str);
rs_write_int(savef, s->s_exp);
rs_write_int(savef, s->s_lvl);
rs_write_int(savef, s->s_arm);
rs_write_int(savef, s->s_hpt);
rs_write_chars(savef, s->s_dmg, sizeof(s->s_dmg));
rs_write_int(savef,s->s_maxhp);
return(WRITESTAT);
}
int
rs_read_stats(FILE *inf, struct stats *s)
{
if (read_error || format_error)
return(READSTAT);
rs_read_marker(inf, RSID_STATS);
rs_read_str_t(inf,&s->s_str);
rs_read_int(inf,&s->s_exp);
rs_read_int(inf,&s->s_lvl);
rs_read_int(inf,&s->s_arm);
rs_read_int(inf,&s->s_hpt);
rs_read_chars(inf,s->s_dmg,sizeof(s->s_dmg));
rs_read_int(inf,&s->s_maxhp);
return(READSTAT);
}
int
rs_write_stone_index(FILE *savef, STONE master[], int max, const char *str)
{
int i;
if (write_error)
return(WRITESTAT);
for(i = 0; i < max; i++)
if (str == master[i].st_name)
{
rs_write_int(savef,i);
return(WRITESTAT);
}
rs_write_int(savef,-1);
return(WRITESTAT);
}
int
rs_read_stone_index(FILE *inf, STONE master[], int maxindex, char **str)
{
int i = 0;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf,&i);
if (i > maxindex)
format_error = TRUE;
else if (i >= 0)
*str = master[i].st_name;
else
*str = NULL;
return(READSTAT);
}
int
rs_write_scrolls(FILE *savef)
{
int i;
if (write_error)
return(WRITESTAT);
for(i = 0; i < MAXSCROLLS; i++)
rs_write_string(savef, s_names[i]);
return(READSTAT);
}
int
rs_read_scrolls(FILE *inf)
{
int i;
if (read_error || format_error)
return(READSTAT);
for(i = 0; i < MAXSCROLLS; i++)
rs_read_new_string(inf, &s_names[i]);
return(READSTAT);
}
int
rs_write_potions(FILE *savef)
{
int i;
if (write_error)
return(WRITESTAT);
for(i = 0; i < MAXPOTIONS; i++)
rs_write_string_index(savef, rainbow, cNCOLORS, p_colors[i]);
return(WRITESTAT);
}
int
rs_read_potions(FILE *inf)
{
int i;
if (read_error || format_error)
return(READSTAT);
for(i = 0; i < MAXPOTIONS; i++)
rs_read_string_index(inf, rainbow, cNCOLORS, &p_colors[i]);
return(READSTAT);
}
int
rs_write_rings(FILE *savef)
{
int i;
if (write_error)
return(WRITESTAT);
for(i = 0; i < MAXRINGS; i++)
rs_write_stone_index(savef, stones, cNSTONES, r_stones[i]);
return(WRITESTAT);
}
int
rs_read_rings(FILE *inf)
{
int i;
if (read_error || format_error)
return(READSTAT);
for(i = 0; i < MAXRINGS; i++)
rs_read_stone_index(inf, stones, cNSTONES, &r_stones[i]);
return(READSTAT);
}
int
rs_write_sticks(FILE *savef)
{
int i;
if (write_error)
return(WRITESTAT);
for (i = 0; i < MAXSTICKS; i++)
{
if (strcmp(ws_type[i],"staff") == 0)
{
rs_write_int(savef,0);
rs_write_string_index(savef, wood, cNWOOD, ws_made[i]);
}
else
{
rs_write_int(savef,1);
rs_write_string_index(savef, metal, cNMETAL, ws_made[i]);
}
}
return(WRITESTAT);
}
int
rs_read_sticks(FILE *inf)
{
int i = 0, list = 0;
if (read_error || format_error)
return(READSTAT);
for(i = 0; i < MAXSTICKS; i++)
{
rs_read_int(inf,&list);
if (list == 0)
{
rs_read_string_index(inf, wood, cNWOOD, &ws_made[i]);
ws_type[i] = "staff";
}
else
{
rs_read_string_index(inf, metal, cNMETAL, &ws_made[i]);
ws_type[i] = "wand";
}
}
return(READSTAT);
}
int
rs_write_daemons(FILE *savef, struct delayed_action *d_list, int count)
{
int i = 0;
int func = 0;
if (write_error)
return(WRITESTAT);
rs_write_marker(savef, RSID_DAEMONS);
rs_write_int(savef, count);
for(i = 0; i < count; i++)
{
if (d_list[i].d_func == rollwand)
func = 1;
else if (d_list[i].d_func == doctor)
func = 2;
else if (d_list[i].d_func == stomach)
func = 3;
else if (d_list[i].d_func == runners)
func = 4;
else if (d_list[i].d_func == swander)
func = 5;
else if (d_list[i].d_func == nohaste)
func = 6;
else if (d_list[i].d_func == unconfuse)
func = 7;
else if (d_list[i].d_func == unsee)
func = 8;
else if (d_list[i].d_func == sight)
func = 9;
else if (d_list[i].d_func == NULL)
func = 0;
else
func = -1;
rs_write_int(savef, d_list[i].d_type);
rs_write_int(savef, func);
rs_write_int(savef, d_list[i].d_arg);
rs_write_int(savef, d_list[i].d_time);
}
return(WRITESTAT);
}
int
rs_read_daemons(FILE *inf, struct delayed_action *d_list, int count)
{
int i = 0;
int func = 0;
int value = 0;
if (read_error || format_error)
return(READSTAT);
rs_read_marker(inf, RSID_DAEMONS);
rs_read_int(inf, &value);
if (value > count)
format_error = TRUE;
for(i=0; i < count; i++)
{
func = 0;
rs_read_int(inf, &d_list[i].d_type);
rs_read_int(inf, &func);
rs_read_int(inf, &d_list[i].d_arg);
rs_read_int(inf, &d_list[i].d_time);
switch(func)
{
case 1: d_list[i].d_func = rollwand;
break;
case 2: d_list[i].d_func = doctor;
break;
case 3: d_list[i].d_func = stomach;
break;
case 4: d_list[i].d_func = runners;
break;
case 5: d_list[i].d_func = swander;
break;
case 6: d_list[i].d_func = nohaste;
break;
case 7: d_list[i].d_func = unconfuse;
break;
case 8: d_list[i].d_func = unsee;
break;
case 9: d_list[i].d_func = sight;
break;
default:d_list[i].d_func = NULL;
break;
}
}
if (d_list[i].d_func == NULL)
{
d_list[i].d_type = 0;
d_list[i].d_arg = 0;
d_list[i].d_time = 0;
}
return(READSTAT);
}
int
rs_write_obj_info(FILE *savef, struct obj_info *i, int count)
{
int n;
if (write_error)
return(WRITESTAT);
rs_write_marker(savef, RSID_MAGICITEMS);
rs_write_int(savef, count);
for(n = 0; n < count; n++)
{
/* mi_name is constant, defined at compile time in all cases */
rs_write_int(savef,i[n].oi_prob);
rs_write_int(savef,i[n].oi_worth);
rs_write_string(savef,i[n].oi_guess);
rs_write_boolean(savef,i[n].oi_know);
}
return(WRITESTAT);
}
int
rs_read_obj_info(FILE *inf, struct obj_info *mi, int count)
{
int n;
int value;
if (read_error || format_error)
return(READSTAT);
rs_read_marker(inf, RSID_MAGICITEMS);
rs_read_int(inf, &value);
if (value > count)
format_error = TRUE;
for(n = 0; n < value; n++)
{
/* mi_name is const, defined at compile time in all cases */
rs_read_int(inf,&mi[n].oi_prob);
rs_read_int(inf,&mi[n].oi_worth);
rs_read_new_string(inf,&mi[n].oi_guess);
rs_read_boolean(inf,&mi[n].oi_know);
}
return(READSTAT);
}
int
rs_write_room(FILE *savef, struct room *r)
{
if (write_error)
return(WRITESTAT);
rs_write_coord(savef, r->r_pos);
rs_write_coord(savef, r->r_max);
rs_write_coord(savef, r->r_gold);
rs_write_int(savef, r->r_goldval);
rs_write_short(savef, r->r_flags);
rs_write_int(savef, r->r_nexits);
rs_write_coord(savef, r->r_exit[0]);
rs_write_coord(savef, r->r_exit[1]);
rs_write_coord(savef, r->r_exit[2]);
rs_write_coord(savef, r->r_exit[3]);
rs_write_coord(savef, r->r_exit[4]);
rs_write_coord(savef, r->r_exit[5]);
rs_write_coord(savef, r->r_exit[6]);
rs_write_coord(savef, r->r_exit[7]);
rs_write_coord(savef, r->r_exit[8]);
rs_write_coord(savef, r->r_exit[9]);
rs_write_coord(savef, r->r_exit[10]);
rs_write_coord(savef, r->r_exit[11]);
return(WRITESTAT);
}
int
rs_read_room(FILE *inf, struct room *r)
{
if (read_error || format_error)
return(READSTAT);
rs_read_coord(inf,&r->r_pos);
rs_read_coord(inf,&r->r_max);
rs_read_coord(inf,&r->r_gold);
rs_read_int(inf,&r->r_goldval);
rs_read_short(inf,&r->r_flags);
rs_read_int(inf,&r->r_nexits);
rs_read_coord(inf,&r->r_exit[0]);
rs_read_coord(inf,&r->r_exit[1]);
rs_read_coord(inf,&r->r_exit[2]);
rs_read_coord(inf,&r->r_exit[3]);
rs_read_coord(inf,&r->r_exit[4]);
rs_read_coord(inf,&r->r_exit[5]);
rs_read_coord(inf,&r->r_exit[6]);
rs_read_coord(inf,&r->r_exit[7]);
rs_read_coord(inf,&r->r_exit[8]);
rs_read_coord(inf,&r->r_exit[9]);
rs_read_coord(inf,&r->r_exit[10]);
rs_read_coord(inf,&r->r_exit[11]);
return(READSTAT);
}
int
rs_write_rooms(FILE *savef, struct room r[], int count)
{
int n = 0;
if (write_error)
return(WRITESTAT);
rs_write_int(savef, count);
for(n = 0; n < count; n++)
rs_write_room(savef, &r[n]);
return(WRITESTAT);
}
int
rs_read_rooms(FILE *inf, struct room *r, int count)
{
int value = 0, n = 0;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf,&value);
if (value > count)
format_error = TRUE;
for(n = 0; n < value; n++)
rs_read_room(inf,&r[n]);
return(READSTAT);
}
int
rs_write_room_reference(FILE *savef, struct room *rp)
{
int i, room = -1;
if (write_error)
return(WRITESTAT);
for (i = 0; i < MAXROOMS; i++)
if (&rooms[i] == rp)
room = i;
rs_write_int(savef, room);
return(WRITESTAT);
}
int
rs_read_room_reference(FILE *inf, struct room **rp)
{
int i;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf, &i);
*rp = &rooms[i];
return(READSTAT);
}
int
rs_write_monsters(FILE *savef, struct monster *m, int count)
{
int n;
if (write_error)
return(WRITESTAT);
rs_write_marker(savef, RSID_MONSTERS);
rs_write_int(savef, count);
for(n=0;n<count;n++)
rs_write_stats(savef, &m[n].m_stats);
return(WRITESTAT);
}
int
rs_read_monsters(FILE *inf, struct monster *m, int count)
{
int value = 0, n = 0;
if (read_error || format_error)
return(READSTAT);
rs_read_marker(inf, RSID_MONSTERS);
rs_read_int(inf, &value);
if (value != count)
format_error = TRUE;
for(n = 0; n < count; n++)
rs_read_stats(inf, &m[n].m_stats);
return(READSTAT);
}
int
rs_write_object(FILE *savef, THING *o)
{
if (write_error)
return(WRITESTAT);
rs_write_marker(savef, RSID_OBJECT);
rs_write_int(savef, o->_o._o_type);
rs_write_coord(savef, o->_o._o_pos);
rs_write_int(savef, o->_o._o_launch);
rs_write_char(savef, o->_o._o_packch);
rs_write_chars(savef, o->_o._o_damage, sizeof(o->_o._o_damage));
rs_write_chars(savef, o->_o._o_hurldmg, sizeof(o->_o._o_hurldmg));
rs_write_int(savef, o->_o._o_count);
rs_write_int(savef, o->_o._o_which);
rs_write_int(savef, o->_o._o_hplus);
rs_write_int(savef, o->_o._o_dplus);
rs_write_int(savef, o->_o._o_arm);
rs_write_int(savef, o->_o._o_flags);
rs_write_int(savef, o->_o._o_group);
rs_write_string(savef, o->_o._o_label);
return(WRITESTAT);
}
int
rs_read_object(FILE *inf, THING *o)
{
if (read_error || format_error)
return(READSTAT);
rs_read_marker(inf, RSID_OBJECT);
rs_read_int(inf, &o->_o._o_type);
rs_read_coord(inf, &o->_o._o_pos);
rs_read_int(inf, &o->_o._o_launch);
rs_read_char(inf, &o->_o._o_packch);
rs_read_chars(inf, o->_o._o_damage, sizeof(o->_o._o_damage));
rs_read_chars(inf, o->_o._o_hurldmg, sizeof(o->_o._o_hurldmg));
rs_read_int(inf, &o->_o._o_count);
rs_read_int(inf, &o->_o._o_which);
rs_read_int(inf, &o->_o._o_hplus);
rs_read_int(inf, &o->_o._o_dplus);
rs_read_int(inf, &o->_o._o_arm);
rs_read_int(inf, &o->_o._o_flags);
rs_read_int(inf, &o->_o._o_group);
rs_read_new_string(inf, &o->_o._o_label);
return(READSTAT);
}
int
rs_write_object_list(FILE *savef, THING *l)
{
if (write_error)
return(WRITESTAT);
rs_write_marker(savef, RSID_OBJECTLIST);
rs_write_int(savef, list_size(l));
for( ;l != NULL; l = l->l_next)
rs_write_object(savef, l);
return(WRITESTAT);
}
int
rs_read_object_list(FILE *inf, THING **list)
{
int i, cnt;
THING *l = NULL, *previous = NULL, *head = NULL;
if (read_error || format_error)
return(READSTAT);
rs_read_marker(inf, RSID_OBJECTLIST);
rs_read_int(inf, &cnt);
for (i = 0; i < cnt; i++)
{
l = new_item();
memset(l,0,sizeof(THING));
l->l_prev = previous;
if (previous != NULL)
previous->l_next = l;
rs_read_object(inf,l);
if (previous == NULL)
head = l;
previous = l;
}
if (l != NULL)
l->l_next = NULL;
*list = head;
return(READSTAT);
}
int
rs_write_object_reference(FILE *savef, THING *list, THING *item)
{
int i;
if (write_error)
return(WRITESTAT);
i = find_list_ptr(list, item);
rs_write_int(savef, i);
return(WRITESTAT);
}
int
rs_read_object_reference(FILE *inf, THING *list, THING **item)
{
int i;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf, &i);
*item = get_list_item(list,i);
return(READSTAT);
}
int
find_room_coord(struct room *rmlist, coord *c, int n)
{
int i = 0;
for(i = 0; i < n; i++)
if(&rmlist[i].r_gold == c)
return(i);
return(-1);
}
int
find_thing_coord(THING *monlist, coord *c)
{
THING *mitem;
THING *tp;
int i = 0;
for(mitem = monlist; mitem != NULL; mitem = mitem->l_next)
{
tp = mitem;
if (c == &tp->t_pos)
return(i);
i++;
}
return(-1);
}
int
find_object_coord(THING *objlist, coord *c)
{
THING *oitem;
THING *obj;
int i = 0;
for(oitem = objlist; oitem != NULL; oitem = oitem->l_next)
{
obj = oitem;
if (c == &obj->o_pos)
return(i);
i++;
}
return(-1);
}
int
rs_write_thing(FILE *savef, THING *t)
{
int i = -1;
if (write_error)
return(WRITESTAT);
rs_write_marker(savef, RSID_THING);
if (t == NULL)
{
rs_write_int(savef, 0);
return(WRITESTAT);
}
rs_write_int(savef, 1);
rs_write_coord(savef, t->_t._t_pos);
rs_write_boolean(savef, t->_t._t_turn);
rs_write_char(savef, t->_t._t_type);
rs_write_char(savef, t->_t._t_disguise);
rs_write_char(savef, t->_t._t_oldch);
/*
t_dest can be:
0,0: NULL
0,1: location of hero
1,i: location of a thing (monster)
2,i: location of an object
3,i: location of gold in a room
We need to remember what we are chasing rather than
the current location of what we are chasing.
*/
if (t->t_dest == &hero)
{
rs_write_int(savef,0);
rs_write_int(savef,1);
}
else if (t->t_dest != NULL)
{
i = find_thing_coord(mlist, t->t_dest);
if (i >=0 )
{
rs_write_int(savef,1);
rs_write_int(savef,i);
}
else
{
i = find_object_coord(lvl_obj, t->t_dest);
if (i >= 0)
{
rs_write_int(savef,2);
rs_write_int(savef,i);
}
else
{
i = find_room_coord(rooms, t->t_dest, MAXROOMS);
if (i >= 0)
{
rs_write_int(savef,3);
rs_write_int(savef,i);
}
else
{
rs_write_int(savef, 0);
rs_write_int(savef,1); /* chase the hero anyway */
}
}
}
}
else
{
rs_write_int(savef,0);
rs_write_int(savef,0);
}
rs_write_short(savef, t->_t._t_flags);
rs_write_stats(savef, &t->_t._t_stats);
rs_write_room_reference(savef, t->_t._t_room);
rs_write_object_list(savef, t->_t._t_pack);
return(WRITESTAT);
}
int
rs_read_thing(FILE *inf, THING *t)
{
int listid = 0, index = -1;
THING *item;
if (read_error || format_error)
return(READSTAT);
rs_read_marker(inf, RSID_THING);
rs_read_int(inf, &index);
if (index == 0)
return(READSTAT);
rs_read_coord(inf,&t->_t._t_pos);
rs_read_boolean(inf,&t->_t._t_turn);
rs_read_char(inf,&t->_t._t_type);
rs_read_char(inf,&t->_t._t_disguise);
rs_read_char(inf,&t->_t._t_oldch);
/*
t_dest can be (listid,index):
0,0: NULL
0,1: location of hero
1,i: location of a thing (monster)
2,i: location of an object
3,i: location of gold in a room
We need to remember what we are chasing rather than
the current location of what we are chasing.
*/
rs_read_int(inf, &listid);
rs_read_int(inf, &index);
t->_t._t_reserved = -1;
if (listid == 0) /* hero or NULL */
{
if (index == 1)
t->_t._t_dest = &hero;
else
t->_t._t_dest = NULL;
}
else if (listid == 1) /* monster/thing */
{
t->_t._t_dest = NULL;
t->_t._t_reserved = index;
}
else if (listid == 2) /* object */
{
THING *obj;
item = get_list_item(lvl_obj, index);
if (item != NULL)
{
obj = item;
t->_t._t_dest = &obj->o_pos;
}
}
else if (listid == 3) /* gold */
{
t->_t._t_dest = &rooms[index].r_gold;
}
else
t->_t._t_dest = NULL;
rs_read_short(inf,&t->_t._t_flags);
rs_read_stats(inf,&t->_t._t_stats);
rs_read_room_reference(inf, &t->_t._t_room);
rs_read_object_list(inf,&t->_t._t_pack);
return(READSTAT);
}
void
rs_fix_thing(THING *t)
{
THING *item;
THING *tp;
if (t->t_reserved < 0)
return;
item = get_list_item(mlist,t->t_reserved);
if (item != NULL)
{
tp = item;
t->t_dest = &tp->t_pos;
}
}
int
rs_write_thing_list(FILE *savef, THING *l)
{
int cnt = 0;
if (write_error)
return(WRITESTAT);
rs_write_marker(savef, RSID_MONSTERLIST);
cnt = list_size(l);
rs_write_int(savef, cnt);
if (cnt < 1)
return(WRITESTAT);
while (l != NULL) {
rs_write_thing(savef, l);
l = l->l_next;
}
return(WRITESTAT);
}
int
rs_read_thing_list(FILE *inf, THING **list)
{
int i, cnt;
THING *l = NULL, *previous = NULL, *head = NULL;
if (read_error || format_error)
return(READSTAT);
rs_read_marker(inf, RSID_MONSTERLIST);
rs_read_int(inf, &cnt);
for (i = 0; i < cnt; i++)
{
l = new_item();
l->l_prev = previous;
if (previous != NULL)
previous->l_next = l;
rs_read_thing(inf,l);
if (previous == NULL)
head = l;
previous = l;
}
if (l != NULL)
l->l_next = NULL;
*list = head;
return(READSTAT);
}
void
rs_fix_thing_list(THING *list)
{
THING *item;
for(item = list; item != NULL; item = item->l_next)
rs_fix_thing(item);
}
int
rs_write_thing_reference(FILE *savef, THING *list, THING *item)
{
int i;
if (write_error)
return(WRITESTAT);
if (item == NULL)
rs_write_int(savef,-1);
else
{
i = find_list_ptr(list, item);
rs_write_int(savef, i);
}
return(WRITESTAT);
}
int
rs_read_thing_reference(FILE *inf, THING *list, THING **item)
{
int i;
if (read_error || format_error)
return(READSTAT);
rs_read_int(inf, &i);
if (i == -1)
*item = NULL;
else
*item = get_list_item(list,i);
return(READSTAT);
}
int
rs_write_thing_references(FILE *savef, THING *list, THING *items[], int count)
{
int i;
if (write_error)
return(WRITESTAT);
for(i = 0; i < count; i++)
rs_write_thing_reference(savef,list,items[i]);
return(WRITESTAT);
}
int
rs_read_thing_references(FILE *inf, THING *list, THING *items[], int count)
{
int i;
if (read_error || format_error)
return(READSTAT);
for(i = 0; i < count; i++)
rs_read_thing_reference(inf,list,&items[i]);
return(WRITESTAT);
}
int
rs_write_places(FILE *savef, PLACE *places, int count)
{
int i = 0;
if (write_error)
return(WRITESTAT);
for(i = 0; i < count; i++)
{
rs_write_char(savef, places[i].p_ch);
rs_write_char(savef, places[i].p_flags);
rs_write_thing_reference(savef, mlist, places[i].p_monst);
}
return(WRITESTAT);
}
int
rs_read_places(FILE *inf, PLACE *places, int count)
{
int i = 0;
if (read_error || format_error)
return(READSTAT);
for(i = 0; i < count; i++)
{
rs_read_char(inf,&places[i].p_ch);
rs_read_char(inf,&places[i].p_flags);
rs_read_thing_reference(inf, mlist, &places[i].p_monst);
}
return(READSTAT);
}
int
rs_save_file(FILE *savef)
{
if (write_error)
return(WRITESTAT);
rs_write_boolean(savef, after); /* 1 */ /* extern.c */
rs_write_boolean(savef, again); /* 2 */
rs_write_int(savef, noscore); /* 3 */
rs_write_boolean(savef, seenstairs); /* 4 */
rs_write_boolean(savef, amulet); /* 5 */
rs_write_boolean(savef, door_stop); /* 6 */
rs_write_boolean(savef, fight_flush); /* 7 */
rs_write_boolean(savef, firstmove); /* 8 */
rs_write_boolean(savef, got_ltc); /* 9 */
rs_write_boolean(savef, has_hit); /* 10 */
rs_write_boolean(savef, in_shell); /* 11 */
rs_write_boolean(savef, inv_describe); /* 12 */
rs_write_boolean(savef, jump); /* 13 */
rs_write_boolean(savef, kamikaze); /* 14 */
rs_write_boolean(savef, lower_msg); /* 15 */
rs_write_boolean(savef, move_on); /* 16 */
rs_write_boolean(savef, msg_esc); /* 17 */
rs_write_boolean(savef, passgo); /* 18 */
rs_write_boolean(savef, playing); /* 19 */
rs_write_boolean(savef, q_comm); /* 20 */
rs_write_boolean(savef, running); /* 21 */
rs_write_boolean(savef, save_msg); /* 22 */
rs_write_boolean(savef, see_floor); /* 23 */
rs_write_boolean(savef, stat_msg); /* 24 */
rs_write_boolean(savef, terse); /* 25 */
rs_write_boolean(savef, to_death); /* 26 */
rs_write_boolean(savef, tombstone); /* 27 */
#ifdef MASTER
rs_write_int(savef, wizard); /* 28 */
#else
rs_write_int(savef, 0); /* 28 */
#endif
rs_write_booleans(savef, pack_used, 26); /* 29 */
rs_write_char(savef, dir_ch);
rs_write_chars(savef, file_name, MAXSTR);
rs_write_chars(savef, huh, MAXSTR);
rs_write_potions(savef);
rs_write_chars(savef,prbuf,2*MAXSTR);
rs_write_rings(savef);
rs_write_string(savef,release);
rs_write_char(savef, runch);
rs_write_scrolls(savef);
rs_write_char(savef, take);
rs_write_chars(savef, whoami, MAXSTR);
rs_write_sticks(savef);
rs_write_int(savef,orig_dsusp);
rs_write_chars(savef, fruit, MAXSTR);
rs_write_chars(savef, home, MAXSTR);
rs_write_strings(savef,inv_t_name,3);
rs_write_char(savef,l_last_comm);
rs_write_char(savef,l_last_dir);
rs_write_char(savef,last_comm);
rs_write_char(savef,last_dir);
rs_write_strings(savef,tr_name,8);
rs_write_int(savef,n_objs);
rs_write_int(savef, ntraps);
rs_write_int(savef, hungry_state);
rs_write_int(savef, inpack);
rs_write_int(savef, inv_type);
rs_write_int(savef, level);
rs_write_int(savef, max_level);
rs_write_int(savef, mpos);
rs_write_int(savef, no_food);
rs_write_ints(savef,a_class,MAXARMORS);
rs_write_int(savef, count);
rs_write_int(savef, food_left);
rs_write_int(savef, lastscore);
rs_write_int(savef, no_command);
rs_write_int(savef, no_move);
rs_write_int(savef, purse);
rs_write_int(savef, quiet);
rs_write_int(savef, vf_hit);
rs_write_int(savef, dnum);
rs_write_int(savef, seed);
rs_write_ints(savef, e_levels, 21);
rs_write_coord(savef, delta);
rs_write_coord(savef, oldpos);
rs_write_coord(savef, stairs);
rs_write_thing(savef, &player);
rs_write_object_reference(savef, player.t_pack, cur_armor);
rs_write_object_reference(savef, player.t_pack, cur_ring[0]);
rs_write_object_reference(savef, player.t_pack, cur_ring[1]);
rs_write_object_reference(savef, player.t_pack, cur_weapon);
rs_write_object_reference(savef, player.t_pack, l_last_pick);
rs_write_object_reference(savef, player.t_pack, last_pick);
rs_write_object_list(savef, lvl_obj);
rs_write_thing_list(savef, mlist);
rs_write_places(savef,places,MAXLINES*MAXCOLS);
rs_write_stats(savef,&max_stats);
rs_write_rooms(savef, rooms, MAXROOMS);
rs_write_room_reference(savef, oldrp);
rs_write_rooms(savef, passages, MAXPASS);
rs_write_monsters(savef,monsters,26);
rs_write_obj_info(savef, things, NUMTHINGS);
rs_write_obj_info(savef, arm_info, MAXARMORS);
rs_write_obj_info(savef, pot_info, MAXPOTIONS);
rs_write_obj_info(savef, ring_info, MAXRINGS);
rs_write_obj_info(savef, scr_info, MAXSCROLLS);
rs_write_obj_info(savef, weap_info, MAXWEAPONS+1);
rs_write_obj_info(savef, ws_info, MAXSTICKS);
rs_write_daemons(savef, &d_list[0], 20); /* 5.4-daemon.c */
#ifdef MASTER
rs_write_int(savef,total); /* 5.4-list.c */
#else
rs_write_int(savef, 0);
#endif
rs_write_int(savef,between); /* 5.4-daemons.c*/
rs_write_coord(savef, nh); /* 5.4-move.c */
rs_write_int(savef, group); /* 5.4-weapons.c */
rs_write_window(savef,stdscr);
return(WRITESTAT);
}
int
rs_restore_file(FILE *inf)
{
int dummyint;
if (read_error || format_error)
return(READSTAT);
rs_read_boolean(inf, &after); /* 1 */ /* extern.c */
rs_read_boolean(inf, &again); /* 2 */
rs_read_int(inf, &noscore); /* 3 */
rs_read_boolean(inf, &seenstairs); /* 4 */
rs_read_boolean(inf, &amulet); /* 5 */
rs_read_boolean(inf, &door_stop); /* 6 */
rs_read_boolean(inf, &fight_flush); /* 7 */
rs_read_boolean(inf, &firstmove); /* 8 */
rs_read_boolean(inf, &got_ltc); /* 9 */
rs_read_boolean(inf, &has_hit); /* 10 */
rs_read_boolean(inf, &in_shell); /* 11 */
rs_read_boolean(inf, &inv_describe); /* 12 */
rs_read_boolean(inf, &jump); /* 13 */
rs_read_boolean(inf, &kamikaze); /* 14 */
rs_read_boolean(inf, &lower_msg); /* 15 */
rs_read_boolean(inf, &move_on); /* 16 */
rs_read_boolean(inf, &msg_esc); /* 17 */
rs_read_boolean(inf, &passgo); /* 18 */
rs_read_boolean(inf, &playing); /* 19 */
rs_read_boolean(inf, &q_comm); /* 20 */
rs_read_boolean(inf, &running); /* 21 */
rs_read_boolean(inf, &save_msg); /* 22 */
rs_read_boolean(inf, &see_floor); /* 23 */
rs_read_boolean(inf, &stat_msg); /* 24 */
rs_read_boolean(inf, &terse); /* 25 */
rs_read_boolean(inf, &to_death); /* 26 */
rs_read_boolean(inf, &tombstone); /* 27 */
#ifdef MASTER
rs_read_int(inf, &wizard); /* 28 */
#else
rs_read_int(inf, &dummyint); /* 28 */
#endif
rs_read_booleans(inf, pack_used, 26); /* 29 */
rs_read_char(inf, &dir_ch);
rs_read_chars(inf, file_name, MAXSTR);
rs_read_chars(inf, huh, MAXSTR);
rs_read_potions(inf);
rs_read_chars(inf, prbuf, 2*MAXSTR);
rs_read_rings(inf);
rs_read_new_string(inf,&release);
rs_read_char(inf, &runch);
rs_read_scrolls(inf);
rs_read_char(inf, &take);
rs_read_chars(inf, whoami, MAXSTR);
rs_read_sticks(inf);
rs_read_int(inf,&orig_dsusp);
rs_read_chars(inf, fruit, MAXSTR);
rs_read_chars(inf, home, MAXSTR);
rs_read_new_strings(inf,inv_t_name,3);
rs_read_char(inf, &l_last_comm);
rs_read_char(inf, &l_last_dir);
rs_read_char(inf, &last_comm);
rs_read_char(inf, &last_dir);
rs_read_new_strings(inf,tr_name,8);
rs_read_int(inf, &n_objs);
rs_read_int(inf, &ntraps);
rs_read_int(inf, &hungry_state);
rs_read_int(inf, &inpack);
rs_read_int(inf, &inv_type);
rs_read_int(inf, &level);
rs_read_int(inf, &max_level);
rs_read_int(inf, &mpos);
rs_read_int(inf, &no_food);
rs_read_ints(inf,a_class,MAXARMORS);
rs_read_int(inf, &count);
rs_read_int(inf, &food_left);
rs_read_int(inf, &lastscore);
rs_read_int(inf, &no_command);
rs_read_int(inf, &no_move);
rs_read_int(inf, &purse);
rs_read_int(inf, &quiet);
rs_read_int(inf, &vf_hit);
rs_read_int(inf, &dnum);
rs_read_int(inf, &seed);
rs_read_ints(inf,e_levels,21);
rs_read_coord(inf, &delta);
rs_read_coord(inf, &oldpos);
rs_read_coord(inf, &stairs);
rs_read_thing(inf, &player);
rs_read_object_reference(inf, player.t_pack, &cur_armor);
rs_read_object_reference(inf, player.t_pack, &cur_ring[0]);
rs_read_object_reference(inf, player.t_pack, &cur_ring[1]);
rs_read_object_reference(inf, player.t_pack, &cur_weapon);
rs_read_object_reference(inf, player.t_pack, &l_last_pick);
rs_read_object_reference(inf, player.t_pack, &last_pick);
rs_read_object_list(inf, &lvl_obj);
rs_read_thing_list(inf, &mlist);
rs_fix_thing(&player);
rs_fix_thing_list(mlist);
rs_read_places(inf,places,MAXLINES*MAXCOLS);
rs_read_stats(inf, &max_stats);
rs_read_rooms(inf, rooms, MAXROOMS);
rs_read_room_reference(inf, &oldrp);
rs_read_rooms(inf, passages, MAXPASS);
rs_read_monsters(inf,monsters,26);
rs_read_obj_info(inf, things, NUMTHINGS);
rs_read_obj_info(inf, arm_info, MAXARMORS);
rs_read_obj_info(inf, pot_info, MAXPOTIONS);
rs_read_obj_info(inf, ring_info, MAXRINGS);
rs_read_obj_info(inf, scr_info, MAXSCROLLS);
rs_read_obj_info(inf, weap_info, MAXWEAPONS+1);
rs_read_obj_info(inf, ws_info, MAXSTICKS);
rs_read_daemons(inf, d_list, 20); /* 5.4-daemon.c */
rs_read_int(inf,&dummyint); /* total */ /* 5.4-list.c */
rs_read_int(inf,&between); /* 5.4-daemons.c */
rs_read_coord(inf, &nh); /* 5.4-move.c */
rs_read_int(inf,&group); /* 5.4-weapons.c */
rs_read_window(inf,stdscr);
return(READSTAT);
}
| 22.460422 | 80 | 0.567014 | [
"object"
] |
7f27e1c79afbe39ec2ea3750613e043168f26633 | 1,796 | h | C | lib/vscode/node_modules/native-keymap/src/keymapping.h | cdkfox/private-soft-code_server3.1.1 | 242ba6a536495f03f8653e7cab641748ba3feb92 | [
"MIT"
] | 1 | 2022-03-12T15:20:54.000Z | 2022-03-12T15:20:54.000Z | lib/vscode/node_modules/native-keymap/src/keymapping.h | cdkfox/private-soft-code_server3.1.1 | 242ba6a536495f03f8653e7cab641748ba3feb92 | [
"MIT"
] | 2 | 2021-08-31T19:19:13.000Z | 2022-02-13T12:12:11.000Z | lib/vscode/node_modules/native-keymap/src/keymapping.h | cdkfox/private-soft-code_server3.1.1 | 242ba6a536495f03f8653e7cab641748ba3feb92 | [
"MIT"
] | 1 | 2020-07-30T11:10:03.000Z | 2020-07-30T11:10:03.000Z | /*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
#ifndef KEYMAPPING_H_
#define KEYMAPPING_H_
#include <node_api.h>
#include <string>
#include <vector>
#include "../deps/chromium/keyboard_codes.h"
#define CHECK_OK(x) if (x != napi_ok) return NULL
namespace vscode_keyboard {
// This structure is used to define the keycode mapping table.
// It is defined here because the unittests need access to it.
typedef struct {
// USB keycode:
// Upper 16-bits: USB Usage Page.
// Lower 16-bits: USB Usage Id: Assigned ID within this usage page.
uint32_t usb_keycode;
// Contains one of the following:
// On Linux: XKB scancode
// On Windows: Windows OEM scancode
// On Mac: Mac keycode
int native_keycode;
// The UIEvents (aka: DOM4Events) |code| value as defined in:
// http://www.w3.org/TR/DOM-Level-3-Events-code/
const char* code;
} KeycodeMapEntry;
napi_value _GetKeyMap(napi_env env, napi_callback_info info);
napi_value _GetCurrentKeyboardLayout(napi_env env, napi_callback_info info);
napi_value _OnDidChangeKeyboardLayout(napi_env env, napi_callback_info info);
napi_value _isISOKeyboard(napi_env env, napi_callback_info info);
napi_status napi_set_named_property_string_utf8(napi_env env, napi_value object, const char *utf8Name, const char *value);
napi_value napi_fetch_null(napi_env env);
napi_value napi_fetch_undefined(napi_env env);
napi_value napi_fetch_boolean(napi_env env, bool value);
} // namespace vscode_keyboard
#endif // KEYMAPPING_H_ | 35.92 | 122 | 0.686526 | [
"object",
"vector"
] |
7f283e9195c0e4bfcca00634ca0cddde23b36390 | 1,935 | h | C | src/ArgumentViewer/private/ArgumentListFormat.h | dormon/ArgumentViewer | a3cce792f18040dd009c75b10a070a61a3f53ac9 | [
"MIT"
] | null | null | null | src/ArgumentViewer/private/ArgumentListFormat.h | dormon/ArgumentViewer | a3cce792f18040dd009c75b10a070a61a3f53ac9 | [
"MIT"
] | 1 | 2018-03-31T11:42:38.000Z | 2018-05-02T13:34:18.000Z | src/ArgumentViewer/private/ArgumentListFormat.h | dormon/ArgumentViewer | a3cce792f18040dd009c75b10a070a61a3f53ac9 | [
"MIT"
] | null | null | null | #pragma once
#include <ArgumentViewer/private/ValueFormat.h>
#include <map>
#include <memory>
#include <set>
class ContextFormat;
class ArgumentListFormat : public Format {
public:
ArgumentListFormat(string const &com);
virtual string toStr(size_t indent,
size_t = 0,
size_t = 0,
size_t = 0) const override;
virtual MatchStatus match(vector<string> const &args,
size_t & index) const override;
map<string, shared_ptr<Format>> formats;
protected:
void getLargestLengths(size_t &nameLength,
size_t &defaultsLength,
size_t &typeLength) const;
void writeIndentedNonContextFormats(stringstream &ss,
size_t nameLength,
size_t defaultsLength,
size_t typeLength,
size_t indent) const;
void writeContextFormats(stringstream &ss, size_t indent) const;
string matchOneUnusedFormat(set<string> const & unusedFormats,
vector<string> const &args,
size_t & index) const;
void checkAndMatchOneUnusedFormat(set<string> & unusedFormats,
vector<string> const &args,
size_t & index) const;
void matchUnusedFormats(set<string> & unusedFormats,
vector<string> const &args,
size_t & index) const;
set<string> getUnusedFormats() const;
};
| 47.195122 | 84 | 0.458915 | [
"vector"
] |
7f2fe8fafddc989c74ad2c2a54f26500d0f09b36 | 2,731 | h | C | src/clipperlib/clipper_offset.h | andryblack/pcb-printer-host | 8e2980eb6584ea832720ab793b2c4454d0fe4e4e | [
"BSL-1.0",
"MIT"
] | 3 | 2020-06-18T07:24:12.000Z | 2020-10-05T18:51:41.000Z | src/clipperlib/clipper_offset.h | andryblack/pcb-printer-host | 8e2980eb6584ea832720ab793b2c4454d0fe4e4e | [
"BSL-1.0",
"MIT"
] | null | null | null | src/clipperlib/clipper_offset.h | andryblack/pcb-printer-host | 8e2980eb6584ea832720ab793b2c4454d0fe4e4e | [
"BSL-1.0",
"MIT"
] | 1 | 2020-01-29T10:28:38.000Z | 2020-01-29T10:28:38.000Z | /*******************************************************************************
* Author : Angus Johnson *
* Version : 10.0 (beta) *
* Date : 8 Noveber 2017 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2017 *
* Purpose : Offset clipping solutions *
* License : http://www.boost.org/LICENSE_1_0.txt *
*******************************************************************************/
#ifndef clipper_offset_h
#define clipper_offset_h
#include <vector>
#include <cstdlib>
#include "clipper.h"
namespace clipperlib {
enum JoinType { kSquare, kRound, kMiter };
enum EndType { kPolygon, kOpenJoined, kOpenButt, kOpenSquare, kOpenRound };
void OffsetPaths(Paths &paths_in, Paths &paths_out, double delta, JoinType jt, EndType et);
class ClipperOffset
{
private:
struct PointD
{
double x;
double y;
PointD(double x_ = 0, double y_ = 0) : x(x_), y(y_) {};
PointD(const Point64 &pt) : x((double)pt.x), y((double)pt.y) {};
};
struct PathNode
{
Path path;
JoinType join_type;
EndType end_type;
int lowest_idx;
PathNode(const Path &p, JoinType jt, EndType et);
};
typedef std::vector< PointD > NormalsList;
typedef std::vector< PathNode* > NodeList;
Paths solution_;
Path path_in_, path_out_;
NormalsList norms_;
NodeList nodes_;
double arc_tolerance_;
double miter_limit_;
//nb: miter_lim_ below is a temp field that differs from miter_limit
double delta_, sin_a_, sin_, cos_, miter_lim_, steps_per_radian_;
int lowest_idx_;
void GetLowestPolygonIdx();
void OffsetPoint(size_t j, size_t &k, JoinType join_type);
void DoSquare(int j, int k);
void DoMiter(int j, int k, double cos_a_plus_1);
void DoRound(int j, int k);
void DoOffset(double d);
static PointD GetUnitNormal(const Point64 &pt1, const Point64 &pt2);
public:
ClipperOffset(double miter_limit = 2.0, double arc_tolerance = 0) :
miter_limit_(miter_limit), arc_tolerance_(arc_tolerance) {};
~ClipperOffset() { Clear(); }
void Clear();
void AddPath(const Path &path, JoinType jt, EndType et);
void AddPaths(const Paths &paths, JoinType jt, EndType et);
void Execute(Paths &sol, double delta);
};
} //clipperlib namespace
#endif //clipper_offset_h
| 33.304878 | 94 | 0.535701 | [
"vector"
] |
7f31a98cff3a7f2bef29ea8a087fdd1557e612ed | 2,484 | h | C | Nemo/InteractionSystem.h | cyj0912/Nemo | cd242e9d17863b461ccfd768122572d979c330e3 | [
"BSD-2-Clause"
] | null | null | null | Nemo/InteractionSystem.h | cyj0912/Nemo | cd242e9d17863b461ccfd768122572d979c330e3 | [
"BSD-2-Clause"
] | null | null | null | Nemo/InteractionSystem.h | cyj0912/Nemo | cd242e9d17863b461ccfd768122572d979c330e3 | [
"BSD-2-Clause"
] | null | null | null | #pragma once
#include "InputHandler.h"
#include <Matrix3x4.h>
#include <UsingStl.h>
namespace tc
{
class FNode;
class FEntityManager;
class IRayIntersectComponent;
class FInteractionSystem;
class FEditorMaster;
class FBaseEntity;
class FTranslateGizmo;
class FTranslateGizmoInputHandler;
class FPointTranslateGizmoInputHandler;
enum EGizmoFlags
{
GF_NONE = 0x0,
GF_TRANSLATE = 0x1,
GF_ROTATE = 0x2,
GF_SCALE = 0x4,
};
class IInteractionComponent
{
public:
virtual EGizmoFlags GetGizmoFlags()
{
return GF_NONE;
}
virtual Matrix3x4 QueryPreferredGizmoTransform()
{
return {};
}
virtual void SetGizmoTransformStart(const FNode& node) {}
virtual void UpdateFromGizmoTransform(const FNode& node) {}
virtual IRayIntersectComponent* GetRayIntersectComponent() = 0;
};
class FInteractionSystem : public IInputHandler
{
public:
explicit FInteractionSystem(FEntityManager* em)
: EntityManager(em), EditorMaster(nullptr), MainSelection(nullptr),
TranslateGizmoInputHandler(nullptr), bAllowMultiSelect(false),
TranslateGizmoBasis(nullptr), TranslateGizmo(nullptr)
{
}
FEditorMaster* GetEditorMaster() const
{
return EditorMaster;
}
void SetEditorMaster(FEditorMaster* v)
{
EditorMaster = v;
}
bool KeyPressed(const FKeyboardEvent& evt) override;
bool KeyReleased(const FKeyboardEvent& evt) override;
bool MouseMoved(const FMouseMotionEvent& evt) override;
bool MousePressed(const FMouseButtonEvent& evt) override;
bool MouseReleased(const FMouseButtonEvent& evt) override;
void CreateGizmoFromSelections();
void UpdateGizmo();
void RemoveGizmo();
void ImGuiUpdate();
FBaseEntity* GetMainSelection() const
{
return MainSelection;
}
const vector<FBaseEntity*>& GetSelectedEntities() const
{
return SelectedEntities;
}
protected:
bool IsEntityInSelection(FBaseEntity* entity)
{
return std::find(SelectedEntities.begin(), SelectedEntities.end(), entity) != SelectedEntities.end();
}
private:
FEntityManager* EntityManager;
FEditorMaster* EditorMaster;
FBaseEntity* MainSelection;
vector<FBaseEntity*> SelectedEntities;
bool bAllowMultiSelect;
FNode* TranslateGizmoBasis;
FTranslateGizmo* TranslateGizmo;
FTranslateGizmoInputHandler* TranslateGizmoInputHandler;
};
} /* namespace tc */
| 21.6 | 109 | 0.711353 | [
"vector"
] |
7f3bde3aa50610ca4bd3ec82c564d73db75f2523 | 4,261 | h | C | cpp/include/doxygen_groups.h | JohnZed/cudf | 403d2571e5fcde66b7768b2213f6c142cc8b63db | [
"Apache-2.0"
] | null | null | null | cpp/include/doxygen_groups.h | JohnZed/cudf | 403d2571e5fcde66b7768b2213f6c142cc8b63db | [
"Apache-2.0"
] | 1 | 2022-01-18T19:36:35.000Z | 2022-01-18T19:36:35.000Z | cpp/include/doxygen_groups.h | JohnZed/cudf | 403d2571e5fcde66b7768b2213f6c142cc8b63db | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This header is only processed by doxygen and does
// not need to be included in any source file.
// Below are the main groups that doxygen uses to build
// the Modules page in the specified order.
//
// To add a new API to an existing group, just use the
// @ingroup tag to the API's doxygen comment.
// Add a new group by first specifying in the hierarchy below.
/**
* @defgroup cudf_classes Classes
* @{
* @defgroup column_classes Column
* @{
* @defgroup column_factories Factories
* @defgroup strings_classes Strings
* @defgroup dictionary_classes Dictionary
* @defgroup timestamp_classes Timestamp
* @}
* @defgroup table_classes Table
* @defgroup scalar_classes Scalar
* @{
* @defgroup scalar_factories Factories
* @}
* @defgroup fixed_point_classes Fixed Point
* @}
* @defgroup column_apis Column and Table
* @{
* @defgroup column_copy Copying
* @{
* @defgroup copy_concatenate Concatenating
* @defgroup copy_gather Gathering
* @defgroup copy_scatter Scattering
* @defgroup copy_slice Slicing
* @defgroup copy_split Splitting
* @defgroup copy_shift Shifting
* @}
* @defgroup column_nullmask Bitmask Operations
* @defgroup column_sort Sorting
* @defgroup column_search Searching
* @defgroup column_hash Hashing
* @defgroup column_merge Merging
* @defgroup column_join Joining
* @defgroup column_quantiles Quantiles
* @defgroup column_aggregation Aggregation
* @{
* @defgroup aggregation_factories Aggregation Factories
* @defgroup aggregation_reduction Reduction
* @defgroup aggregation_groupby GroupBy
* @defgroup aggregation_rolling Rolling Window
* @}
* @defgroup column_transformation Transformation
* @{
* @defgroup transformation_unaryops Unary Operations
* @defgroup transformation_binaryops Binary Operations
* @defgroup transformation_transform Transform
* @defgroup transformation_replace Replacing
* @defgroup transformation_fill Filling
* @}
* @defgroup column_reshape Reshaping
* @{
* @defgroup reshape_transpose Transpose
* @}
* @defgroup column_reorder Reordering
* @{
* @defgroup reorder_partition Partitioning
* @defgroup reorder_compact Stream Compaction
* @}
* @defgroup column_interop Interop
* @{
* @defgroup interop_dlpack DLPack
* @}
* @}
* @defgroup datetime_apis DateTime
* @{
* @defgroup datetime_extract Extracting
* @defgroup datetime_compute Compute Day
* @}
* @defgroup strings_apis Strings
* @{
* @defgroup strings_case Case
* @defgroup strings_types Character Types
* @defgroup strings_combine Combining
* @defgroup strings_contains Searching
* @defgroup strings_convert Converting
* @defgroup strings_substring Substring
* @defgroup strings_find Finding
* @defgroup strings_modify Modifying
* @defgroup strings_replace Replacing
* @defgroup strings_split Splitting
* @}
* @defgroup dictionary_apis Dictionary
* @{
* @defgroup dictionary_encode Encoding
* @defgroup dictionary_search Searching
* @defgroup dictionary_update Updating Keys
* @}
* @defgroup io_apis IO
* @{
* @defgroup io_readers Readers
* @defgroup io_writers Writers
* @}
* @defgroup nvtext_apis NVText
* @{
* @defgroup nvtext_ngrams NGrams
* @defgroup nvtext_normalize Normalizing
* @defgroup nvtext_tokenize Tokenizing
* @}
* @defgroup utility_apis Utilities
* @{
* @defgroup utility_types Types
* @defgroup utility_dispatcher Type Dispatcher
* @defgroup utility_bitmask Bitmask
* @defgroup utility_error Exception
* @}
*/
| 32.037594 | 75 | 0.718845 | [
"transform"
] |
7f3d53d05dff6fe65e3002ec065465ecd93e74ee | 3,649 | h | C | include/http/webhooks_handler.h | tomsksoft-llc/cis1-webui-native-srv-cpp | 9ac8f7867977a2f9af5713f60942200d25582f7f | [
"MIT"
] | 2 | 2019-04-26T07:48:26.000Z | 2019-06-03T07:04:22.000Z | include/http/webhooks_handler.h | tomsksoft-llc/cis1-webui-native-srv-cpp | 9ac8f7867977a2f9af5713f60942200d25582f7f | [
"MIT"
] | 73 | 2019-04-25T07:41:34.000Z | 2020-04-14T16:23:54.000Z | include/http/webhooks_handler.h | tomsksoft-llc/cis1-webui-native-srv-cpp | 9ac8f7867977a2f9af5713f60942200d25582f7f | [
"MIT"
] | null | null | null | /*
* TomskSoft CIS1 WebUI
*
* (c) 2019 TomskSoft LLC
* (c) Mokin Innokentiy [mia@tomsksoft.com]
*
*/
#pragma once
#include <string>
#include "net/http_session.h"
#include "handle_result.h"
#include "request_context.h"
#include "auth_manager.h"
#include "rights_manager.h"
#include "cis/cis_manager.h"
namespace beast = boost::beast;
namespace http
{
class webhooks_handler
{
public:
enum class api
{
github,
gitlab,
plain,
};
enum class hook_event
{
ping,
push,
tag_push,
issue,
note,
merge_request,
wiki_page,
pipeline,
build,
unknown,
};
webhooks_handler(
auth_manager& auth,
rights_manager& rights,
cis::cis_manager_interface& cis);
handle_result operator()(
beast::http::request<beast::http::empty_body>& req,
request_context& ctx,
net::http_session::request_reader& reader,
net::http_session::queue& queue,
const std::string& email,
const std::string& project,
const std::string& job,
const std::string& escaped_query_string,
api api_provider);
private:
auth_manager& auth_;
rights_manager& rights_;
cis::cis_manager_interface& cis_;
handle_result handle_github_headers(
beast::http::request<beast::http::empty_body>& req,
request_context& ctx,
net::http_session::request_reader& reader,
net::http_session::queue& queue,
const std::string& project,
const std::string& job,
const std::string& query_string);
handle_result handle_gitlab_headers(
beast::http::request<beast::http::empty_body>& req,
request_context& ctx,
net::http_session::request_reader& reader,
net::http_session::queue& queue,
const std::string& project,
const std::string& job,
const std::string& query_string);
handle_result handle_plain_headers(
beast::http::request<beast::http::empty_body>& req,
request_context& ctx,
net::http_session::request_reader& reader,
net::http_session::queue& queue,
const std::string& project,
const std::string& job,
const std::string& query_string);
void handle_github_signature(
beast::http::request<beast::http::string_body>&& req,
request_context& ctx,
net::http_session::queue& queue,
const std::string& project,
const std::string& job,
const std::string& query_string,
const std::string& raw_event,
hook_event ev,
const std::string& signature);
void finish(
beast::http::request<beast::http::string_body>&& req,
request_context& ctx,
net::http_session::queue& queue,
const std::string& project,
const std::string& job,
const std::string& query_string,
const std::string& raw_event,
hook_event ev);
std::filesystem::path save_body(std::string_view body);
const char* ev_to_string(hook_event ev);
std::vector<std::pair<std::string, std::string>> prepare_params(
const std::string& project,
const std::string& job,
const std::string& query_string,
const std::filesystem::path& body_file,
const std::string& raw_event,
hook_event ev);
};
} // namespace http
| 27.854962 | 68 | 0.582351 | [
"vector"
] |
7f400272e445796f8285f8799e4327fb4bc2d014 | 5,729 | h | C | platform/windows/Corona.Native.Library.Win32/Interop/Input/VibrationRequestManager.h | agramonte/corona | 3a6892f14eea92fdab5fa6d41920aa1e97bc22b1 | [
"MIT"
] | 1,968 | 2018-12-30T21:14:22.000Z | 2022-03-31T23:48:16.000Z | platform/windows/Corona.Native.Library.Win32/Interop/Input/VibrationRequestManager.h | agramonte/corona | 3a6892f14eea92fdab5fa6d41920aa1e97bc22b1 | [
"MIT"
] | 303 | 2019-01-02T19:36:43.000Z | 2022-03-31T23:52:45.000Z | platform/windows/Corona.Native.Library.Win32/Interop/Input/VibrationRequestManager.h | agramonte/corona | 3a6892f14eea92fdab5fa6d41920aa1e97bc22b1 | [
"MIT"
] | 254 | 2019-01-02T19:05:52.000Z | 2022-03-30T06:32:28.000Z | //////////////////////////////////////////////////////////////////////////////
//
// This file is part of the Corona game engine.
// For overview and more information on licensing please refer to README.md
// Home page: https://github.com/coronalabs/corona
// Contact: support@coronalabs.com
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "Interop\Event.h"
#include "Interop\EventArgs.h"
#include "Interop\Ticks.h"
#include "InputDeviceInterface.h"
namespace Interop { namespace Input {
/// <summary>
/// <para>Listens for vibration requests and manages the current vibration state for one input device.</para>
/// <para>
/// Instances of this class are expected to be held by MInputDeviceHandler derived class to process to
/// manage a device's current vibration state.
/// </para>
/// <para>
/// This manager's vibration request handler is expected to passed into the constructor of all InputDeviceContext
/// objects associated with an MInputDeviceHandler's device. These contexts will raise the vibration requests.
/// </para>
/// </summary>
class VibrationRequestManager
{
public:
#pragma region RequestType Enum
/// <summary>Indicates what vibration operation should be performed on a device.</summary>
enum class RequestType
{
/// <summary>
/// <para>Requests the device handler to do nothing with the device.</para>
/// <para>This means keep the device in its current vibration state (ie: vibrating or not vibrating).</para>
/// </summary>
kDoNothing,
/// <summary>Requests the device handler to "start" vibrating the device.</summary>
kStart,
/// <summary>Requests the device handler to "stop" vibrating the device.</summary>
kStop
};
#pragma endregion
#pragma region Constructors/Destructors
/// <summary>Creates a new vibration request manager.</summary>
VibrationRequestManager();
/// <summary>Destroys this object.</summary>
virtual ~VibrationRequestManager();
#pragma endregion
#pragma region Public Methods
/// <summary>
/// <para>Gets an event handler used to receive vibration requests.</para>
/// <para>
/// Invoking this handler will flag the device to be vibrated the next time this manager's
/// ProcessRequests() method gets called.
/// </para>
/// <para>
/// This handler is expected to be passed into an InputDeviceContext's constructor associated with
/// the device to be vibrated.
/// </para>
/// </summary>
/// <returns>Returns an event handler used to received/handle vibration requests.</returns>
const InputDeviceInterface::ReceivedVibrationRequestEvent::Handler* GetRequestHandler() const;
/// <summary>
/// <para>
/// Processes all vibration requests received by the handler returned by the GetRequestHandler() method.
/// </para>
/// <para>
/// Returns what vibration action should be performed on a device and updates the value returned
/// by the WasVibrationRequested() method.
/// </para>
/// <para>
/// This method is expected to be called at regular intervals, such as by an MInputDeviceHandler's Poll() method.
/// </para>
/// </summary>
/// <returns>
/// Returns what vibration action should be performed on the input device such as kStart, kStop, or kDoNothing.
/// The kDoNothing action indicates that the device should be left in its current state.
/// </returns>
VibrationRequestManager::RequestType ProcessRequests();
/// <summary>
/// <para>Clears all vibration requests and resets the current vibration state of the device to stopped.</para>
/// <para>This is expected to be called by an MInputDeviceHandler when detaching/disconnecting from a device.</para>
/// </summary>
void Reset();
/// <summary>
/// <para>Determines if the device should be currently vibrating/rumbling or not.</para>
/// <para>The value returned by this method only changes after calling the ProcessRequests() method.</para>
/// </summary>
/// <returns>
/// <para>
/// Returns true if a device should be currently vibrating. This happens when vibration requests
/// have been received by this manager's event handler from an InputDeviceInterface.
/// </para>
/// <para>Returns false if the device should no longer be vibrating.</para>
/// </returns>
bool WasVibrationRequested() const;
#pragma endregion
private:
#pragma region Private Methods
/// <summary>Called when a vibration request has been received.</summary>
/// <param name="sender">The object that is raising this event.</param>
/// <param name="arguments">Empty event arguments.</param>
void OnReceivedVibrationRequest(InputDeviceInterface& sender, const EventArgs& arguments);
#pragma endregion
#pragma region Private Member Variables
/// <summary>Handler to be invoked when a "ReceivedVibrationRequest" event has been raised.</summary>
InputDeviceInterface::ReceivedVibrationRequestEvent::MethodHandler<VibrationRequestManager> fReceivedVibrationRequestEventHandler;
/// <summary>Set true if the device should be currently vibrating. Set false if not.</summary>
bool fIsDeviceVibrating;
/// <summary>
/// <para>Set true if a vibration request has just been received.</para>
/// <para>This flag is expected to be cleared when the ProcessRequests() method gets called.</para>
/// </summary>
bool fHasReceivedVibrationRequest;
/// <summary>
/// <para>The time in system ticks that the device should stop vibrating.</para>
/// <para>Only applies if member variable "fIsDeviceVibrating" is set true.</para>
/// </summary>
Ticks fEndVibrationTimeInTicks;
#pragma endregion
};
} } // namespace Interop::Input
| 37.940397 | 132 | 0.695758 | [
"object"
] |
7f400cedd6a3a49c3e24245b553917cd5f289e2b | 36,816 | c | C | MDLiveShow/MDLiveShow/Classes/Other/Lib/Together/LFLiveKit/LFLiveKit/packet/flv/amf.c | ShangDuRuiORG/DuRuiMDLiveShow | 664f12d037f35a0b895d165e506afce63a2183de | [
"Apache-2.0"
] | 3,039 | 2016-07-05T17:54:27.000Z | 2022-03-29T07:01:55.000Z | MiaowShow/Pods/LFLiveKit/LFLiveKit/packet/flv/amf.c | youbooks/MiaowShow | 987cc53e091297be801675c8e155e3ccfe76bfb4 | [
"MIT"
] | 27 | 2016-07-06T13:42:08.000Z | 2019-10-10T02:42:23.000Z | MiaowShow/Pods/LFLiveKit/LFLiveKit/packet/flv/amf.c | youbooks/MiaowShow | 987cc53e091297be801675c8e155e3ccfe76bfb4 | [
"MIT"
] | 1,053 | 2016-07-05T23:19:07.000Z | 2022-03-28T06:43:20.000Z | /*
$Id: amf.c 231 2011-06-27 13:46:19Z marc.noirot $
FLV Metadata updater
Copyright (C) 2007-2012 Marc Noirot <marc.noirot AT gmail.com>
This file is part of FLVMeta.
FLVMeta is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FLVMeta is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FLVMeta; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <string.h>
#include "amf.h"
/* function common to all array types */
static void amf_list_init(amf_list * list) {
if (list != NULL) {
list->size = 0;
list->first_element = NULL;
list->last_element = NULL;
}
}
static amf_data * amf_list_push(amf_list * list, amf_data * data) {
amf_node * node = (amf_node*)malloc(sizeof(amf_node));
if (node != NULL) {
node->data = data;
node->next = NULL;
node->prev = NULL;
if (list->size == 0) {
list->first_element = node;
list->last_element = node;
}
else {
list->last_element->next = node;
node->prev = list->last_element;
list->last_element = node;
}
++(list->size);
return data;
}
return NULL;
}
static amf_data * amf_list_insert_before(amf_list * list, amf_node * node, amf_data * data) {
if (node != NULL) {
amf_node * new_node = (amf_node*)malloc(sizeof(amf_node));
if (new_node != NULL) {
new_node->next = node;
new_node->prev = node->prev;
if (node->prev != NULL) {
node->prev->next = new_node;
node->prev = new_node;
}
if (node == list->first_element) {
list->first_element = new_node;
}
++(list->size);
new_node->data = data;
return data;
}
}
return NULL;
}
static amf_data * amf_list_insert_after(amf_list * list, amf_node * node, amf_data * data) {
if (node != NULL) {
amf_node * new_node = (amf_node*)malloc(sizeof(amf_node));
if (new_node != NULL) {
new_node->next = node->next;
new_node->prev = node;
if (node->next != NULL) {
node->next->prev = new_node;
node->next = new_node;
}
if (node == list->last_element) {
list->last_element = new_node;
}
++(list->size);
new_node->data = data;
return data;
}
}
return NULL;
}
static amf_data * amf_list_delete(amf_list * list, amf_node * node) {
amf_data * data = NULL;
if (node != NULL) {
if (node->next != NULL) {
node->next->prev = node->prev;
}
if (node->prev != NULL) {
node->prev->next = node->next;
}
if (node == list->first_element) {
list->first_element = node->next;
}
if (node == list->last_element) {
list->last_element = node->prev;
}
data = node->data;
free(node);
--(list->size);
}
return data;
}
static amf_data * amf_list_get_at(const amf_list * list, uint32 n) {
if (n < list->size) {
uint32 i;
amf_node * node = list->first_element;
for (i = 0; i < n; ++i) {
node = node->next;
}
return node->data;
}
return NULL;
}
static amf_data * amf_list_pop(amf_list * list) {
return amf_list_delete(list, list->last_element);
}
static amf_node * amf_list_first(const amf_list * list) {
return list->first_element;
}
static amf_node * amf_list_last(const amf_list * list) {
return list->last_element;
}
static void amf_list_clear(amf_list * list) {
amf_node * tmp;
amf_node * node = list->first_element;
while (node != NULL) {
amf_data_free(node->data);
tmp = node;
node = node->next;
free(tmp);
}
list->size = 0;
}
static amf_list * amf_list_clone(const amf_list * list, amf_list * out_list) {
amf_node * node;
node = list->first_element;
while (node != NULL) {
amf_list_push(out_list, amf_data_clone(node->data));
node = node->next;
}
return out_list;
}
/* structure used to mimic a stream with a memory buffer */
typedef struct __buffer_context {
byte * start_address;
byte * current_address;
size_t buffer_size;
} buffer_context;
/* callback function to mimic fread using a memory buffer */
static size_t buffer_read(void * out_buffer, size_t size, void * user_data) {
buffer_context * ctxt = (buffer_context *)user_data;
if (ctxt->current_address >= ctxt->start_address &&
ctxt->current_address + size <= ctxt->start_address + ctxt->buffer_size) {
memcpy(out_buffer, ctxt->current_address, size);
ctxt->current_address += size;
return size;
}
else {
return 0;
}
}
/* callback function to mimic fwrite using a memory buffer */
static size_t buffer_write(const void * in_buffer, size_t size, void * user_data) {
buffer_context * ctxt = (buffer_context *)user_data;
if (ctxt->current_address >= ctxt->start_address &&
ctxt->current_address + size <= ctxt->start_address + ctxt->buffer_size) {
memcpy(ctxt->current_address, in_buffer, size);
ctxt->current_address += size;
return size;
}
else {
return 0;
}
}
/* allocate an AMF data object */
amf_data * amf_data_new(byte type) {
amf_data * data = (amf_data*)malloc(sizeof(amf_data));
if (data != NULL) {
data->type = type;
data->error_code = AMF_ERROR_OK;
}
return data;
}
/* read AMF data from buffer */
amf_data * amf_data_buffer_read(byte * buffer, size_t maxbytes) {
buffer_context ctxt;
ctxt.start_address = ctxt.current_address = buffer;
ctxt.buffer_size = maxbytes;
return amf_data_read(buffer_read, &ctxt);
}
/* write AMF data to buffer */
size_t amf_data_buffer_write(amf_data * data, byte * buffer, size_t maxbytes) {
buffer_context ctxt;
ctxt.start_address = ctxt.current_address = buffer;
ctxt.buffer_size = maxbytes;
return amf_data_write(data, buffer_write, &ctxt);
}
/* callback function to read data from a file stream */
static size_t file_read(void * out_buffer, size_t size, void * user_data) {
return fread(out_buffer, sizeof(byte), size, (FILE *)user_data);
}
/* callback function to write data to a file stream */
static size_t file_write(const void * in_buffer, size_t size, void * user_data) {
return fwrite(in_buffer, sizeof(byte), size, (FILE *)user_data);
}
/* load AMF data from a file stream */
amf_data * amf_data_file_read(FILE * stream) {
return amf_data_read(file_read, stream);
}
/* write AMF data into a file stream */
size_t amf_data_file_write(const amf_data * data, FILE * stream) {
return amf_data_write(data, file_write, stream);
}
/* read a number */
static amf_data * amf_number_read(amf_read_proc read_proc, void * user_data) {
number64_be val;
if (read_proc(&val, sizeof(number64_be), user_data) == sizeof(number64_be)) {
return amf_number_new(swap_number64(val));
}
else {
return amf_data_error(AMF_ERROR_EOF);
}
}
/* read a boolean */
static amf_data * amf_boolean_read(amf_read_proc read_proc, void * user_data) {
uint8 val;
if (read_proc(&val, sizeof(uint8), user_data) == sizeof(uint8)) {
return amf_boolean_new(val);
}
else {
return amf_data_error(AMF_ERROR_EOF);
}
}
/* read a string */
static amf_data * amf_string_read(amf_read_proc read_proc, void * user_data) {
uint16_be strsize;
byte * buffer;
if (read_proc(&strsize, sizeof(uint16_be), user_data) < sizeof(uint16_be)) {
return amf_data_error(AMF_ERROR_EOF);
}
strsize = swap_uint16(strsize);
if (strsize == 0) {
return amf_string_new(NULL, 0);
}
buffer = (byte*)calloc(strsize, sizeof(byte));
if (buffer == NULL) {
return NULL;
}
if (read_proc(buffer, strsize, user_data) == strsize) {
amf_data * data = amf_string_new(buffer, strsize);
free(buffer);
return data;
}
else {
free(buffer);
return amf_data_error(AMF_ERROR_EOF);
}
}
/* read an object */
static amf_data * amf_object_read(amf_read_proc read_proc, void * user_data) {
amf_data * name;
amf_data * element;
byte error_code;
amf_data * data;
data = amf_object_new();
if (data == NULL) {
return NULL;
}
while (1) {
name = amf_string_read(read_proc, user_data);
error_code = amf_data_get_error_code(name);
if (error_code != AMF_ERROR_OK) {
/* invalid name: error */
amf_data_free(name);
amf_data_free(data);
return amf_data_error(error_code);
}
element = amf_data_read(read_proc, user_data);
error_code = amf_data_get_error_code(element);
if (error_code == AMF_ERROR_END_TAG || error_code == AMF_ERROR_UNKNOWN_TYPE) {
/* end tag or unknown element: end of data, exit loop */
amf_data_free(name);
amf_data_free(element);
break;
}
else if (error_code != AMF_ERROR_OK) {
amf_data_free(name);
amf_data_free(data);
amf_data_free(element);
return amf_data_error(error_code);
}
if (amf_object_add(data, (char *)amf_string_get_bytes(name), element) == NULL) {
amf_data_free(name);
amf_data_free(element);
amf_data_free(data);
return NULL;
}
else {
amf_data_free(name);
}
}
return data;
}
/* read an associative array */
static amf_data * amf_associative_array_read(amf_read_proc read_proc, void * user_data) {
amf_data * name;
amf_data * element;
uint32_be size;
byte error_code;
amf_data * data;
data = amf_associative_array_new();
if (data == NULL) {
return NULL;
}
/* we ignore the 32 bits array size marker */
if (read_proc(&size, sizeof(uint32_be), user_data) < sizeof(uint32_be)) {
amf_data_free(data);
return amf_data_error(AMF_ERROR_EOF);
}
while(1) {
name = amf_string_read(read_proc, user_data);
error_code = amf_data_get_error_code(name);
if (error_code != AMF_ERROR_OK) {
/* invalid name: error */
amf_data_free(name);
amf_data_free(data);
return amf_data_error(error_code);
}
element = amf_data_read(read_proc, user_data);
error_code = amf_data_get_error_code(element);
if (amf_string_get_size(name) == 0 || error_code == AMF_ERROR_END_TAG || error_code == AMF_ERROR_UNKNOWN_TYPE) {
/* end tag or unknown element: end of data, exit loop */
amf_data_free(name);
amf_data_free(element);
break;
}
else if (error_code != AMF_ERROR_OK) {
amf_data_free(name);
amf_data_free(data);
amf_data_free(element);
return amf_data_error(error_code);
}
if (amf_associative_array_add(data, (char *)amf_string_get_bytes(name), element) == NULL) {
amf_data_free(name);
amf_data_free(element);
amf_data_free(data);
return NULL;
}
else {
amf_data_free(name);
}
}
return data;
}
/* read an array */
static amf_data * amf_array_read(amf_read_proc read_proc, void * user_data) {
size_t i;
amf_data * element;
byte error_code;
amf_data * data;
uint32 array_size;
data = amf_array_new();
if (data == NULL) {
return NULL;
}
if (read_proc(&array_size, sizeof(uint32), user_data) < sizeof(uint32)) {
amf_data_free(data);
return amf_data_error(AMF_ERROR_EOF);
}
array_size = swap_uint32(array_size);
for (i = 0; i < array_size; ++i) {
element = amf_data_read(read_proc, user_data);
error_code = amf_data_get_error_code(element);
if (error_code != AMF_ERROR_OK) {
amf_data_free(element);
amf_data_free(data);
return amf_data_error(error_code);
}
if (amf_array_push(data, element) == NULL) {
amf_data_free(element);
amf_data_free(data);
return NULL;
}
}
return data;
}
/* read a date */
static amf_data * amf_date_read(amf_read_proc read_proc, void * user_data) {
number64_be milliseconds;
sint16_be timezone;
if (read_proc(&milliseconds, sizeof(number64_be), user_data) == sizeof(number64_be) &&
read_proc(&timezone, sizeof(sint16_be), user_data) == sizeof(sint16_be)) {
return amf_date_new(swap_number64(milliseconds), swap_sint16(timezone));
}
else {
return amf_data_error(AMF_ERROR_EOF);
}
}
/* load AMF data from stream */
amf_data * amf_data_read(amf_read_proc read_proc, void * user_data) {
byte type;
if (read_proc(&type, sizeof(byte), user_data) < sizeof(byte)) {
return amf_data_error(AMF_ERROR_EOF);
}
switch (type) {
case AMF_TYPE_NUMBER:
return amf_number_read(read_proc, user_data);
case AMF_TYPE_BOOLEAN:
return amf_boolean_read(read_proc, user_data);
case AMF_TYPE_STRING:
return amf_string_read(read_proc, user_data);
case AMF_TYPE_OBJECT:
return amf_object_read(read_proc, user_data);
case AMF_TYPE_NULL:
return amf_null_new();
case AMF_TYPE_UNDEFINED:
return amf_undefined_new();
/*case AMF_TYPE_REFERENCE:*/
case AMF_TYPE_ASSOCIATIVE_ARRAY:
return amf_associative_array_read(read_proc, user_data);
case AMF_TYPE_ARRAY:
return amf_array_read(read_proc, user_data);
case AMF_TYPE_DATE:
return amf_date_read(read_proc, user_data);
/*case AMF_TYPE_SIMPLEOBJECT:*/
case AMF_TYPE_XML:
case AMF_TYPE_CLASS:
return amf_data_error(AMF_ERROR_UNSUPPORTED_TYPE);
case AMF_TYPE_END:
return amf_data_error(AMF_ERROR_END_TAG); /* end of composite object */
default:
return amf_data_error(AMF_ERROR_UNKNOWN_TYPE);
}
}
/* determines the size of the given AMF data */
size_t amf_data_size(const amf_data * data) {
size_t s = 0;
amf_node * node;
if (data != NULL) {
s += sizeof(byte);
switch (data->type) {
case AMF_TYPE_NUMBER:
s += sizeof(number64_be);
break;
case AMF_TYPE_BOOLEAN:
s += sizeof(uint8);
break;
case AMF_TYPE_STRING:
s += sizeof(uint16) + (size_t)amf_string_get_size(data);
break;
case AMF_TYPE_OBJECT:
node = amf_object_first(data);
while (node != NULL) {
s += sizeof(uint16) + (size_t)amf_string_get_size(amf_object_get_name(node));
s += (size_t)amf_data_size(amf_object_get_data(node));
node = amf_object_next(node);
}
s += sizeof(uint16) + sizeof(uint8);
break;
case AMF_TYPE_NULL:
case AMF_TYPE_UNDEFINED:
break;
/*case AMF_TYPE_REFERENCE:*/
case AMF_TYPE_ASSOCIATIVE_ARRAY:
s += sizeof(uint32);
node = amf_associative_array_first(data);
while (node != NULL) {
s += sizeof(uint16) + (size_t)amf_string_get_size(amf_associative_array_get_name(node));
s += (size_t)amf_data_size(amf_associative_array_get_data(node));
node = amf_associative_array_next(node);
}
s += sizeof(uint16) + sizeof(uint8);
break;
case AMF_TYPE_ARRAY:
s += sizeof(uint32);
node = amf_array_first(data);
while (node != NULL) {
s += (size_t)amf_data_size(amf_array_get(node));
node = amf_array_next(node);
}
break;
case AMF_TYPE_DATE:
s += sizeof(number64) + sizeof(sint16);
break;
/*case AMF_TYPE_SIMPLEOBJECT:*/
case AMF_TYPE_XML:
case AMF_TYPE_CLASS:
case AMF_TYPE_END:
break; /* end of composite object */
default:
break;
}
}
return s;
}
/* write a number */
static size_t amf_number_write(const amf_data * data, amf_write_proc write_proc, void * user_data) {
number64 n = swap_number64(data->number_data);
return write_proc(&n, sizeof(number64_be), user_data);
}
/* write a boolean */
static size_t amf_boolean_write(const amf_data * data, amf_write_proc write_proc, void * user_data) {
return write_proc(&(data->boolean_data), sizeof(uint8), user_data);
}
/* write a string */
static size_t amf_string_write(const amf_data * data, amf_write_proc write_proc, void * user_data) {
uint16 s;
size_t w = 0;
s = swap_uint16(data->string_data.size);
w = write_proc(&s, sizeof(uint16_be), user_data);
if (data->string_data.size > 0) {
w += write_proc(data->string_data.mbstr, (size_t)(data->string_data.size), user_data);
}
return w;
}
/* write an object */
static size_t amf_object_write(const amf_data * data, amf_write_proc write_proc, void * user_data) {
amf_node * node;
size_t w = 0;
uint16_be filler = swap_uint16(0);
uint8 terminator = AMF_TYPE_END;
node = amf_object_first(data);
while (node != NULL) {
w += amf_string_write(amf_object_get_name(node), write_proc, user_data);
w += amf_data_write(amf_object_get_data(node), write_proc, user_data);
node = amf_object_next(node);
}
/* empty string is the last element */
w += write_proc(&filler, sizeof(uint16_be), user_data);
/* an object ends with 0x09 */
w += write_proc(&terminator, sizeof(uint8), user_data);
return w;
}
/* write an associative array */
static size_t amf_associative_array_write(const amf_data * data, amf_write_proc write_proc, void * user_data) {
amf_node * node;
size_t w = 0;
uint32_be s;
uint16_be filler = swap_uint16(0);
uint8 terminator = AMF_TYPE_END;
s = swap_uint32(data->list_data.size) / 2;
w += write_proc(&s, sizeof(uint32_be), user_data);
node = amf_associative_array_first(data);
while (node != NULL) {
w += amf_string_write(amf_associative_array_get_name(node), write_proc, user_data);
w += amf_data_write(amf_associative_array_get_data(node), write_proc, user_data);
node = amf_associative_array_next(node);
}
/* empty string is the last element */
w += write_proc(&filler, sizeof(uint16_be), user_data);
/* an object ends with 0x09 */
w += write_proc(&terminator, sizeof(uint8), user_data);
return w;
}
/* write an array */
static size_t amf_array_write(const amf_data * data, amf_write_proc write_proc, void * user_data) {
amf_node * node;
size_t w = 0;
uint32_be s;
s = swap_uint32(data->list_data.size);
w += write_proc(&s, sizeof(uint32_be), user_data);
node = amf_array_first(data);
while (node != NULL) {
w += amf_data_write(amf_array_get(node), write_proc, user_data);
node = amf_array_next(node);
}
return w;
}
/* write a date */
static size_t amf_date_write(const amf_data * data, amf_write_proc write_proc, void * user_data) {
size_t w = 0;
number64_be milli;
sint16_be tz;
milli = swap_number64(data->date_data.milliseconds);
w += write_proc(&milli, sizeof(number64_be), user_data);
tz = swap_sint16(data->date_data.timezone);
w += write_proc(&tz, sizeof(sint16_be), user_data);
return w;
}
/* write amf data to stream */
size_t amf_data_write(const amf_data * data, amf_write_proc write_proc, void * user_data) {
size_t s = 0;
if (data != NULL) {
s += write_proc(&(data->type), sizeof(byte), user_data);
switch (data->type) {
case AMF_TYPE_NUMBER:
s += amf_number_write(data, write_proc, user_data);
break;
case AMF_TYPE_BOOLEAN:
s += amf_boolean_write(data, write_proc, user_data);
break;
case AMF_TYPE_STRING:
s += amf_string_write(data, write_proc, user_data);
break;
case AMF_TYPE_OBJECT:
s += amf_object_write(data, write_proc, user_data);
break;
case AMF_TYPE_NULL:
case AMF_TYPE_UNDEFINED:
break;
/*case AMF_TYPE_REFERENCE:*/
case AMF_TYPE_ASSOCIATIVE_ARRAY:
s += amf_associative_array_write(data, write_proc, user_data);
break;
case AMF_TYPE_ARRAY:
s += amf_array_write(data, write_proc, user_data);
break;
case AMF_TYPE_DATE:
s += amf_date_write(data, write_proc, user_data);
break;
/*case AMF_TYPE_SIMPLEOBJECT:*/
case AMF_TYPE_XML:
case AMF_TYPE_CLASS:
case AMF_TYPE_END:
break; /* end of composite object */
default:
break;
}
}
return s;
}
/* data type */
byte amf_data_get_type(const amf_data * data) {
return (data != NULL) ? data->type : AMF_TYPE_NULL;
}
/* error code */
byte amf_data_get_error_code(const amf_data * data) {
return (data != NULL) ? data->error_code : AMF_ERROR_NULL_POINTER;
}
/* clone AMF data */
amf_data * amf_data_clone(const amf_data * data) {
/* we copy data recursively */
if (data != NULL) {
switch (data->type) {
case AMF_TYPE_NUMBER: return amf_number_new(amf_number_get_value(data));
case AMF_TYPE_BOOLEAN: return amf_boolean_new(amf_boolean_get_value(data));
case AMF_TYPE_STRING:
if (data->string_data.mbstr != NULL) {
return amf_string_new((byte *)strdup((char *)amf_string_get_bytes(data)), amf_string_get_size(data));
}
else {
return amf_str(NULL);
}
case AMF_TYPE_NULL: return NULL;
case AMF_TYPE_UNDEFINED: return NULL;
/*case AMF_TYPE_REFERENCE:*/
case AMF_TYPE_OBJECT:
case AMF_TYPE_ASSOCIATIVE_ARRAY:
case AMF_TYPE_ARRAY:
{
amf_data * d = amf_data_new(data->type);
if (d != NULL) {
amf_list_init(&d->list_data);
amf_list_clone(&data->list_data, &d->list_data);
}
return d;
}
case AMF_TYPE_DATE: return amf_date_new(amf_date_get_milliseconds(data), amf_date_get_timezone(data));
/*case AMF_TYPE_SIMPLEOBJECT:*/
case AMF_TYPE_XML: return NULL;
case AMF_TYPE_CLASS: return NULL;
}
}
return NULL;
}
/* free AMF data */
void amf_data_free(amf_data * data) {
if (data != NULL) {
switch (data->type) {
case AMF_TYPE_NUMBER: break;
case AMF_TYPE_BOOLEAN: break;
case AMF_TYPE_STRING:
if (data->string_data.mbstr != NULL) {
free(data->string_data.mbstr);
} break;
case AMF_TYPE_NULL: break;
case AMF_TYPE_UNDEFINED: break;
/*case AMF_TYPE_REFERENCE:*/
case AMF_TYPE_OBJECT:
case AMF_TYPE_ASSOCIATIVE_ARRAY:
case AMF_TYPE_ARRAY: amf_list_clear(&data->list_data); break;
case AMF_TYPE_DATE: break;
/*case AMF_TYPE_SIMPLEOBJECT:*/
case AMF_TYPE_XML: break;
case AMF_TYPE_CLASS: break;
default: break;
}
free(data);
}
}
/* dump AMF data into a stream as text */
void amf_data_dump(FILE * stream, const amf_data * data, int indent_level) {
if (data != NULL) {
amf_node * node;
time_t time;
struct tm * t = NULL;
char datestr[128];
switch (data->type) {
case AMF_TYPE_NUMBER:
fprintf(stream, "%.12g", data->number_data);
break;
case AMF_TYPE_BOOLEAN:
fprintf(stream, "%s", (data->boolean_data) ? "true" : "false");
break;
case AMF_TYPE_STRING:
fprintf(stream, "\'%.*s\'", data->string_data.size, data->string_data.mbstr);
break;
case AMF_TYPE_OBJECT:
node = amf_object_first(data);
fprintf(stream, "{\n");
while (node != NULL) {
fprintf(stream, "%*s", (indent_level+1)*4, "");
amf_data_dump(stream, amf_object_get_name(node), indent_level+1);
fprintf(stream, ": ");
amf_data_dump(stream, amf_object_get_data(node), indent_level+1);
node = amf_object_next(node);
fprintf(stream, "\n");
}
fprintf(stream, "%*s", indent_level*4 + 1, "}");
break;
case AMF_TYPE_NULL:
fprintf(stream, "null");
break;
case AMF_TYPE_UNDEFINED:
fprintf(stream, "undefined");
break;
/*case AMF_TYPE_REFERENCE:*/
case AMF_TYPE_ASSOCIATIVE_ARRAY:
node = amf_associative_array_first(data);
fprintf(stream, "{\n");
while (node != NULL) {
fprintf(stream, "%*s", (indent_level+1)*4, "");
amf_data_dump(stream, amf_associative_array_get_name(node), indent_level+1);
fprintf(stream, " => ");
amf_data_dump(stream, amf_associative_array_get_data(node), indent_level+1);
node = amf_associative_array_next(node);
fprintf(stream, "\n");
}
fprintf(stream, "%*s", indent_level*4 + 1, "}");
break;
case AMF_TYPE_ARRAY:
node = amf_array_first(data);
fprintf(stream, "[\n");
while (node != NULL) {
fprintf(stream, "%*s", (indent_level+1)*4, "");
amf_data_dump(stream, node->data, indent_level+1);
node = amf_array_next(node);
fprintf(stream, "\n");
}
fprintf(stream, "%*s", indent_level*4 + 1, "]");
break;
case AMF_TYPE_DATE:
time = amf_date_to_time_t(data);
tzset();
localtime_r(&time,t);
strftime(datestr, sizeof(datestr), "%a, %d %b %Y %H:%M:%S %z", t);
fprintf(stream, "%s", datestr);
break;
/*case AMF_TYPE_SIMPLEOBJECT:*/
case AMF_TYPE_XML: break;
case AMF_TYPE_CLASS: break;
default: break;
}
}
}
/* return a null AMF object with the specified error code attached to it */
amf_data * amf_data_error(byte error_code) {
amf_data * data = amf_null_new();
if (data != NULL) {
data->error_code = error_code;
}
return data;
}
/* number functions */
amf_data * amf_number_new(number64 value) {
amf_data * data = amf_data_new(AMF_TYPE_NUMBER);
if (data != NULL) {
data->number_data = value;
}
return data;
}
amf_data * amf_number_double(double value) {
amf_data * data = amf_data_new(AMF_TYPE_NUMBER);
if (data != NULL) {
data->number_data = value;
}
return data;
}
number64 amf_number_get_value(const amf_data * data) {
return (data != NULL) ? data->number_data : 0;
}
void amf_number_set_value(amf_data * data, number64 value) {
if (data != NULL) {
data->number_data = value;
}
}
/* boolean functions */
amf_data * amf_boolean_new(uint8 value) {
amf_data * data = amf_data_new(AMF_TYPE_BOOLEAN);
if (data != NULL) {
data->boolean_data = value;
}
return data;
}
uint8 amf_boolean_get_value(const amf_data * data) {
return (data != NULL) ? data->boolean_data : 0;
}
void amf_boolean_set_value(amf_data * data, uint8 value) {
if (data != NULL) {
data->boolean_data = value;
}
}
/* string functions */
amf_data * amf_string_new(byte * str, uint16 size) {
amf_data * data = amf_data_new(AMF_TYPE_STRING);
if (data != NULL) {
if (str == NULL) {
data->string_data.size = 0;
}
else {
data->string_data.size = size;
}
data->string_data.mbstr = (byte*)calloc(size+1, sizeof(byte));
if (data->string_data.mbstr != NULL) {
if (data->string_data.size > 0) {
memcpy(data->string_data.mbstr, str, data->string_data.size);
}
}
else {
amf_data_free(data);
return NULL;
}
}
return data;
}
amf_data * amf_str(const char * str) {
return amf_string_new((byte *)str, (uint16)(str != NULL ? strlen(str) : 0));
}
uint16 amf_string_get_size(const amf_data * data) {
return (data != NULL) ? data->string_data.size : 0;
}
byte * amf_string_get_bytes(const amf_data * data) {
return (data != NULL) ? data->string_data.mbstr : NULL;
}
/* object functions */
amf_data * amf_object_new(void) {
amf_data * data = amf_data_new(AMF_TYPE_OBJECT);
if (data != NULL) {
amf_list_init(&data->list_data);
}
return data;
}
uint32 amf_object_size(const amf_data * data) {
return (data != NULL) ? data->list_data.size / 2 : 0;
}
amf_data * amf_object_add(amf_data * data, const char * name, amf_data * element) {
if (data != NULL) {
if (amf_list_push(&data->list_data, amf_str(name)) != NULL) {
if (amf_list_push(&data->list_data, element) != NULL) {
return element;
}
else {
amf_data_free(amf_list_pop(&data->list_data));
}
}
}
return NULL;
}
amf_data * amf_object_get(const amf_data * data, const char * name) {
if (data != NULL) {
amf_node * node = amf_list_first(&(data->list_data));
while (node != NULL) {
if (strncmp((char*)(node->data->string_data.mbstr), name, (size_t)(node->data->string_data.size)) == 0) {
node = node->next;
return (node != NULL) ? node->data : NULL;
}
/* we have to skip the element data to reach the next name */
node = node->next->next;
}
}
return NULL;
}
amf_data * amf_object_set(amf_data * data, const char * name, amf_data * element) {
if (data != NULL) {
amf_node * node = amf_list_first(&(data->list_data));
while (node != NULL) {
if (strncmp((char*)(node->data->string_data.mbstr), name, (size_t)(node->data->string_data.size)) == 0) {
node = node->next;
if (node != NULL && node->data != NULL) {
amf_data_free(node->data);
node->data = element;
return element;
}
}
/* we have to skip the element data to reach the next name */
node = node->next->next;
}
}
return NULL;
}
amf_data * amf_object_delete(amf_data * data, const char * name) {
if (data != NULL) {
amf_node * node = amf_list_first(&data->list_data);
while (node != NULL) {
node = node->next;
if (strncmp((char*)(node->data->string_data.mbstr), name, (size_t)(node->data->string_data.size)) == 0) {
amf_node * data_node = node->next;
amf_data_free(amf_list_delete(&data->list_data, node));
return amf_list_delete(&data->list_data, data_node);
}
else {
node = node->next;
}
}
}
return NULL;
}
amf_node * amf_object_first(const amf_data * data) {
return (data != NULL) ? amf_list_first(&data->list_data) : NULL;
}
amf_node * amf_object_last(const amf_data * data) {
if (data != NULL) {
amf_node * node = amf_list_last(&data->list_data);
if (node != NULL) {
return node->prev;
}
}
return NULL;
}
amf_node * amf_object_next(amf_node * node) {
if (node != NULL) {
amf_node * next = node->next;
if (next != NULL) {
return next->next;
}
}
return NULL;
}
amf_node * amf_object_prev(amf_node * node) {
if (node != NULL) {
amf_node * prev = node->prev;
if (prev != NULL) {
return prev->prev;
}
}
return NULL;
}
amf_data * amf_object_get_name(amf_node * node) {
return (node != NULL) ? node->data : NULL;
}
amf_data * amf_object_get_data(amf_node * node) {
if (node != NULL) {
amf_node * next = node->next;
if (next != NULL) {
return next->data;
}
}
return NULL;
}
/* associative array functions */
amf_data * amf_associative_array_new(void) {
amf_data * data = amf_data_new(AMF_TYPE_ASSOCIATIVE_ARRAY);
if (data != NULL) {
amf_list_init(&data->list_data);
}
return data;
}
/* array functions */
amf_data * amf_array_new(void) {
amf_data * data = amf_data_new(AMF_TYPE_ARRAY);
if (data != NULL) {
amf_list_init(&data->list_data);
}
return data;
}
uint32 amf_array_size(const amf_data * data) {
return (data != NULL) ? data->list_data.size : 0;
}
amf_data * amf_array_push(amf_data * data, amf_data * element) {
return (data != NULL) ? amf_list_push(&data->list_data, element) : NULL;
}
amf_data * amf_array_pop(amf_data * data) {
return (data != NULL) ? amf_list_pop(&data->list_data) : NULL;
}
amf_node * amf_array_first(const amf_data * data) {
return (data != NULL) ? amf_list_first(&data->list_data) : NULL;
}
amf_node * amf_array_last(const amf_data * data) {
return (data != NULL) ? amf_list_last(&data->list_data) : NULL;
}
amf_node * amf_array_next(amf_node * node) {
return (node != NULL) ? node->next : NULL;
}
amf_node * amf_array_prev(amf_node * node) {
return (node != NULL) ? node->prev : NULL;
}
amf_data * amf_array_get(amf_node * node) {
return (node != NULL) ? node->data : NULL;
}
amf_data * amf_array_get_at(const amf_data * data, uint32 n) {
return (data != NULL) ? amf_list_get_at(&data->list_data, n) : NULL;
}
amf_data * amf_array_delete(amf_data * data, amf_node * node) {
return (data != NULL) ? amf_list_delete(&data->list_data, node) : NULL;
}
amf_data * amf_array_insert_before(amf_data * data, amf_node * node, amf_data * element) {
return (data != NULL) ? amf_list_insert_before(&data->list_data, node, element) : NULL;
}
amf_data * amf_array_insert_after(amf_data * data, amf_node * node, amf_data * element) {
return (data != NULL) ? amf_list_insert_after(&data->list_data, node, element) : NULL;
}
/* date functions */
amf_data * amf_date_new(number64 milliseconds, sint16 timezone) {
amf_data * data = amf_data_new(AMF_TYPE_DATE);
if (data != NULL) {
data->date_data.milliseconds = milliseconds;
data->date_data.timezone = timezone;
}
return data;
}
number64 amf_date_get_milliseconds(const amf_data * data) {
return (data != NULL) ? data->date_data.milliseconds : (number64)0.0;
}
sint16 amf_date_get_timezone(const amf_data * data) {
return (data != NULL) ? data->date_data.timezone : 0;
}
time_t amf_date_to_time_t(const amf_data * data) {
return (time_t)((data != NULL) ? data->date_data.milliseconds / 1000 : 0);
}
| 31.547558 | 121 | 0.583795 | [
"object"
] |
7f42436365fa2daddf410bdb992568b6857665d8 | 20,513 | h | C | module/dmc500/include/mod_dmc500.h | vijayenthiran-arm/SCP-firmware | b566d7da67a048bec2ce16504d2e7b55f83237e4 | [
"BSD-3-Clause"
] | null | null | null | module/dmc500/include/mod_dmc500.h | vijayenthiran-arm/SCP-firmware | b566d7da67a048bec2ce16504d2e7b55f83237e4 | [
"BSD-3-Clause"
] | null | null | null | module/dmc500/include/mod_dmc500.h | vijayenthiran-arm/SCP-firmware | b566d7da67a048bec2ce16504d2e7b55f83237e4 | [
"BSD-3-Clause"
] | null | null | null | /*
* Arm SCP/MCP Software
* Copyright (c) 2015-2018, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Description:
* DMC-500 module.
*/
#ifndef MOD_DMC500_H
#define MOD_DMC500_H
#include <stdint.h>
#include <fwk_macros.h>
#include <fwk_module.h>
#include <mod_log.h>
#include <mod_timer.h>
/*!
* \addtogroup GroupModules Modules
* @{
*/
/*!
* \addtogroup GroupDMC DMC-500 Driver
*
* \details Please consult the Arm CoreLink DMC-500 Dynamic Memory Controller
* Technical Reference Manual for details on the specific registers that
* are programmed here.
*
* \sa https://developer.arm.com/docs/100132_0000/latest/programmers-model/
register-summary
* @{
*/
/*!
* \brief DMC-500 register definitions
*/
struct mod_dmc500_reg {
/*!
* \cond
* @{
*/
FWK_R uint32_t SI0_SI_STATUS;
FWK_R uint32_t SI0_SI_INTERRUPT_STATUS;
FWK_R uint32_t SI0_TZ_FAIL_ADDRESS_LOW;
FWK_R uint32_t SI0_TZ_FAIL_ADDRESS_HIGH;
FWK_R uint32_t SI0_TZ_FAIL_CONTROL;
FWK_R uint32_t SI0_TZ_FAIL_ID;
FWK_R uint32_t SI0_PMU_REQ_INT_INFO;
FWK_RW uint32_t SI0_PMU_REQ_COUNT0;
FWK_RW uint32_t SI0_PMU_REQ_COUNT1;
FWK_RW uint32_t SI0_PMU_REQ_COUNT2;
FWK_RW uint32_t SI0_PMU_REQ_COUNT3;
FWK_RW uint32_t SI0_PMU_SCLK_COUNT_COUNT;
FWK_RW uint32_t SI0_SI_STATE_CONTROL;
FWK_W uint32_t SI0_SI_FLUSH_CONTROL;
FWK_RW uint32_t ADDRESS_CONTROL;
FWK_RW uint32_t DECODE_CONTROL;
FWK_RW uint32_t ADDRESS_MAP;
FWK_RW uint32_t RANK_REMAP_CONTROL;
FWK_RW uint32_t SI0_SI_INTERRUPT_CONTROL;
FWK_W uint32_t SI0_SI_INTERRUPT_CLR;
FWK_RW uint32_t TZ_ACTION;
FWK_R uint32_t SI0_TZ_REGION_BASE_LOW_0;
FWK_R uint32_t SI0_TZ_REGION_BASE_HIGH_0;
FWK_RW uint32_t SI0_TZ_REGION_TOP_LOW_0;
FWK_RW uint32_t SI0_TZ_REGION_TOP_HIGH_0;
FWK_RW uint32_t SI0_TZ_REGION_ATTRIBUTES_0;
FWK_RW uint32_t SI0_TZ_REGION_ID_ACCESS_0;
FWK_RW uint32_t SI0_TZ_REGION_BASE_LOW_1;
FWK_RW uint32_t SI0_TZ_REGION_BASE_HIGH_1;
FWK_RW uint32_t SI0_TZ_REGION_TOP_LOW_1;
FWK_RW uint32_t SI0_TZ_REGION_TOP_HIGH_1;
FWK_RW uint32_t SI0_TZ_REGION_ATTRIBUTES_1;
FWK_RW uint32_t SI0_TZ_REGION_ID_ACCESS_1;
FWK_RW uint32_t SI0_TZ_REGION_BASE_LOW_2;
FWK_RW uint32_t SI0_TZ_REGION_BASE_HIGH_2;
FWK_RW uint32_t SI0_TZ_REGION_TOP_LOW_2;
FWK_RW uint32_t SI0_TZ_REGION_TOP_HIGH_2;
FWK_RW uint32_t SI0_TZ_REGION_ATTRIBUTES_2;
FWK_RW uint32_t SI0_TZ_REGION_ID_ACCESS_2;
FWK_RW uint32_t SI0_TZ_REGION_BASE_LOW_3;
FWK_RW uint32_t SI0_TZ_REGION_BASE_HIGH_3;
FWK_RW uint32_t SI0_TZ_REGION_TOP_LOW_3;
FWK_RW uint32_t SI0_TZ_REGION_TOP_HIGH_3;
FWK_RW uint32_t SI0_TZ_REGION_ATTRIBUTES_3;
FWK_RW uint32_t SI0_TZ_REGION_ID_ACCESS_3;
FWK_RW uint32_t SI0_TZ_REGION_BASE_LOW_4;
FWK_RW uint32_t SI0_TZ_REGION_BASE_HIGH_4;
FWK_RW uint32_t SI0_TZ_REGION_TOP_LOW_4;
FWK_RW uint32_t SI0_TZ_REGION_TOP_HIGH_4;
FWK_RW uint32_t SI0_TZ_REGION_ATTRIBUTES_4;
FWK_RW uint32_t SI0_TZ_REGION_ID_ACCESS_4;
FWK_RW uint32_t SI0_TZ_REGION_BASE_LOW_5;
FWK_RW uint32_t SI0_TZ_REGION_BASE_HIGH_5;
FWK_RW uint32_t SI0_TZ_REGION_TOP_LOW_5;
FWK_RW uint32_t SI0_TZ_REGION_TOP_HIGH_5;
FWK_RW uint32_t SI0_TZ_REGION_ATTRIBUTES_5;
FWK_RW uint32_t SI0_TZ_REGION_ID_ACCESS_5;
FWK_RW uint32_t SI0_TZ_REGION_BASE_LOW_6;
FWK_RW uint32_t SI0_TZ_REGION_BASE_HIGH_6;
FWK_RW uint32_t SI0_TZ_REGION_TOP_LOW_6;
FWK_RW uint32_t SI0_TZ_REGION_TOP_HIGH_6;
FWK_RW uint32_t SI0_TZ_REGION_ATTRIBUTES_6;
FWK_RW uint32_t SI0_TZ_REGION_ID_ACCESS_6;
FWK_RW uint32_t SI0_TZ_REGION_BASE_LOW_7;
FWK_RW uint32_t SI0_TZ_REGION_BASE_HIGH_7;
FWK_RW uint32_t SI0_TZ_REGION_TOP_LOW_7;
FWK_RW uint32_t SI0_TZ_REGION_TOP_HIGH_7;
FWK_RW uint32_t SI0_TZ_REGION_ATTRIBUTES_7;
FWK_RW uint32_t SI0_TZ_REGION_ID_ACCESS_7;
FWK_RW uint32_t SI0_TZ_REGION_BASE_LOW_8;
FWK_RW uint32_t SI0_TZ_REGION_BASE_HIGH_8;
FWK_RW uint32_t SI0_TZ_REGION_TOP_LOW_8;
FWK_RW uint32_t SI0_TZ_REGION_TOP_HIGH_8;
FWK_RW uint32_t SI0_TZ_REGION_ATTRIBUTES_8;
FWK_RW uint32_t SI0_TZ_REGION_ID_ACCESS_8;
FWK_RW uint32_t SI0_PMU_REQ_CONTROL;
FWK_RW uint32_t SI0_PMU_REQ_ATTRIBUTE_MASK_0;
FWK_RW uint32_t SI0_PMU_REQ_ATTRIBUTE_MATCH_0;
FWK_RW uint32_t SI0_PMU_REQ_ATTRIBUTE_MASK_1;
FWK_RW uint32_t SI0_PMU_REQ_ATTRIBUTE_MATCH_1;
FWK_RW uint32_t SI0_PMU_REQ_ATTRIBUTE_MASK_2;
FWK_RW uint32_t SI0_PMU_REQ_ATTRIBUTE_MATCH_2;
FWK_RW uint32_t SI0_PMU_REQ_ATTRIBUTE_MASK_3;
FWK_RW uint32_t SI0_PMU_REQ_ATTRIBUTE_MATCH_3;
FWK_RW uint32_t SI0_THRESHOLD_CONTROL;
uint8_t RESERVED0[0x200 - 0x154];
FWK_R uint32_t SI1_SI_STATUS;
FWK_R uint32_t SI1_SI_INTERRUPT_STATUS;
FWK_R uint32_t SI1_TZ_FAIL_ADDRESS_LOW;
FWK_R uint32_t SI1_TZ_FAIL_ADDRESS_HIGH;
FWK_R uint32_t SI1_TZ_FAIL_CONTROL;
FWK_R uint32_t SI1_TZ_FAIL_ID;
FWK_R uint32_t SI1_PMU_REQ_INT_INFO;
FWK_RW uint32_t SI1_PMU_REQ_COUNT0;
FWK_RW uint32_t SI1_PMU_REQ_COUNT1;
FWK_RW uint32_t SI1_PMU_REQ_COUNT2;
FWK_RW uint32_t SI1_PMU_REQ_COUNT3;
FWK_RW uint32_t SI1_PMU_SCLK_COUNT_COUNT;
FWK_RW uint32_t SI1_SI_STATE_CONTROL;
FWK_W uint32_t SI1_SI_FLUSH_CONTROL;
uint8_t RESERVED1[0x248 - 0x238];
FWK_RW uint32_t SI1_SI_INTERRUPT_CONTROL;
FWK_W uint32_t SI1_SI_INTERRUPT_CLR;
uint32_t RESERVED2;
FWK_R uint32_t SI1_TZ_REGION_BASE_LOW_0;
FWK_R uint32_t SI1_TZ_REGION_BASE_HIGH_0;
FWK_RW uint32_t SI1_TZ_REGION_TOP_LOW_0;
FWK_RW uint32_t SI1_TZ_REGION_TOP_HIGH_0;
FWK_RW uint32_t SI1_TZ_REGION_ATTRIBUTES_0;
FWK_RW uint32_t SI1_TZ_REGION_ID_ACCESS_0;
FWK_RW uint32_t SI1_TZ_REGION_BASE_LOW_1;
FWK_RW uint32_t SI1_TZ_REGION_BASE_HIGH_1;
FWK_RW uint32_t SI1_TZ_REGION_TOP_LOW_1;
FWK_RW uint32_t SI1_TZ_REGION_TOP_HIGH_1;
FWK_RW uint32_t SI1_TZ_REGION_ATTRIBUTES_1;
FWK_RW uint32_t SI1_TZ_REGION_ID_ACCESS_1;
FWK_RW uint32_t SI1_TZ_REGION_BASE_LOW_2;
FWK_RW uint32_t SI1_TZ_REGION_BASE_HIGH_2;
FWK_RW uint32_t SI1_TZ_REGION_TOP_LOW_2;
FWK_RW uint32_t SI1_TZ_REGION_TOP_HIGH_2;
FWK_RW uint32_t SI1_TZ_REGION_ATTRIBUTES_2;
FWK_RW uint32_t SI1_TZ_REGION_ID_ACCESS_2;
FWK_RW uint32_t SI1_TZ_REGION_BASE_LOW_3;
FWK_RW uint32_t SI1_TZ_REGION_BASE_HIGH_3;
FWK_RW uint32_t SI1_TZ_REGION_TOP_LOW_3;
FWK_RW uint32_t SI1_TZ_REGION_TOP_HIGH_3;
FWK_RW uint32_t SI1_TZ_REGION_ATTRIBUTES_3;
FWK_RW uint32_t SI1_TZ_REGION_ID_ACCESS_3;
FWK_RW uint32_t SI1_TZ_REGION_BASE_LOW_4;
FWK_RW uint32_t SI1_TZ_REGION_BASE_HIGH_4;
FWK_RW uint32_t SI1_TZ_REGION_TOP_LOW_4;
FWK_RW uint32_t SI1_TZ_REGION_TOP_HIGH_4;
FWK_RW uint32_t SI1_TZ_REGION_ATTRIBUTES_4;
FWK_RW uint32_t SI1_TZ_REGION_ID_ACCESS_4;
FWK_RW uint32_t SI1_TZ_REGION_BASE_LOW_5;
FWK_RW uint32_t SI1_TZ_REGION_BASE_HIGH_5;
FWK_RW uint32_t SI1_TZ_REGION_TOP_LOW_5;
FWK_RW uint32_t SI1_TZ_REGION_TOP_HIGH_5;
FWK_RW uint32_t SI1_TZ_REGION_ATTRIBUTES_5;
FWK_RW uint32_t SI1_TZ_REGION_ID_ACCESS_5;
FWK_RW uint32_t SI1_TZ_REGION_BASE_LOW_6;
FWK_RW uint32_t SI1_TZ_REGION_BASE_HIGH_6;
FWK_RW uint32_t SI1_TZ_REGION_TOP_LOW_6;
FWK_RW uint32_t SI1_TZ_REGION_TOP_HIGH_6;
FWK_RW uint32_t SI1_TZ_REGION_ATTRIBUTES_6;
FWK_RW uint32_t SI1_TZ_REGION_ID_ACCESS_6;
FWK_RW uint32_t SI1_TZ_REGION_BASE_LOW_7;
FWK_RW uint32_t SI1_TZ_REGION_BASE_HIGH_7;
FWK_RW uint32_t SI1_TZ_REGION_TOP_LOW_7;
FWK_RW uint32_t SI1_TZ_REGION_TOP_HIGH_7;
FWK_RW uint32_t SI1_TZ_REGION_ATTRIBUTES_7;
FWK_RW uint32_t SI1_TZ_REGION_ID_ACCESS_7;
FWK_RW uint32_t SI1_TZ_REGION_BASE_LOW_8;
FWK_RW uint32_t SI1_TZ_REGION_BASE_HIGH_8;
FWK_RW uint32_t SI1_TZ_REGION_TOP_LOW_8;
FWK_RW uint32_t SI1_TZ_REGION_TOP_HIGH_8;
FWK_RW uint32_t SI1_TZ_REGION_ATTRIBUTES_8;
FWK_RW uint32_t SI1_TZ_REGION_ID_ACCESS_8;
FWK_RW uint32_t SI1_PMU_REQ_CONTROL;
FWK_RW uint32_t SI1_PMU_REQ_ATTRIBUTE_MASK_0;
FWK_RW uint32_t SI1_PMU_REQ_ATTRIBUTE_MATCH_0;
FWK_RW uint32_t SI1_PMU_REQ_ATTRIBUTE_MASK_1;
FWK_RW uint32_t SI1_PMU_REQ_ATTRIBUTE_MATCH_1;
FWK_RW uint32_t SI1_PMU_REQ_ATTRIBUTE_MASK_2;
FWK_RW uint32_t SI1_PMU_REQ_ATTRIBUTE_MATCH_2;
FWK_RW uint32_t SI1_PMU_REQ_ATTRIBUTE_MASK_3;
FWK_RW uint32_t SI1_PMU_REQ_ATTRIBUTE_MATCH_3;
FWK_RW uint32_t SI1_THRESHOLD_CONTROL;
uint8_t RESERVED3[0x400 - 0x354];
FWK_R uint32_t DCB_STATUS;
FWK_R uint32_t M_INTERRUPT_STATUS;
FWK_R uint32_t PMU_DCB_INT_INFO;
FWK_W uint32_t DCB_STATE_CONTROL;
uint32_t RESERVED4;
FWK_RW uint32_t QUEUE_THRESHOLD_CONTROL_31_00;
FWK_RW uint32_t QUEUE_THRESHOLD_CONTROL_63_32;
uint8_t RESERVED5[0x42C - 0x41C];
FWK_RW uint32_t DCB_INTERRUPT_CONTROL;
FWK_W uint32_t DCB_INTERRUPT_CLR;
FWK_RW uint32_t PMU_DCB_CONTROL;
FWK_RW uint32_t PMU_DATA_CONTROL_BLOCK_ATTRIBUTE_MASK_0;
FWK_RW uint32_t PMU_DATA_CONTROL_BLOCK_ATTRIBUTE_MATCH_0;
FWK_RW uint32_t PMU_DATA_CONTROL_BLOCK_COUNT_0;
FWK_RW uint32_t PMU_DATA_CONTROL_BLOCK_ATTRIBUTE_MASK_1;
FWK_RW uint32_t PMU_DATA_CONTROL_BLOCK_ATTRIBUTE_MATCH_1;
FWK_RW uint32_t PMU_DATA_CONTROL_BLOCK_COUNT_1;
FWK_RW uint32_t PMU_DATA_CONTROL_BLOCK_ATTRIBUTE_MASK_2;
FWK_RW uint32_t PMU_DATA_CONTROL_BLOCK_ATTRIBUTE_MATCH_2;
FWK_RW uint32_t PMU_DATA_CONTROL_BLOCK_COUNT_2;
FWK_RW uint32_t PMU_TAG_ENTRIES_ATTRIBUTE_MASK;
FWK_RW uint32_t PMU_TAG_ENTRIES_ATTRIBUTE_MATCH;
FWK_RW uint32_t PMU_TAG_ENTRIES_COUNT;
FWK_RW uint32_t PMU_MCLK_COUNT_COUNT;
uint32_t RESERVED6;
FWK_R uint32_t ERR_RAMECC_FR;
uint32_t RESERVED7;
FWK_RW uint32_t ERR_RAMECC_CTLR;
uint32_t RESERVED8;
FWK_RW uint32_t ERR_RAMECC_STATUS;
uint32_t RESERVED9;
FWK_RW uint32_t ERR_RAMECC_ADDR;
FWK_RW uint32_t ERR_RAMECC_ADDR2;
FWK_RW uint32_t ERR_RAMECC_MISC0;
uint32_t RESERVED10[3];
FWK_W uint32_t ERR_RAMECC_INJECT;
uint8_t RESERVED11[0x500 - 0x4A4];
FWK_R uint32_t QUEUE_STATUS;
uint32_t RESERVED12;
FWK_R uint32_t PMU_QE_INT_INFO;
FWK_RW uint32_t QUEUE_STATE_CONTROL;
FWK_RW uint32_t QE_INTERRUPT_CONTROL;
FWK_W uint32_t QE_INTERRUPT_CLR;
FWK_RW uint32_t RANK_TURNAROUND_CONTROL;
FWK_RW uint32_t HIT_TURNAROUND_CONTROL;
FWK_RW uint32_t QOS_CLASS_CONTROL;
FWK_RW uint32_t ESCALATION_CONTROL;
FWK_RW uint32_t QV_CONTROL_31_00;
FWK_RW uint32_t QV_CONTROL_63_32;
FWK_RW uint32_t RT_CONTROL_31_00;
FWK_RW uint32_t RT_CONTROL_63_32;
FWK_RW uint32_t TIMEOUT_CONTROL;
FWK_RW uint32_t WRITE_PRIORITY_CONTROL_31_00;
FWK_RW uint32_t WRITE_PRIORITY_CONTROL_63_32;
uint32_t RESERVED13;
FWK_RW uint32_t DIR_TURNAROUND_CONTROL;
FWK_RW uint32_t HIT_PREDICTION_CONTROL;
FWK_RW uint32_t REFRESH_ENABLE;
FWK_R uint32_t REFRESH_STATUS;
FWK_R uint32_t REFRESH_STATUS_FG;
FWK_RW uint32_t REFRESH_PRIORITY;
FWK_RW uint32_t MC_UPDATE_CONTROL;
FWK_RW uint32_t PHY_UPDATE_CONTROL;
FWK_RW uint32_t PHY_MASTER_CONTROL;
FWK_RW uint32_t LOW_POWER_CONTROL;
FWK_RW uint32_t PMU_QE_CONTROL;
FWK_RW uint32_t PMU_QE_MUX;
FWK_RW uint32_t PMU_QOS_ENGINE_ATTRIBUTE_MASK_0;
FWK_RW uint32_t PMU_QOS_ENGINE_ATTRIBUTE_MATCH_0;
FWK_RW uint32_t PMU_QOS_ENGINE_COUNT_0;
FWK_RW uint32_t PMU_QOS_ENGINE_ATTRIBUTE_MASK_1;
FWK_RW uint32_t PMU_QOS_ENGINE_ATTRIBUTE_MATCH_1;
FWK_RW uint32_t PMU_QOS_ENGINE_COUNT_1;
FWK_RW uint32_t PMU_QOS_ENGINE_ATTRIBUTE_MASK_2;
FWK_RW uint32_t PMU_QOS_ENGINE_ATTRIBUTE_MATCH_2;
FWK_RW uint32_t PMU_QOS_ENGINE_COUNT_2;
FWK_RW uint32_t PMU_QUEUED_ENTRIES_ATTRIBUTE_MASK;
FWK_RW uint32_t PMU_QUEUED_ENTRIES_ATTRIBUTE_MATCH;
FWK_RW uint32_t PMU_QUEUED_ENTRIES_COUNT;
uint8_t RESERVED14[0x600 - 0x5A8];
FWK_R uint32_t MI_STATUS;
FWK_R uint32_t RANKS_READY;
FWK_R uint32_t RANKS_RESET;
FWK_R uint32_t RANKS_DEEP_POWER_DOWN;
FWK_R uint32_t RANKS_SELF_REFRESH;
FWK_R uint32_t RANKS_POWERED_DOWN;
FWK_R uint32_t RANKS_CLOCK_DISABLED;
FWK_R uint32_t PHY_STATUS0;
FWK_R uint32_t PHY_STATUS1;
uint32_t RESERVED15;
FWK_R uint32_t PMU_MI_INT_INFO;
uint32_t RESERVED16;
FWK_RW uint32_t MI_STATE_CONTROL;
FWK_RW uint32_t PHY_CONFIG;
FWK_RW uint32_t DIRECT_CMD_SETTINGS;
FWK_RW uint32_t DIRECT_CMD;
FWK_RW uint32_t DIRECT_CLK_DISABLE;
FWK_RW uint32_t DIRECT_ODT;
FWK_RW uint32_t DCI_STRB;
FWK_RW uint32_t DCI_DATA;
FWK_W uint32_t DCI_DATA_CLR;
FWK_W uint32_t RANK_STATUS_OVERRIDE;
FWK_W uint32_t CLK_STATUS_OVERRIDE;
FWK_W uint32_t BANK_STATUS_OVERRIDE;
FWK_RW uint32_t MI_INTERRUPT_CONTROL;
FWK_W uint32_t MI_INTERRUPT_CLR;
FWK_RW uint32_t MEMORY_TYPE;
FWK_RW uint32_t FORMAT_CONTROL;
FWK_RW uint32_t FEATURE_CONTROL;
FWK_RW uint32_t POWER_DOWN_CONTROL;
FWK_RW uint32_t REFRESH_CONTROL;
FWK_RW uint32_t ODT_WR_CONTROL_31_00;
uint32_t RESERVED17;
FWK_RW uint32_t ODT_RD_CONTROL_31_00;
uint32_t RESERVED18;
FWK_RW uint32_t PHY_WRDATA_CS_CONTROL_31_00;
uint32_t RESERVED19;
FWK_RW uint32_t PHY_RDDATA_CS_CONTROL_31_00;
uint32_t RESERVED20;
FWK_RW uint32_t PHYUPD_INIT;
FWK_RW uint32_t PHY_POWER_CONTROL;
uint32_t RESERVED21;
FWK_RW uint32_t ODT_TIMING;
FWK_RW uint32_t T_REFI;
FWK_RW uint32_t T_RFC;
FWK_RW uint32_t T_RCD;
FWK_RW uint32_t T_RAS;
FWK_RW uint32_t T_RP;
FWK_RW uint32_t T_RRD;
FWK_RW uint32_t T_ACT_WINDOW;
FWK_RW uint32_t T_RTR;
FWK_RW uint32_t T_RTW;
FWK_RW uint32_t T_RTP;
FWK_RW uint32_t T_RDPDEN;
FWK_RW uint32_t T_WR;
FWK_RW uint32_t T_WTR;
FWK_RW uint32_t T_WTW;
FWK_RW uint32_t T_XTMW;
FWK_RW uint32_t T_WRPDEN;
FWK_RW uint32_t T_CLOCK_CONTROL;
FWK_RW uint32_t T_EP;
FWK_RW uint32_t T_XP;
FWK_RW uint32_t T_ESR;
FWK_RW uint32_t T_XSR;
uint32_t RESERVED22;
FWK_RW uint32_t T_COMPLETION_CHECKS;
FWK_RW uint32_t T_RDDATA_EN;
FWK_RW uint32_t T_PHYRDLAT;
FWK_RW uint32_t T_PHYWRLAT;
FWK_RW uint32_t T_PHY_TRAIN;
FWK_R uint32_t ERR_PHY_FR;
uint32_t RESERVED23;
FWK_RW uint32_t ERR_PHY_CTLR;
uint32_t RESERVED24;
FWK_RW uint32_t ERR_PHY_STATUS;
uint32_t RESERVED25;
FWK_RW uint32_t ERR_PHY_ADDR;
FWK_RW uint32_t ERR_PHY_ADDR2;
FWK_RW uint32_t ERR_PHY_MISC0;
uint8_t RESERVED26[0x74C - 0x73C];
FWK_W uint32_t ERR_PHY_INJECT;
FWK_RW uint32_t PMU_MI_CONTROL;
FWK_RW uint32_t PMU_MEMORY_IF_ATTRIBUTE_MASK_0;
FWK_RW uint32_t PMU_MEMORY_IF_ATTRIBUTE_MATCH_0;
FWK_RW uint32_t PMU_MEMORY_IF_COUNT_0;
FWK_RW uint32_t PMU_MEMORY_IF_ATTRIBUTE_MASK_1;
FWK_RW uint32_t PMU_MEMORY_IF_ATTRIBUTE_MATCH_1;
FWK_RW uint32_t PMU_MEMORY_IF_COUNT_1;
FWK_RW uint32_t PMU_BANK_STATES_ATTRIBUTE_MASK;
FWK_RW uint32_t PMU_BANK_STATES_ATTRIBUTE_MATCH;
FWK_RW uint32_t PMU_BANK_STATES_COUNT;
FWK_RW uint32_t PMU_RANK_STATES_ATTRIBUTE_MASK;
FWK_RW uint32_t PMU_RANK_STATES_ATTRIBUTE_MATCH;
FWK_RW uint32_t PMU_RANK_STATES_COUNT;
uint8_t RESERVED27[0xF00 - 0x784];
FWK_R uint32_t MEMC_CONFIG;
uint32_t RESERVED28[3];
FWK_R uint32_t CFG_INTERRUPT_STATUS;
FWK_R uint32_t CFG_FAILED_ACCESS_INT_INFO;
uint8_t RESERVED29[0xF30 - 0xF18];
FWK_RW uint32_t CFG_INTERRUPT_CONTROL;
uint32_t RESERVED30;
FWK_W uint32_t CFG_INTERRUPT_CLR;
uint8_t RESERVED31[0xFC0 - 0xF3C];
FWK_RW uint32_t INTEGRATION_TEST_CONTROL;
FWK_RW uint32_t INTEGRATION_TEST_OUTPUT;
uint32_t RESERVED32[2];
FWK_R uint32_t PERIPH_ID_4;
uint32_t RESERVED33[3];
FWK_R uint32_t PERIPH_ID_0;
FWK_R uint32_t PERIPH_ID_1;
FWK_R uint32_t PERIPH_ID_2;
FWK_R uint32_t PERIPH_ID_3;
FWK_R uint32_t COMPONENT_ID_0;
FWK_R uint32_t COMPONENT_ID_1;
FWK_R uint32_t COMPONENT_ID_2;
FWK_R uint32_t COMPONENT_ID_3;
/*!
* \endcond
* @}
*/
};
/*!
* \brief SI_STATE_CONTROL mask used to prevent request stalling.
*/
#define MOD_DMC500_SI_STATE_CONTROL_GO 0
/*!
* \brief SI_STATE_CONTROL mask used to enable request stalling.
*/
#define MOD_DMC500_SI_STATE_CONTROL_STALL_REQ (1 << 0)
/*!
* \brief SI_STATUS mask used to confirm that request stalling is active.
*/
#define MOD_DMC500_SI_STATUS_STALL_ACK (1 << 0)
/*!
* \brief SI_STATUS mask used to read the empty bit.
*/
#define MOD_DMC500_SI_STATUS_EMPTY (1 << 1)
/*!
* \brief QUEUE_STATE_CONTROL mask used to prevent request stalling.
*/
#define MOD_DMC500_QUEUE_STATE_CONTROL_GO 0
/*!
* \brief QUEUE_STATE_CONTROL mask used to enable request stalling.
*/
#define MOD_DMC500_QUEUE_STATE_CONTROL_STALL_REQ (1 << 0)
/*!
* \brief QUEUE_STATUS mask used to confirm that request stalling is active.
*/
#define MOD_DMC500_QUEUE_STATUS_STALL_ACK (1 << 0)
/*!
* \brief QUEUE_STATUS mask used to read the empty bit.
*/
#define MOD_DMC500_QUEUE_STATUS_EMPTY (1 << 1)
/*!
* \brief MI_STATUS mask used to read the idle bit.
*/
#define MOD_DMC500_MI_STATUS_IDLE (1 << 0)
/*!
* \brief MI_STATUS mask used to read the empty bit.
*/
#define MOD_DMC500_MI_STATUS_EMPTY (1 << 1)
/*!
* \brief Create the ADDRESS_MAP value.
*
* \param SHUTTER The address shutter.
*
* \return The ADDRESS_MAP value.
*/
#define ADDRESS_MAP_VAL(SHUTTER) ((1 << 8) | (SHUTTER))
/*!
* \brief Create the ADDRESS_CONTROL value.
*
* \param RANK Number of bits for the rank.
* \param BANK Number of bits for the bank.
* \param ROW Number of bits for the row.
* \param COL Number of bits for the column.
*
* \return The ADDRESS_CONTROL value.
*/
#define ADDRESS_CONTROL_VAL(RANK, BANK, ROW, COL) (((RANK) << 24) | \
((BANK) << 16) | \
((ROW) << 8) | \
(COL))
/*!
* \brief Create the MEMORY_TYPE value
*
* \param BANK_GROUP Bank group.
* \param WIDTH Memory device width.
* \param TYPE Memory type.
*
* \return The MEMORY_TYPE value.
*/
#define MEMORY_TYPE_VAL(BANK_GROUP, WIDTH, TYPE) (((BANK_GROUP) << 16) | \
((WIDTH) << 8) | \
(TYPE))
/*!
* \brief Create the FORMAT_CONTROL value.
*
* \param BURST Memory burst.
*
* \return The FORMAT_CONTROL value.
*/
#define FORMAT_CONTROL_VAL(BURST) ((BURST) << 8)
/*!
* \brief Element configuration.
*/
struct mod_dmc500_element_config {
/*! Base address of the DMC-500 device's registers */
uintptr_t dmc;
/*! Element identifier of the associated DDR PHY-500 device */
fwk_id_t ddr_phy_id;
};
/*!
* \brief API of the DDR PHY associate to the DMC
*/
struct mod_dmc500_ddr_phy_api {
/*!
* \brief Configure a DDR PHY500 device
*
* \param element_id Element identifier corresponding to the device to
* configure.
*
* \retval FWK_SUCCESS if the operation succeed.
* \return one of the error code otherwise.
*/
int (*configure)(fwk_id_t element_id);
};
/*!
* \brief DMC-500 module configuration.
*/
struct mod_dmc500_module_config {
/*!
* Element identifier of the timer used for delays when programming the
* DMC-500
*/
fwk_id_t timer_id;
/*! DDR PHY module ID */
fwk_id_t ddr_phy_module_id;
/*! DDR PHY API ID */
fwk_id_t ddr_phy_api_id;
/*! Initial value for the dmc registers */
const struct mod_dmc500_reg *reg_val;
/*! Pointer to a product-specific function that issues direct commands */
void (*direct_ddr_cmd)(struct mod_dmc500_reg *dmc);
};
/*!
* \brief DMC-500 module description.
*/
extern const struct fwk_module module_dmc500;
/*!
* @}
*/
/*!
* @}
*/
#endif /* MOD_DMC500_H */
| 35.861888 | 78 | 0.739044 | [
"model"
] |
7f4462a335c24df7e027eeb95fb298e4f87af638 | 2,338 | h | C | Classes/GamerCamp/GameSpecific/Enemies/GCObjGroupEnemy.h | smkmth/Danny_GCFramework_M1_Template | 61dea58a1eca5f18a277026b6945f7f4f58d34ab | [
"Unlicense"
] | null | null | null | Classes/GamerCamp/GameSpecific/Enemies/GCObjGroupEnemy.h | smkmth/Danny_GCFramework_M1_Template | 61dea58a1eca5f18a277026b6945f7f4f58d34ab | [
"Unlicense"
] | 2 | 2018-10-25T14:55:17.000Z | 2018-10-25T15:20:55.000Z | Classes/GamerCamp/GameSpecific/Enemies/GCObjGroupEnemy.h | smkmth/Danny_GCFramework_M1_Template | 61dea58a1eca5f18a277026b6945f7f4f58d34ab | [
"Unlicense"
] | null | null | null | #ifndef _GCOBJECTGROUPENEMY_H_
#define _GCOBJECTGROUPENEMY_H_
#ifndef BOX2D_H
#include "Box2d/Box2D.h"
#endif
#ifndef _GCOBJECTGROUP_H_
#include "GamerCamp/GCObject/GCObjectGroup.h"
#endif
//////////////////////////////////////////////////////////////////////////
// Forward Declarations
class CGCObjSprite;
class CGCObjEnemy;
//////////////////////////////////////////////////////////////////////////
// Responsible for newing, managing, & deleting the enemies
//////////////////////////////////////////////////////////////////////////
class CGCObjGroupEnemy
: public CGCObjectGroup
{
private:
// Total number of enemies to create
static const u32 k_uNumEnemies = 3;
// Array of b2Vec2 for enemy position
b2Vec2 m_v2EnemyPositionArray[k_uNumEnemies];
// Array of floats for enemy patrol min/max points
float m_v2EnemyPatrolMinimumArray[k_uNumEnemies];
float m_v2EnemyPatrolMaximumArray[k_uNumEnemies];
// Array of ints for enemy patrol direction
int m_v2EnemyPatrolDirectionArray[k_uNumEnemies];
public:
// Constructor
CGCObjGroupEnemy();
//////////////////////////////////////////////////////////////////////////
// We need a virtual destructor since delete will be called on pointers of
// this class to delete derived types.
virtual ~CGCObjGroupEnemy() override;
//////////////////////////////////////////////////////////////////////////
// Overrides for CGCObjectGroup public interface
// Handles GCObjenemy
virtual bool VHandlesThisTypeId ( GCTypeID idQueryType ) override;
// Must return the typeid of the CGCObjectGroup derived class
virtual GCTypeID VGetTypeId ( void ) override;
virtual void VOnGroupResourceAcquire ( void ) override;
virtual void VOnGroupResourceAcquire_PostObject ( void ) override;
virtual void VOnGroupResourceRelease ( void ) override;
// Overridden virtuals from the game object interface
//////////////////////////////////////////////////////////////////////////
void CreateEnemies( void );
void DestroyEnemies( void );
// Getters and Setters
// Getters
int GetNumberOfEnemies();
// Setters
void SetEnemyPosition( int _iEnemyNumber, b2Vec2 _v2EnemyPosition );
void SetEnemyPatrol( int _iEnemyNumber, float _fpatrolMinimumPoint, float _fpatrolMaximumPoint, int _iPatrolDirection );
};
#endif // #ifndef _GCOBJECTGROUPENEMY_H_ | 31.173333 | 121 | 0.630453 | [
"object"
] |
7f44db81e4f50938c6ba6607815c4a5e0f6d4fd6 | 54,666 | h | C | 3rdparty/blend2d/src/blend2d/support_p.h | Praxinos/ULIS3 | 98eb48293fdd3b45fcfe4b659d471572100d1623 | [
"RSA-MD"
] | 12 | 2020-05-04T08:49:04.000Z | 2021-12-30T09:35:17.000Z | 3rdparty/blend2d/src/blend2d/support_p.h | Praxinos/ULIS3 | 98eb48293fdd3b45fcfe4b659d471572100d1623 | [
"RSA-MD"
] | 1 | 2021-09-03T21:20:38.000Z | 2021-09-03T21:20:38.000Z | 3rdparty/blend2d/src/blend2d/support_p.h | Praxinos/ULIS3 | 98eb48293fdd3b45fcfe4b659d471572100d1623 | [
"RSA-MD"
] | 3 | 2021-02-19T18:39:02.000Z | 2022-03-09T17:14:57.000Z | // Blend2D - 2D Vector Graphics Powered by a JIT Compiler
//
// * Official Blend2D Home Page: https://blend2d.com
// * Official Github Repository: https://github.com/blend2d/blend2d
//
// Copyright (c) 2017-2020 The Blend2D Authors
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
#ifndef BLEND2D_SUPPORT_P_H_INCLUDED
#define BLEND2D_SUPPORT_P_H_INCLUDED
#include "./api-internal_p.h"
#if defined(_MSC_VER) && defined(BL_TARGET_OPT_POPCNT)
#include <intrin.h>
#endif
//! \cond INTERNAL
//! \addtogroup blend2d_internal
//! \{
// ============================================================================
// [StdInt]
// ============================================================================
template<typename T>
BL_NODISCARD
static constexpr bool blIsUnsigned() noexcept { return std::is_unsigned<T>::value; }
//! Cast an integer `x` to a fixed-width type as defined by <stdint.h>
//!
//! This can help when specializing some functions for a particular type. Since
//! some C/C++ types may overlap (like `long` vs `long long`) it's easier to
//! just cast to a type as defined by <stdint.h> and specialize for it.
template<typename T>
BL_NODISCARD
static constexpr typename BLInternal::StdInt<sizeof(T), blIsUnsigned<T>()>::Type blAsStdInt(T x) noexcept {
return (typename BLInternal::StdInt<sizeof(T), blIsUnsigned<T>()>::Type)x;
}
//! Cast an integer `x` to a fixed-width unsigned type as defined by <stdint.h>
template<typename T>
BL_NODISCARD
static constexpr typename BLInternal::StdInt<sizeof(T), 1>::Type blAsStdUInt(T x) noexcept {
return (typename BLInternal::StdInt<sizeof(T), 1>::Type)x;
}
//! Cast an integer `x` to either `int32_t`, uint32_t`, `int64_t`, or `uint64_t`.
//!
//! Used to keep a signedness of `T`, but to promote it to at least 32-bit type.
template<typename T>
BL_NODISCARD
static constexpr typename BLInternal::StdInt<blMax<size_t>(sizeof(T), 4), blIsUnsigned<T>()>::Type blAsIntLeast32(T x) noexcept {
typedef typename BLInternal::StdInt<blMax<size_t>(sizeof(T), 4), blIsUnsigned<T>()>::Type Result;
return Result(x);
}
//! Cast an integer `x` to either `uint32_t` or `uint64_t`.
template<typename T>
BL_NODISCARD
static constexpr typename BLInternal::StdInt<blMax<size_t>(sizeof(T), 4), 1>::Type blAsUIntLeast32(T x) noexcept {
typedef typename BLInternal::StdInt<blMax<size_t>(sizeof(T), 4), 1>::Type Result;
typedef typename std::make_unsigned<T>::type U;
return Result(U(x));
}
// ============================================================================
// [MisalignedInt]
// ============================================================================
static const constexpr bool BL_UNALIGNED_IO_16 = BL_TARGET_ARCH_X86 != 0;
static const constexpr bool BL_UNALIGNED_IO_32 = BL_TARGET_ARCH_X86 != 0;
static const constexpr bool BL_UNALIGNED_IO_64 = BL_TARGET_ARCH_X86 != 0;
// Type alignment (not allowed by C++11 'alignas' keyword).
#if defined(__GNUC__)
#define BL_MISALIGN_TYPE(TYPE, N) __attribute__((__aligned__(N))) TYPE
#elif defined(_MSC_VER)
#define BL_MISALIGN_TYPE(TYPE, N) __declspec(align(N)) TYPE
#else
#define BL_MISALIGN_TYPE(TYPE, N) TYPE
#endif
//! An integer type that has possibly less alignment than its size.
template<typename T, size_t Alignment>
struct BLMisalignedUInt {};
template<> struct BLMisalignedUInt<uint8_t, 1> { typedef uint8_t T; };
template<> struct BLMisalignedUInt<uint16_t, 1> { typedef uint16_t BL_MISALIGN_TYPE(T, 1); };
template<> struct BLMisalignedUInt<uint16_t, 2> { typedef uint16_t T; };
template<> struct BLMisalignedUInt<uint32_t, 1> { typedef uint32_t BL_MISALIGN_TYPE(T, 1); };
template<> struct BLMisalignedUInt<uint32_t, 2> { typedef uint32_t BL_MISALIGN_TYPE(T, 2); };
template<> struct BLMisalignedUInt<uint32_t, 4> { typedef uint32_t T; };
template<> struct BLMisalignedUInt<uint64_t, 1> { typedef uint64_t BL_MISALIGN_TYPE(T, 1); };
template<> struct BLMisalignedUInt<uint64_t, 2> { typedef uint64_t BL_MISALIGN_TYPE(T, 2); };
template<> struct BLMisalignedUInt<uint64_t, 4> { typedef uint64_t BL_MISALIGN_TYPE(T, 4); };
template<> struct BLMisalignedUInt<uint64_t, 8> { typedef uint64_t T; };
#undef BL_MISALIGN_TYPE
// ============================================================================
// [Numeric Limits]
// ============================================================================
template<typename T> BL_NODISCARD static constexpr T blInf() noexcept { return std::numeric_limits<T>::infinity(); }
template<typename T> BL_NODISCARD static constexpr T blNaN() noexcept { return std::numeric_limits<T>::quiet_NaN(); }
template<typename T> BL_NODISCARD static constexpr T blMinValue() noexcept { return std::numeric_limits<T>::lowest(); }
template<typename T> BL_NODISCARD static constexpr T blMaxValue() noexcept { return std::numeric_limits<T>::max(); }
// ============================================================================
// [Integer Utilities]
// ============================================================================
//! Returns `0 - x` in a safe way (no undefined behavior), works for both signed and unsigned numbers.
template<typename T>
BL_NODISCARD
static constexpr T blNegate(const T& x) noexcept {
typedef typename std::make_unsigned<T>::type U;
return T(U(0) - U(x));
}
// ============================================================================
// [ByteSwap]
// ============================================================================
namespace {
template<typename T>
BL_NODISCARD
static BL_INLINE T blByteSwap32(const T& x) noexcept {
#if defined(__GNUC__) && !defined(BL_BUILD_NO_INTRINSICS)
return T(uint32_t(__builtin_bswap32(uint32_t(x))));
#elif defined(_MSC_VER) && !defined(BL_BUILD_NO_INTRINSICS)
return T(uint32_t(_byteswap_ulong(uint32_t(x))));
#else
return T((uint32_t(x) << 24) | (uint32_t(x) >> 24) | ((uint32_t(x) << 8) & 0x00FF0000u) | ((uint32_t(x) >> 8) & 0x0000FF00));
#endif
}
template<typename T>
BL_NODISCARD
static BL_INLINE T blByteSwap24(const T& x) noexcept {
// This produces always much better code than trying to do a real 24-bit byteswap.
return T(blByteSwap32(uint32_t(x)) >> 8);
}
template<typename T>
BL_NODISCARD
static BL_INLINE T blByteSwap16(const T& x) noexcept {
#if defined(_MSC_VER) && !defined(BL_BUILD_NO_INTRINSICS)
return T(uint16_t(_byteswap_ushort(uint16_t(x))));
#else
return T((uint16_t(x) << 8) | (uint16_t(x) >> 8));
#endif
}
template<typename T>
BL_NODISCARD
static BL_INLINE T blByteSwap64(const T& x) noexcept {
#if defined(__GNUC__) && !defined(BL_BUILD_NO_INTRINSICS)
return T(uint64_t(__builtin_bswap64(uint64_t(x))));
#elif defined(_MSC_VER) && !defined(BL_BUILD_NO_INTRINSICS)
return T(uint64_t(_byteswap_uint64(uint64_t(x))));
#else
return T( (uint64_t(blByteSwap32(uint32_t(uint64_t(x) >> 32 ))) ) |
(uint64_t(blByteSwap32(uint32_t(uint64_t(x) & 0xFFFFFFFFu))) << 32) );
#endif
}
template<typename T>
BL_NODISCARD
static BL_INLINE T blByteSwap(const T& x) noexcept {
static_assert(sizeof(T) == 1 || sizeof(T) == 2 ||
sizeof(T) == 4 || sizeof(T) == 8, "Size of 'T' must be 1|2|4|8");
if (sizeof(T) == 1)
return x;
else if (sizeof(T) == 2)
return blByteSwap16(x);
else if (sizeof(T) == 4)
return blByteSwap32(x);
else
return blByteSwap64(x);
}
// TODO: [GLOBAL] REMOVE?
template<typename T> BL_NODISCARD static BL_INLINE T blByteSwap16LE(T x) noexcept { return BL_BYTE_ORDER_NATIVE == BL_BYTE_ORDER_LE ? T(x) : T(blByteSwap16(int16_t(x))); }
template<typename T> BL_NODISCARD static BL_INLINE T blByteSwap24LE(T x) noexcept { return BL_BYTE_ORDER_NATIVE == BL_BYTE_ORDER_LE ? T(x) : T(blByteSwap24(uint32_t(x))); }
template<typename T> BL_NODISCARD static BL_INLINE T blByteSwap32LE(T x) noexcept { return BL_BYTE_ORDER_NATIVE == BL_BYTE_ORDER_LE ? T(x) : T(blByteSwap32(uint32_t(x))); }
template<typename T> BL_NODISCARD static BL_INLINE T blByteSwap64LE(T x) noexcept { return BL_BYTE_ORDER_NATIVE == BL_BYTE_ORDER_LE ? T(x) : T(blByteSwap64(uint64_t(x))); }
template<typename T> BL_NODISCARD static BL_INLINE T blByteSwap16BE(T x) noexcept { return BL_BYTE_ORDER_NATIVE == BL_BYTE_ORDER_BE ? T(x) : T(blByteSwap16(uint16_t(x))); }
template<typename T> BL_NODISCARD static BL_INLINE T blByteSwap24BE(T x) noexcept { return BL_BYTE_ORDER_NATIVE == BL_BYTE_ORDER_BE ? T(x) : T(blByteSwap24(uint32_t(x))); }
template<typename T> BL_NODISCARD static BL_INLINE T blByteSwap32BE(T x) noexcept { return BL_BYTE_ORDER_NATIVE == BL_BYTE_ORDER_BE ? T(x) : T(blByteSwap32(uint32_t(x))); }
template<typename T> BL_NODISCARD static BL_INLINE T blByteSwap64BE(T x) noexcept { return BL_BYTE_ORDER_NATIVE == BL_BYTE_ORDER_BE ? T(x) : T(blByteSwap64(uint64_t(x))); }
} // {anonymous}
// ============================================================================
// [Bit Utilities]
// ============================================================================
namespace {
template<typename T>
BL_NODISCARD
BL_INLINE constexpr uint32_t blBitSizeOf() noexcept { return uint32_t(sizeof(T) * 8u); }
template<typename T>
BL_NODISCARD
BL_INLINE constexpr T blBitOnes() noexcept { return T(~T(0)); }
template<typename T>
BL_NODISCARD
BL_INLINE constexpr size_t blBitWordCountFromBitCount(size_t nBits) noexcept {
return (nBits + blBitSizeOf<T>() - 1) / blBitSizeOf<T>();
}
//! Returns `x << y` (shift left logical) by explicitly casting `x` to an unsigned type and back.
template<typename X, typename Y>
BL_NODISCARD
BL_INLINE constexpr X blBitShl(const X& x, const Y& y) noexcept {
typedef typename std::make_unsigned<X>::type U;
return X(U(x) << y);
}
//! Returns `x >> y` (shift right logical) by explicitly casting `x` to an unsigned type and back.
template<typename X, typename Y>
BL_NODISCARD
BL_INLINE constexpr X blBitShr(const X& x, const Y& y) noexcept {
typedef typename std::make_unsigned<X>::type U;
return X(U(x) >> y);
}
//! Returns `x >> y` (shift right arithmetic) by explicitly casting `x` to a signed type and back.
template<typename X, typename Y>
BL_NODISCARD
BL_INLINE constexpr X blBitSar(const X& x, const Y& y) noexcept {
typedef typename std::make_signed<X>::type S;
return X(S(x) >> y);
}
template<typename T>
BL_NODISCARD
BL_INLINE T blBitRolImpl(const T& x, unsigned n) noexcept {
return blBitShl(x, n % unsigned(sizeof(T) * 8u)) | blBitShr(x, (0u - n) % unsigned(sizeof(T) * 8u)) ;
}
template<typename T>
BL_NODISCARD
BL_INLINE T blBitRorImpl(const T& x, unsigned n) noexcept {
return blBitShr(x, n % unsigned(sizeof(T) * 8u)) | blBitShl(x, (0u - n) % unsigned(sizeof(T) * 8u)) ;
}
// MSVC is unable to emit `rol|ror` instruction when `n` is not constant so we
// have to help it a bit. This, however, prevents us from using `constexpr`.
#if defined(_MSC_VER)
template<> BL_NODISCARD BL_INLINE uint8_t blBitRolImpl(const uint8_t& x, unsigned n) noexcept { return uint8_t(_rotl8(x, uint8_t(n))); }
template<> BL_NODISCARD BL_INLINE uint8_t blBitRorImpl(const uint8_t& x, unsigned n) noexcept { return uint8_t(_rotr8(x, uint8_t(n))); }
template<> BL_NODISCARD BL_INLINE uint16_t blBitRolImpl(const uint16_t& x, unsigned n) noexcept { return uint16_t(_rotl16(x, uint8_t(n))); }
template<> BL_NODISCARD BL_INLINE uint16_t blBitRorImpl(const uint16_t& x, unsigned n) noexcept { return uint16_t(_rotr16(x, uint8_t(n))); }
template<> BL_NODISCARD BL_INLINE uint32_t blBitRolImpl(const uint32_t& x, unsigned n) noexcept { return uint32_t(_rotl(x, int(n))); }
template<> BL_NODISCARD BL_INLINE uint32_t blBitRorImpl(const uint32_t& x, unsigned n) noexcept { return uint32_t(_rotr(x, int(n))); }
template<> BL_NODISCARD BL_INLINE uint64_t blBitRolImpl(const uint64_t& x, unsigned n) noexcept { return uint64_t(_rotl64(x, int(n))); }
template<> BL_NODISCARD BL_INLINE uint64_t blBitRorImpl(const uint64_t& x, unsigned n) noexcept { return uint64_t(_rotr64(x, int(n))); }
#endif
template<typename X, typename Y>
BL_NODISCARD
BL_INLINE X blBitRol(const X& x, const Y& n) noexcept { return X(blBitRolImpl(blAsUIntLeast32(x), unsigned(n))); }
template<typename X, typename Y>
BL_NODISCARD
BL_INLINE X blBitRor(const X& x, const Y& n) noexcept { return X(blBitRorImpl(blAsUIntLeast32(x), unsigned(n))); }
//! Returns `x | (x >> y)` - helper used by some bit manipulation helpers.
template<typename X, typename Y>
BL_NODISCARD
BL_INLINE constexpr X blBitShrOr(const X& x, const Y& y) noexcept { return X(x | blBitShr(x, y)); }
template<typename X, typename Y, typename... Args>
BL_NODISCARD
BL_INLINE constexpr X blBitShrOr(const X& x, const Y& y, Args... args) noexcept { return blBitShrOr(blBitShrOr(x, y), args...); }
//! Fills all trailing bits right from the first most significant bit set.
template<typename T>
BL_NODISCARD
BL_INLINE constexpr T blFillTrailingBits(const T& x) noexcept {
typedef typename BLInternal::StdInt<sizeof(T), 1>::Type U;
return T(blFillTrailingBits(U(x)));
}
template<> BL_NODISCARD BL_INLINE constexpr uint8_t blFillTrailingBits(const uint8_t& x) noexcept { return blBitShrOr(x, 1, 2, 4); }
template<> BL_NODISCARD BL_INLINE constexpr uint16_t blFillTrailingBits(const uint16_t& x) noexcept { return blBitShrOr(x, 1, 2, 4, 8); }
template<> BL_NODISCARD BL_INLINE constexpr uint32_t blFillTrailingBits(const uint32_t& x) noexcept { return blBitShrOr(x, 1, 2, 4, 8, 16); }
template<> BL_NODISCARD BL_INLINE constexpr uint64_t blFillTrailingBits(const uint64_t& x) noexcept { return blBitShrOr(x, 1, 2, 4, 8, 16, 32); }
template<typename T, typename N = uint32_t>
BL_NODISCARD
static BL_INLINE constexpr T blNonZeroLsbMask(const N& n = 1) noexcept {
return blBitShr(blBitOnes<T>(), N(blBitSizeOf<T>()) - n);
}
template<typename T, typename N = uint32_t>
BL_NODISCARD
static BL_INLINE constexpr T blNonZeroMsbMask(const N& n = 1) noexcept {
return blBitSar(blBitShl(T(1), blBitSizeOf<T>() - 1u), n - 1u);
}
//! Returns a bit-mask that has `x` bit set.
template<typename T, typename Arg>
BL_NODISCARD
BL_INLINE constexpr T blBitAt(Arg x) noexcept { return T(T(1u) << x); }
//! Returns a bit-mask that has `x` bit set (multiple arguments).
template<typename T, typename Arg>
BL_NODISCARD
BL_INLINE constexpr T blBitsAt(Arg x) noexcept { return T(T(1u) << x); }
template<typename T, typename Arg, typename... Args>
BL_NODISCARD
BL_INLINE constexpr T blBitsAt(Arg x, Args... args) noexcept { return T(blBitAt<T>(x) | blBitsAt<T>(args...)); }
//! Returns a bit-mask where all bits are set if the given value `x` is 1, or
//! zero otherwise. Please note that `x` must be either 0 or 1, all other
//! values will produce invalid output.
template<typename T, typename B>
BL_NODISCARD
BL_INLINE constexpr T blBitMaskFromBool(const B& x) noexcept { return blNegate(T(x)); }
//! Tests whether `x` has `n`th bit set.
template<typename T, typename I>
BL_NODISCARD
BL_INLINE constexpr bool blBitTest(const T& x, const I& i) noexcept {
typedef typename std::make_unsigned<T>::type U;
return (U(x) & (U(1) << i)) != 0;
}
//! Tests whether bits specified by `y` are all set in `x`.
template<typename X, typename Y>
BL_NODISCARD
BL_INLINE constexpr bool blBitMatch(const X& x, const Y& y) noexcept { return (x & y) == y; }
template<typename T>
BL_NODISCARD
BL_INLINE constexpr bool blIsBitMaskConsecutive(const T& x) noexcept {
typedef typename std::make_unsigned<T>::type U;
return x != 0 && (U(x) ^ (U(x) + (U(x) & (~U(x) + 1u)))) >= U(x);
}
template<typename T>
BL_NODISCARD
static BL_INLINE T blBitSwap(const T& x) noexcept {
auto v = blAsUIntLeast32(x);
auto m1 = blAsUIntLeast32(T(0x5555555555555555u & blBitOnes<T>()));
auto m2 = blAsUIntLeast32(T(0x3333333333333333u & blBitOnes<T>()));
auto m4 = blAsUIntLeast32(T(0x0F0F0F0F0F0F0F0Fu & blBitOnes<T>()));
v = ((v >> 1) & m1) | ((v & m1) << 1);
v = ((v >> 2) & m2) | ((v & m2) << 2);
v = ((v >> 4) & m4) | ((v & m4) << 4);
return blByteSwap(T(v));
}
} // {anonymous}
// ============================================================================
// [Bit Leading/Trailing Zeros Counting]
// ============================================================================
namespace {
template<typename T>
struct BLBitScanData { T x; uint32_t n; };
template<typename T, uint32_t N>
struct BLBitScanCalc {
BL_NODISCARD
static constexpr BLBitScanData<T> advanceLeft(const BLBitScanData<T>& data, uint32_t n) noexcept {
return BLBitScanData<T> { data.x << n, data.n + n };
}
BL_NODISCARD
static constexpr BLBitScanData<T> advanceRight(const BLBitScanData<T>& data, uint32_t n) noexcept {
return BLBitScanData<T> { data.x >> n, data.n + n };
}
BL_NODISCARD
static constexpr BLBitScanData<T> clz(const BLBitScanData<T>& data) noexcept {
return BLBitScanCalc<T, N / 2>::clz(advanceLeft(data, data.x & (blBitOnes<T>() << (blBitSizeOf<T>() - N)) ? uint32_t(0) : N));
}
BL_NODISCARD
static constexpr BLBitScanData<T> ctz(const BLBitScanData<T>& data) noexcept {
return BLBitScanCalc<T, N / 2>::ctz(advanceRight(data, data.x & (blBitOnes<T>() >> (blBitSizeOf<T>() - N)) ? uint32_t(0) : N));
}
};
template<typename T>
struct BLBitScanCalc<T, 0> {
BL_NODISCARD
static constexpr BLBitScanData<T> clz(const BLBitScanData<T>& ctx) noexcept {
return BLBitScanData<T> { 0, ctx.n - uint32_t(ctx.x >> (blBitSizeOf<T>() - 1)) };
}
BL_NODISCARD
static constexpr BLBitScanData<T> ctz(const BLBitScanData<T>& ctx) noexcept {
return BLBitScanData<T> { 0, ctx.n - uint32_t(ctx.x & 0x1) };
}
};
template<typename T>
BL_NODISCARD
constexpr uint32_t blBitClzFallback(const T& x) noexcept {
return BLBitScanCalc<T, blBitSizeOf<T>() / 2u>::clz(BLBitScanData<T>{x, 1}).n;
}
template<typename T>
BL_NODISCARD
constexpr uint32_t blBitCtzFallback(const T& x) noexcept {
return BLBitScanCalc<T, blBitSizeOf<T>() / 2u>::ctz(BLBitScanData<T>{x, 1}).n;
}
template<typename T> BL_NODISCARD constexpr uint32_t blBitClzStatic(const T& x) noexcept { return blBitClzFallback(blAsUIntLeast32(x)); }
template<typename T> BL_NODISCARD constexpr uint32_t blBitCtzStatic(const T& x) noexcept { return blBitCtzFallback(blAsUIntLeast32(x)); }
template<typename T> BL_NODISCARD BL_INLINE uint32_t blBitClzImpl(const T& x) noexcept { return blBitClzStatic(x); }
template<typename T> BL_NODISCARD BL_INLINE uint32_t blBitCtzImpl(const T& x) noexcept { return blBitCtzStatic(x); }
#if !defined(BL_BUILD_NO_INTRINSICS)
# if defined(__GNUC__)
template<> BL_NODISCARD BL_INLINE uint32_t blBitClzImpl(const uint32_t& x) noexcept { return uint32_t(__builtin_clz(x)); }
template<> BL_NODISCARD BL_INLINE uint32_t blBitClzImpl(const uint64_t& x) noexcept { return uint32_t(__builtin_clzll(x)); }
template<> BL_NODISCARD BL_INLINE uint32_t blBitCtzImpl(const uint32_t& x) noexcept { return uint32_t(__builtin_ctz(x)); }
template<> BL_NODISCARD BL_INLINE uint32_t blBitCtzImpl(const uint64_t& x) noexcept { return uint32_t(__builtin_ctzll(x)); }
# elif defined(_MSC_VER)
template<> BL_NODISCARD BL_INLINE uint32_t blBitClzImpl(const uint32_t& x) noexcept { unsigned long i; _BitScanReverse(&i, x); return uint32_t(i ^ 31); }
template<> BL_NODISCARD BL_INLINE uint32_t blBitCtzImpl(const uint32_t& x) noexcept { unsigned long i; _BitScanForward(&i, x); return uint32_t(i); }
# if BL_TARGET_ARCH_X86 == 64 || BL_TARGET_ARCH_ARM == 64
template<> BL_NODISCARD BL_INLINE uint32_t blBitClzImpl(const uint64_t& x) noexcept { unsigned long i; _BitScanReverse64(&i, x); return uint32_t(i ^ 63); }
template<> BL_NODISCARD BL_INLINE uint32_t blBitCtzImpl(const uint64_t& x) noexcept { unsigned long i; _BitScanForward64(&i, x); return uint32_t(i); }
# endif
# endif
#endif
//! Counts leading zeros in `x`.
//!
//! \note If the input is zero the result is undefined.
template<typename T>
BL_NODISCARD
static BL_INLINE uint32_t blBitClz(T x) noexcept { return blBitClzImpl(blAsUIntLeast32(x)); }
//! Counts trailing zeros in `x`.
//!
//! \note If the input is zero the result is undefined.
template<typename T>
BL_NODISCARD
static BL_INLINE uint32_t blBitCtz(T x) noexcept { return blBitCtzImpl(blAsUIntLeast32(x)); }
template<typename T>
BL_NODISCARD
static BL_INLINE constexpr uint32_t blBitShiftOf(const T& x) noexcept { return blBitCtzStatic(x); }
} // {anonymous}
// ============================================================================
// [Bit Population Count]
// ============================================================================
// Based on the following resource:
// http://graphics.stanford.edu/~seander/bithacks.html
//
// Alternatively, for a very small number of bits in `x`:
// uint32_t n = 0;
// while (x) {
// x &= x - 1;
// n++;
// }
// return n;
namespace {
template<typename T>
BL_NODISCARD
static BL_INLINE uint32_t blPopCountStatic(const T& x) noexcept {
typedef typename std::make_unsigned<T>::type U;
const U m1 = U(0x5555555555555555u & blBitOnes<U>());
const U m2 = U(0x3333333333333333u & blBitOnes<U>());
const U m4 = U(0x0F0F0F0F0F0F0F0Fu & blBitOnes<U>());
const U mX = U(0x0101010101010101u & blBitOnes<U>());
U u = U(x);
u -= ((u >> 1) & m1);
u = ((u >> 2) & m2) + (u & m2);
u = ((u >> 4) + u) & m4;
if (sizeof(T) > 1)
return uint32_t((u * mX) >> (blBitSizeOf<T>() - 8));
else
return uint32_t(u & 0xFFu);
}
BL_NODISCARD
static BL_INLINE uint32_t blPopCountImpl(uint32_t x) noexcept {
#if defined(__GNUC__)
return uint32_t(__builtin_popcount(x));
#elif defined(_MSC_VER) && defined(BL_TARGET_OPT_POPCNT)
return __popcnt(x);
#else
return blPopCountStatic(x);
#endif
}
BL_NODISCARD
static BL_INLINE uint32_t blPopCountImpl(uint64_t x) noexcept {
#if defined(__GNUC__)
return uint32_t(__builtin_popcountll(x));
#elif defined(_MSC_VER) && defined(BL_TARGET_OPT_POPCNT) && BL_TARGET_ARCH_BITS >= 64
return uint32_t(__popcnt64(x));
#elif BL_TARGET_ARCH_BITS >= 64
return blPopCountImpl(uint32_t(x >> 32)) + blPopCountImpl(uint32_t(x & 0xFFFFFFFFu));
#else
return blPopCountStatic(x);
#endif
}
} // {anonymous}
//! Calculates count of bits in `x`.
template<typename T>
BL_NODISCARD
static BL_INLINE uint32_t blPopCount(T x) noexcept { return blPopCountImpl(blAsUIntLeast32(x)); }
// ============================================================================
// [Alignment]
// ============================================================================
template<typename X, typename Y>
BL_NODISCARD
static constexpr bool blIsAligned(const X& base, const Y& alignment) noexcept {
typedef typename BLInternal::StdInt<sizeof(X), 1>::Type U;
return ((U)base % (U)alignment) == 0;
}
//! Tests whether the `x` is a power of two (only one bit is set).
template<typename T>
BL_NODISCARD
static constexpr bool blIsPowerOf2(const T& x) noexcept {
typedef typename std::make_unsigned<T>::type U;
return x && !(U(x) & (U(x) - U(1)));
}
template<typename X, typename Y>
BL_NODISCARD
static constexpr X blAlignUp(const X& x, const Y& alignment) noexcept {
typedef typename BLInternal::StdInt<sizeof(X), 1>::Type U;
return (X)( ((U)x + ((U)(alignment) - 1u)) & ~((U)(alignment) - 1u) );
}
template<typename T>
BL_NODISCARD
static constexpr T blAlignUpPowerOf2(const T& x) noexcept {
typedef typename BLInternal::StdInt<sizeof(T), 1>::Type U;
return (T)(blFillTrailingBits(U(x) - 1u) + 1u);
}
//! Returns zero or a positive difference between `base` and `base` aligned to `alignment`.
template<typename X, typename Y>
BL_NODISCARD
static constexpr X blAlignUpDiff(const X& base, const Y& alignment) noexcept {
typedef typename BLInternal::StdInt<sizeof(X), 1>::Type U;
return blAlignUp(U(base), alignment) - U(base);
}
template<typename X, typename Y>
BL_NODISCARD
static constexpr X blAlignDown(const X& x, const Y& alignment) noexcept {
typedef typename BLInternal::StdInt<sizeof(X), 1>::Type U;
return (X)( (U)x & ~((U)(alignment) - 1u) );
}
// ============================================================================
// [Pointer Utilities]
// ============================================================================
template<typename T, typename Offset>
BL_NODISCARD
static constexpr T* blOffsetPtr(T* ptr, Offset offset) noexcept { return (T*)((uintptr_t)(ptr) + (uintptr_t)(intptr_t)offset); }
template<typename T, typename P, typename Offset>
BL_NODISCARD
static constexpr T* blOffsetPtr(P* ptr, Offset offset) noexcept { return (T*)((uintptr_t)(ptr) + (uintptr_t)(intptr_t)offset); }
// ============================================================================
// [ClampTo]
// ============================================================================
template<typename SrcT, typename DstT>
BL_NODISCARD
static constexpr DstT blClampToImpl(const SrcT& x, const DstT& y) noexcept {
typedef typename std::make_unsigned<SrcT>::type U;
return U(x) <= U(y) ? DstT(x) :
blIsUnsigned<SrcT>() ? DstT(y) : DstT(SrcT(y) & SrcT(blBitSar(blNegate(x), sizeof(SrcT) * 8 - 1)));
}
//! Clamp a value `x` to a byte (unsigned 8-bit type).
template<typename T>
BL_NODISCARD
static constexpr uint8_t blClampToByte(const T& x) noexcept {
return blClampToImpl<T, uint8_t>(x, uint8_t(0xFFu));
}
//! Clamp a value `x` to a word (unsigned 16-bit type).
template<typename T>
BL_NODISCARD
static constexpr uint16_t blClampToWord(const T& x) noexcept {
return blClampToImpl<T, uint16_t>(x, uint16_t(0xFFFFu));
}
// ============================================================================
// [Arithmetic]
// ============================================================================
typedef unsigned char BLOverflowFlag;
namespace BLInternal {
template<typename T>
BL_INLINE T addOverflowFallback(T x, T y, BLOverflowFlag* of) noexcept {
typedef typename std::make_unsigned<T>::type U;
U result = U(x) + U(y);
*of |= BLOverflowFlag(blIsUnsigned<T>() ? result < U(x) : T((U(x) ^ ~U(y)) & (U(x) ^ result)) < 0);
return T(result);
}
template<typename T>
BL_INLINE T subOverflowFallback(T x, T y, BLOverflowFlag* of) noexcept {
typedef typename std::make_unsigned<T>::type U;
U result = U(x) - U(y);
*of |= BLOverflowFlag(blIsUnsigned<T>() ? result > U(x) : T((U(x) ^ U(y)) & (U(x) ^ result)) < 0);
return T(result);
}
template<typename T>
BL_INLINE T mulOverflowFallback(T x, T y, BLOverflowFlag* of) noexcept {
typedef typename BLInternal::StdInt<sizeof(T) * 2, blIsUnsigned<T>()>::Type I;
typedef typename std::make_unsigned<I>::type U;
U mask = U(blMaxValue<typename std::make_unsigned<T>::type>());
if (std::is_signed<T>::value) {
U prod = U(I(x)) * U(I(y));
*of |= BLOverflowFlag(I(prod) < I(blMinValue<T>()) || I(prod) > I(blMaxValue<T>()));
return T(I(prod & mask));
}
else {
U prod = U(x) * U(y);
*of |= BLOverflowFlag((prod & ~mask) != 0);
return T(prod & mask);
}
}
template<>
BL_INLINE int64_t mulOverflowFallback(int64_t x, int64_t y, BLOverflowFlag* of) noexcept {
int64_t result = int64_t(uint64_t(x) * uint64_t(y));
*of |= BLOverflowFlag(x && (result / x != y));
return result;
}
template<>
BL_INLINE uint64_t mulOverflowFallback(uint64_t x, uint64_t y, BLOverflowFlag* of) noexcept {
uint64_t result = x * y;
*of |= BLOverflowFlag(y != 0 && blMaxValue<uint64_t>() / y < x);
return result;
}
// These can be specialized.
template<typename T> BL_INLINE T addOverflowImpl(const T& x, const T& y, BLOverflowFlag* of) noexcept { return addOverflowFallback(x, y, of); }
template<typename T> BL_INLINE T subOverflowImpl(const T& x, const T& y, BLOverflowFlag* of) noexcept { return subOverflowFallback(x, y, of); }
template<typename T> BL_INLINE T mulOverflowImpl(const T& x, const T& y, BLOverflowFlag* of) noexcept { return mulOverflowFallback(x, y, of); }
#if defined(__GNUC__) && !defined(BL_BUILD_NO_INTRINSICS)
#if defined(__clang__) || __GNUC__ >= 5
#define BL_ARITH_OVERFLOW_SPECIALIZE(FUNC, T, RESULT_T, BUILTIN) \
template<> \
BL_INLINE T FUNC(const T& x, const T& y, BLOverflowFlag* of) noexcept { \
RESULT_T result; \
*of |= BLOverflowFlag(BUILTIN((RESULT_T)x, (RESULT_T)y, &result)); \
return T(result); \
}
BL_ARITH_OVERFLOW_SPECIALIZE(addOverflowImpl, int32_t , int , __builtin_sadd_overflow )
BL_ARITH_OVERFLOW_SPECIALIZE(addOverflowImpl, uint32_t, unsigned int , __builtin_uadd_overflow )
BL_ARITH_OVERFLOW_SPECIALIZE(addOverflowImpl, int64_t , long long , __builtin_saddll_overflow)
BL_ARITH_OVERFLOW_SPECIALIZE(addOverflowImpl, uint64_t, unsigned long long, __builtin_uaddll_overflow)
BL_ARITH_OVERFLOW_SPECIALIZE(subOverflowImpl, int32_t , int , __builtin_ssub_overflow )
BL_ARITH_OVERFLOW_SPECIALIZE(subOverflowImpl, uint32_t, unsigned int , __builtin_usub_overflow )
BL_ARITH_OVERFLOW_SPECIALIZE(subOverflowImpl, int64_t , long long , __builtin_ssubll_overflow)
BL_ARITH_OVERFLOW_SPECIALIZE(subOverflowImpl, uint64_t, unsigned long long, __builtin_usubll_overflow)
BL_ARITH_OVERFLOW_SPECIALIZE(mulOverflowImpl, int32_t , int , __builtin_smul_overflow )
BL_ARITH_OVERFLOW_SPECIALIZE(mulOverflowImpl, uint32_t, unsigned int , __builtin_umul_overflow )
BL_ARITH_OVERFLOW_SPECIALIZE(mulOverflowImpl, int64_t , long long , __builtin_smulll_overflow)
BL_ARITH_OVERFLOW_SPECIALIZE(mulOverflowImpl, uint64_t, unsigned long long, __builtin_umulll_overflow)
#undef BL_ARITH_OVERFLOW_SPECIALIZE
#endif
#endif
// There is a bug in MSVC that makes these specializations unusable, maybe in the future...
#if defined(_MSC_VER) && 0
#define BL_ARITH_OVERFLOW_SPECIALIZE(FUNC, T, ALT_T, BUILTIN) \
template<> \
BL_INLINE T FUNC(T x, T y, BLOverflowFlag* of) noexcept { \
ALT_T result; \
*of |= BLOverflowFlag(BUILTIN(0, (ALT_T)x, (ALT_T)y, &result)); \
return T(result); \
}
BL_ARITH_OVERFLOW_SPECIALIZE(addOverflowImpl, uint32_t, unsigned int , _addcarry_u32 )
BL_ARITH_OVERFLOW_SPECIALIZE(subOverflowImpl, uint32_t, unsigned int , _subborrow_u32)
#if ARCH_BITS >= 64
BL_ARITH_OVERFLOW_SPECIALIZE(addOverflowImpl, uint64_t, unsigned __int64 , _addcarry_u64 )
BL_ARITH_OVERFLOW_SPECIALIZE(subOverflowImpl, uint64_t, unsigned __int64 , _subborrow_u64)
#endif
#undef BL_ARITH_OVERFLOW_SPECIALIZE
#endif
} // {BLInternal}
template<typename T>
BL_NODISCARD
static BL_INLINE T blAddOverflow(const T& x, const T& y, BLOverflowFlag* of) noexcept { return T(BLInternal::addOverflowImpl(blAsStdInt(x), blAsStdInt(y), of)); }
template<typename T>
BL_NODISCARD
static BL_INLINE T blSubOverflow(const T& x, const T& y, BLOverflowFlag* of) noexcept { return T(BLInternal::subOverflowImpl(blAsStdInt(x), blAsStdInt(y), of)); }
template<typename T>
BL_NODISCARD
static BL_INLINE T blMulOverflow(const T& x, const T& y, BLOverflowFlag* of) noexcept { return T(BLInternal::mulOverflowImpl(blAsStdInt(x), blAsStdInt(y), of)); }
template<typename T>
BL_NODISCARD
static BL_INLINE T blUAddSaturate(const T& x, const T& y) noexcept {
BLOverflowFlag of = 0;
T result = blAddOverflow(x, y, &of);
return T(result | blBitMaskFromBool<T>(of));
}
template<typename T>
BL_NODISCARD
static BL_INLINE T blUSubSaturate(const T& x, const T& y) noexcept {
BLOverflowFlag of = 0;
T result = blSubOverflow(x, y, &of);
return T(result & blBitMaskFromBool<T>(!of));
}
template<typename T>
BL_NODISCARD
static BL_INLINE T blUMulSaturate(const T& x, const T& y) noexcept {
BLOverflowFlag of = 0;
T result = blMulOverflow(x, y, &of);
return T(result | blBitMaskFromBool<T>(of));
}
// ============================================================================
// [Udiv255]
// ============================================================================
//! Integer division by 255 with correct rounding semantics.
//!
//! Possible implementations:
//! - `((x + 128) + ((x + 128) >> 8)) >> 8` (used by scalar operations and AVX+ impls).
//! - `((x + 128) * 257) >> 16` (used by SSE2 to SSE4.1 impl, but not by AVX).
BL_NODISCARD
static BL_INLINE uint32_t blUdiv255(uint32_t x) noexcept {
return ((x + 128) * 257) >> 16;
}
// ============================================================================
// [blMemRead]
// ============================================================================
namespace {
BL_NODISCARD BL_INLINE uint32_t blMemReadU8(const void* p) noexcept { return uint32_t(static_cast<const uint8_t*>(p)[0]); }
BL_NODISCARD BL_INLINE int32_t blMemReadI8(const void* p) noexcept { return int32_t(static_cast<const int8_t*>(p)[0]); }
template<uint32_t ByteOrder, size_t Alignment>
BL_NODISCARD
BL_INLINE uint32_t blMemReadU16(const void* p) noexcept {
if (ByteOrder == BL_BYTE_ORDER_NATIVE && (BL_UNALIGNED_IO_16 || Alignment >= 2)) {
typedef typename BLMisalignedUInt<uint16_t, Alignment>::T U16AlignedToN;
return uint32_t(static_cast<const U16AlignedToN*>(p)[0]);
}
else {
uint32_t hi = blMemReadU8(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 1 : 0));
uint32_t lo = blMemReadU8(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 0 : 1));
return blBitShl(hi, 8) | lo;
}
}
template<uint32_t ByteOrder, size_t Alignment>
BL_NODISCARD
BL_INLINE int32_t blMemReadI16(const void* p) noexcept {
if (ByteOrder == BL_BYTE_ORDER_NATIVE && (BL_UNALIGNED_IO_16 || Alignment >= 2)) {
typedef typename BLMisalignedUInt<uint16_t, Alignment>::T U16AlignedToN;
return int32_t(int16_t(static_cast<const U16AlignedToN*>(p)[0]));
}
else {
int32_t hi = int32_t(blMemReadI8(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 1 : 0)));
int32_t lo = int32_t(blMemReadU8(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 0 : 1)));
return blBitShl(hi, 8) | lo;
}
}
template<uint32_t ByteOrder = BL_BYTE_ORDER_NATIVE>
BL_NODISCARD
BL_INLINE uint32_t blMemReadU24u(const void* p) noexcept {
uint32_t b0 = blMemReadU8(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 2 : 0));
uint32_t b1 = blMemReadU8(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 1 : 1));
uint32_t b2 = blMemReadU8(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 0 : 2));
return blBitShl(b0, 16) | blBitShl(b1, 8) | b2;
}
template<uint32_t ByteOrder, size_t Alignment>
BL_NODISCARD
BL_INLINE uint32_t blMemReadU32(const void* p) noexcept {
if (BL_UNALIGNED_IO_32 || Alignment >= 4) {
typedef typename BLMisalignedUInt<uint32_t, Alignment>::T U32AlignedToN;
uint32_t x = static_cast<const U32AlignedToN*>(p)[0];
return ByteOrder == BL_BYTE_ORDER_NATIVE ? x : blByteSwap32(x);
}
else {
uint32_t hi = blMemReadU16<ByteOrder, Alignment >= 2 ? size_t(2) : Alignment>(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 2 : 0));
uint32_t lo = blMemReadU16<ByteOrder, Alignment >= 2 ? size_t(2) : Alignment>(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 0 : 2));
return blBitShl(hi, 16) | lo;
}
}
template<uint32_t ByteOrder, size_t Alignment>
BL_NODISCARD
BL_INLINE uint64_t blMemReadU64(const void* p) noexcept {
if (ByteOrder == BL_BYTE_ORDER_NATIVE && (BL_UNALIGNED_IO_64 || Alignment >= 8)) {
typedef typename BLMisalignedUInt<uint64_t, Alignment>::T U64AlignedToN;
return static_cast<const U64AlignedToN*>(p)[0];
}
else {
uint32_t hi = blMemReadU32<ByteOrder, Alignment >= 4 ? size_t(4) : Alignment>(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 4 : 0));
uint32_t lo = blMemReadU32<ByteOrder, Alignment >= 4 ? size_t(4) : Alignment>(static_cast<const uint8_t*>(p) + (ByteOrder == BL_BYTE_ORDER_LE ? 0 : 4));
return blBitShl(uint64_t(hi), 32) | lo;
}
}
template<uint32_t ByteOrder, size_t Alignment>
BL_NODISCARD BL_INLINE int32_t blMemReadI32(const void* p) noexcept { return int32_t(blMemReadU32<ByteOrder, Alignment>(p)); }
template<uint32_t ByteOrder, size_t Alignment>
BL_NODISCARD BL_INLINE int64_t blMemReadI64(const void* p) noexcept { return int64_t(blMemReadU64<ByteOrder, Alignment>(p)); }
BL_NODISCARD BL_INLINE int32_t blMemReadI16a(const void* p) noexcept { return blMemReadI16<BL_BYTE_ORDER_NATIVE, 2>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI16u(const void* p) noexcept { return blMemReadI16<BL_BYTE_ORDER_NATIVE, 1>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU16a(const void* p) noexcept { return blMemReadU16<BL_BYTE_ORDER_NATIVE, 2>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU16u(const void* p) noexcept { return blMemReadU16<BL_BYTE_ORDER_NATIVE, 1>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI16aLE(const void* p) noexcept { return blMemReadI16<BL_BYTE_ORDER_LE, 2>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI16uLE(const void* p) noexcept { return blMemReadI16<BL_BYTE_ORDER_LE, 1>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU16aLE(const void* p) noexcept { return blMemReadU16<BL_BYTE_ORDER_LE, 2>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU16uLE(const void* p) noexcept { return blMemReadU16<BL_BYTE_ORDER_LE, 1>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI16aBE(const void* p) noexcept { return blMemReadI16<BL_BYTE_ORDER_BE, 2>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI16uBE(const void* p) noexcept { return blMemReadI16<BL_BYTE_ORDER_BE, 1>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU16aBE(const void* p) noexcept { return blMemReadU16<BL_BYTE_ORDER_BE, 2>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU16uBE(const void* p) noexcept { return blMemReadU16<BL_BYTE_ORDER_BE, 1>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU24uLE(const void* p) noexcept { return blMemReadU24u<BL_BYTE_ORDER_LE>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU24uBE(const void* p) noexcept { return blMemReadU24u<BL_BYTE_ORDER_BE>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI32a(const void* p) noexcept { return blMemReadI32<BL_BYTE_ORDER_NATIVE, 4>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI32u(const void* p) noexcept { return blMemReadI32<BL_BYTE_ORDER_NATIVE, 1>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU32a(const void* p) noexcept { return blMemReadU32<BL_BYTE_ORDER_NATIVE, 4>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU32u(const void* p) noexcept { return blMemReadU32<BL_BYTE_ORDER_NATIVE, 1>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI32aLE(const void* p) noexcept { return blMemReadI32<BL_BYTE_ORDER_LE, 4>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI32uLE(const void* p) noexcept { return blMemReadI32<BL_BYTE_ORDER_LE, 1>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU32aLE(const void* p) noexcept { return blMemReadU32<BL_BYTE_ORDER_LE, 4>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU32uLE(const void* p) noexcept { return blMemReadU32<BL_BYTE_ORDER_LE, 1>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI32aBE(const void* p) noexcept { return blMemReadI32<BL_BYTE_ORDER_BE, 4>(p); }
BL_NODISCARD BL_INLINE int32_t blMemReadI32uBE(const void* p) noexcept { return blMemReadI32<BL_BYTE_ORDER_BE, 1>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU32aBE(const void* p) noexcept { return blMemReadU32<BL_BYTE_ORDER_BE, 4>(p); }
BL_NODISCARD BL_INLINE uint32_t blMemReadU32uBE(const void* p) noexcept { return blMemReadU32<BL_BYTE_ORDER_BE, 1>(p); }
BL_NODISCARD BL_INLINE int64_t blMemReadI64a(const void* p) noexcept { return blMemReadI64<BL_BYTE_ORDER_NATIVE, 8>(p); }
BL_NODISCARD BL_INLINE int64_t blMemReadI64u(const void* p) noexcept { return blMemReadI64<BL_BYTE_ORDER_NATIVE, 1>(p); }
BL_NODISCARD BL_INLINE uint64_t blMemReadU64a(const void* p) noexcept { return blMemReadU64<BL_BYTE_ORDER_NATIVE, 8>(p); }
BL_NODISCARD BL_INLINE uint64_t blMemReadU64u(const void* p) noexcept { return blMemReadU64<BL_BYTE_ORDER_NATIVE, 1>(p); }
BL_NODISCARD BL_INLINE int64_t blMemReadI64aLE(const void* p) noexcept { return blMemReadI64<BL_BYTE_ORDER_LE, 8>(p); }
BL_NODISCARD BL_INLINE int64_t blMemReadI64uLE(const void* p) noexcept { return blMemReadI64<BL_BYTE_ORDER_LE, 1>(p); }
BL_NODISCARD BL_INLINE uint64_t blMemReadU64aLE(const void* p) noexcept { return blMemReadU64<BL_BYTE_ORDER_LE, 8>(p); }
BL_NODISCARD BL_INLINE uint64_t blMemReadU64uLE(const void* p) noexcept { return blMemReadU64<BL_BYTE_ORDER_LE, 1>(p); }
BL_NODISCARD BL_INLINE int64_t blMemReadI64aBE(const void* p) noexcept { return blMemReadI64<BL_BYTE_ORDER_BE, 8>(p); }
BL_NODISCARD BL_INLINE int64_t blMemReadI64uBE(const void* p) noexcept { return blMemReadI64<BL_BYTE_ORDER_BE, 1>(p); }
BL_NODISCARD BL_INLINE uint64_t blMemReadU64aBE(const void* p) noexcept { return blMemReadU64<BL_BYTE_ORDER_BE, 8>(p); }
BL_NODISCARD BL_INLINE uint64_t blMemReadU64uBE(const void* p) noexcept { return blMemReadU64<BL_BYTE_ORDER_BE, 1>(p); }
} // {anonymous}
// ============================================================================
// [blMemWrite]
// ============================================================================
namespace {
BL_INLINE void blMemWriteU8(void* p, uint32_t x) noexcept { static_cast<uint8_t*>(p)[0] = uint8_t(x & 0xFFu); }
BL_INLINE void blMemWriteI8(void* p, int32_t x) noexcept { static_cast<uint8_t*>(p)[0] = uint8_t(x & 0xFF); }
template<uint32_t ByteOrder, size_t Alignment>
BL_INLINE void blMemWriteU16(void* p, uint32_t x) noexcept {
if (ByteOrder == BL_BYTE_ORDER_NATIVE && (BL_UNALIGNED_IO_16 || Alignment >= 2)) {
typedef typename BLMisalignedUInt<uint16_t, Alignment>::T U16AlignedToN;
static_cast<U16AlignedToN*>(p)[0] = uint16_t(x & 0xFFFFu);
}
else {
static_cast<uint8_t*>(p)[0] = uint8_t((x >> (ByteOrder == BL_BYTE_ORDER_LE ? 0 : 8)) & 0xFFu);
static_cast<uint8_t*>(p)[1] = uint8_t((x >> (ByteOrder == BL_BYTE_ORDER_LE ? 8 : 0)) & 0xFFu);
}
}
template<uint32_t ByteOrder = BL_BYTE_ORDER_NATIVE>
BL_INLINE void blMemWriteU24u(void* p, uint32_t v) noexcept {
static_cast<uint8_t*>(p)[0] = uint8_t((v >> (ByteOrder == BL_BYTE_ORDER_LE ? 0 : 16)) & 0xFFu);
static_cast<uint8_t*>(p)[1] = uint8_t((v >> (ByteOrder == BL_BYTE_ORDER_LE ? 8 : 8)) & 0xFFu);
static_cast<uint8_t*>(p)[2] = uint8_t((v >> (ByteOrder == BL_BYTE_ORDER_LE ? 16 : 0)) & 0xFFu);
}
template<uint32_t ByteOrder, size_t Alignment>
BL_INLINE void blMemWriteU32(void* p, uint32_t x) noexcept {
if (BL_UNALIGNED_IO_32 || Alignment >= 4) {
typedef typename BLMisalignedUInt<uint32_t, Alignment>::T U32AlignedToN;
static_cast<U32AlignedToN*>(p)[0] = (ByteOrder == BL_BYTE_ORDER_NATIVE) ? x : blByteSwap32(x);
}
else {
blMemWriteU16<ByteOrder, Alignment >= 2 ? size_t(2) : Alignment>(static_cast<uint8_t*>(p) + 0, x >> (ByteOrder == BL_BYTE_ORDER_LE ? 0 : 16));
blMemWriteU16<ByteOrder, Alignment >= 2 ? size_t(2) : Alignment>(static_cast<uint8_t*>(p) + 2, x >> (ByteOrder == BL_BYTE_ORDER_LE ? 16 : 0));
}
}
template<uint32_t ByteOrder, size_t Alignment>
BL_INLINE void blMemWriteU64(void* p, uint64_t x) noexcept {
if (ByteOrder == BL_BYTE_ORDER_NATIVE && (BL_UNALIGNED_IO_64 || Alignment >= 8)) {
typedef typename BLMisalignedUInt<uint64_t, Alignment>::T U64AlignedToN;
static_cast<U64AlignedToN*>(p)[0] = x;
}
else {
blMemWriteU32<ByteOrder, Alignment >= 4 ? size_t(4) : Alignment>(static_cast<uint8_t*>(p) + 0, uint32_t((x >> (ByteOrder == BL_BYTE_ORDER_LE ? 0 : 32)) & 0xFFFFFFFFu));
blMemWriteU32<ByteOrder, Alignment >= 4 ? size_t(4) : Alignment>(static_cast<uint8_t*>(p) + 4, uint32_t((x >> (ByteOrder == BL_BYTE_ORDER_LE ? 32 : 0)) & 0xFFFFFFFFu));
}
}
template<uint32_t ByteOrder, size_t Alignment> BL_INLINE void blMemWriteI16(void* p, int32_t x) noexcept { blMemWriteU16<ByteOrder, Alignment>(p, uint32_t(x)); }
template<uint32_t ByteOrder, size_t Alignment> BL_INLINE void blMemWriteI32(void* p, int32_t x) noexcept { blMemWriteU32<ByteOrder, Alignment>(p, uint32_t(x)); }
template<uint32_t ByteOrder, size_t Alignment> BL_INLINE void blMemWriteI64(void* p, int64_t x) noexcept { blMemWriteU64<ByteOrder, Alignment>(p, uint64_t(x)); }
BL_INLINE void blMemWriteI16a(void* p, int32_t x) noexcept { blMemWriteI16<BL_BYTE_ORDER_NATIVE, 2>(p, x); }
BL_INLINE void blMemWriteI16u(void* p, int32_t x) noexcept { blMemWriteI16<BL_BYTE_ORDER_NATIVE, 1>(p, x); }
BL_INLINE void blMemWriteU16a(void* p, uint32_t x) noexcept { blMemWriteU16<BL_BYTE_ORDER_NATIVE, 2>(p, x); }
BL_INLINE void blMemWriteU16u(void* p, uint32_t x) noexcept { blMemWriteU16<BL_BYTE_ORDER_NATIVE, 1>(p, x); }
BL_INLINE void blMemWriteI16aLE(void* p, int32_t x) noexcept { blMemWriteI16<BL_BYTE_ORDER_LE, 2>(p, x); }
BL_INLINE void blMemWriteI16uLE(void* p, int32_t x) noexcept { blMemWriteI16<BL_BYTE_ORDER_LE, 1>(p, x); }
BL_INLINE void blMemWriteU16aLE(void* p, uint32_t x) noexcept { blMemWriteU16<BL_BYTE_ORDER_LE, 2>(p, x); }
BL_INLINE void blMemWriteU16uLE(void* p, uint32_t x) noexcept { blMemWriteU16<BL_BYTE_ORDER_LE, 1>(p, x); }
BL_INLINE void blMemWriteI16aBE(void* p, int32_t x) noexcept { blMemWriteI16<BL_BYTE_ORDER_BE, 2>(p, x); }
BL_INLINE void blMemWriteI16uBE(void* p, int32_t x) noexcept { blMemWriteI16<BL_BYTE_ORDER_BE, 1>(p, x); }
BL_INLINE void blMemWriteU16aBE(void* p, uint32_t x) noexcept { blMemWriteU16<BL_BYTE_ORDER_BE, 2>(p, x); }
BL_INLINE void blMemWriteU16uBE(void* p, uint32_t x) noexcept { blMemWriteU16<BL_BYTE_ORDER_BE, 1>(p, x); }
BL_INLINE void blMemWriteU24uLE(void* p, uint32_t v) noexcept { blMemWriteU24u<BL_BYTE_ORDER_LE>(p, v); }
BL_INLINE void blMemWriteU24uBE(void* p, uint32_t v) noexcept { blMemWriteU24u<BL_BYTE_ORDER_BE>(p, v); }
BL_INLINE void blMemWriteI32a(void* p, int32_t x) noexcept { blMemWriteI32<BL_BYTE_ORDER_NATIVE, 4>(p, x); }
BL_INLINE void blMemWriteI32u(void* p, int32_t x) noexcept { blMemWriteI32<BL_BYTE_ORDER_NATIVE, 1>(p, x); }
BL_INLINE void blMemWriteU32a(void* p, uint32_t x) noexcept { blMemWriteU32<BL_BYTE_ORDER_NATIVE, 4>(p, x); }
BL_INLINE void blMemWriteU32u(void* p, uint32_t x) noexcept { blMemWriteU32<BL_BYTE_ORDER_NATIVE, 1>(p, x); }
BL_INLINE void blMemWriteI32aLE(void* p, int32_t x) noexcept { blMemWriteI32<BL_BYTE_ORDER_LE, 4>(p, x); }
BL_INLINE void blMemWriteI32uLE(void* p, int32_t x) noexcept { blMemWriteI32<BL_BYTE_ORDER_LE, 1>(p, x); }
BL_INLINE void blMemWriteU32aLE(void* p, uint32_t x) noexcept { blMemWriteU32<BL_BYTE_ORDER_LE, 4>(p, x); }
BL_INLINE void blMemWriteU32uLE(void* p, uint32_t x) noexcept { blMemWriteU32<BL_BYTE_ORDER_LE, 1>(p, x); }
BL_INLINE void blMemWriteI32aBE(void* p, int32_t x) noexcept { blMemWriteI32<BL_BYTE_ORDER_BE, 4>(p, x); }
BL_INLINE void blMemWriteI32uBE(void* p, int32_t x) noexcept { blMemWriteI32<BL_BYTE_ORDER_BE, 1>(p, x); }
BL_INLINE void blMemWriteU32aBE(void* p, uint32_t x) noexcept { blMemWriteU32<BL_BYTE_ORDER_BE, 4>(p, x); }
BL_INLINE void blMemWriteU32uBE(void* p, uint32_t x) noexcept { blMemWriteU32<BL_BYTE_ORDER_BE, 1>(p, x); }
BL_INLINE void blMemWriteI64a(void* p, int64_t x) noexcept { blMemWriteI64<BL_BYTE_ORDER_NATIVE, 8>(p, x); }
BL_INLINE void blMemWriteI64u(void* p, int64_t x) noexcept { blMemWriteI64<BL_BYTE_ORDER_NATIVE, 1>(p, x); }
BL_INLINE void blMemWriteU64a(void* p, uint64_t x) noexcept { blMemWriteU64<BL_BYTE_ORDER_NATIVE, 8>(p, x); }
BL_INLINE void blMemWriteU64u(void* p, uint64_t x) noexcept { blMemWriteU64<BL_BYTE_ORDER_NATIVE, 1>(p, x); }
BL_INLINE void blMemWriteI64aLE(void* p, int64_t x) noexcept { blMemWriteI64<BL_BYTE_ORDER_LE, 8>(p, x); }
BL_INLINE void blMemWriteI64uLE(void* p, int64_t x) noexcept { blMemWriteI64<BL_BYTE_ORDER_LE, 1>(p, x); }
BL_INLINE void blMemWriteU64aLE(void* p, uint64_t x) noexcept { blMemWriteU64<BL_BYTE_ORDER_LE, 8>(p, x); }
BL_INLINE void blMemWriteU64uLE(void* p, uint64_t x) noexcept { blMemWriteU64<BL_BYTE_ORDER_LE, 1>(p, x); }
BL_INLINE void blMemWriteI64aBE(void* p, int64_t x) noexcept { blMemWriteI64<BL_BYTE_ORDER_BE, 8>(p, x); }
BL_INLINE void blMemWriteI64uBE(void* p, int64_t x) noexcept { blMemWriteI64<BL_BYTE_ORDER_BE, 1>(p, x); }
BL_INLINE void blMemWriteU64aBE(void* p, uint64_t x) noexcept { blMemWriteU64<BL_BYTE_ORDER_BE, 8>(p, x); }
BL_INLINE void blMemWriteU64uBE(void* p, uint64_t x) noexcept { blMemWriteU64<BL_BYTE_ORDER_BE, 1>(p, x); }
} // {anonymous}
// ============================================================================
// [blMemCopyInline]
// ============================================================================
namespace {
template<typename T>
static BL_INLINE void blMemCopyInlineT(T* dst, const T* src, size_t count) noexcept {
for (size_t i = 0; i < count; i++)
dst[i] = src[i];
}
//! Copies `n` bytes from `src` to `dst` optimized for small buffers.
static BL_INLINE void blMemCopyInline(void* dst, const void* src, size_t n) noexcept {
#if defined(__GNUC__) && BL_TARGET_ARCH_X86
size_t unused;
__asm__ __volatile__(
"rep movsb" : "=&D"(dst), "=&S"(src), "=&c"(unused)
: "0"(dst), "1"(src), "2"(n)
: "memory"
);
#elif defined(_MSC_VER) && BL_TARGET_ARCH_X86
__movsb(static_cast<unsigned char *>(dst), static_cast<const unsigned char *>(src), n);
#else
blMemCopyInlineT<uint8_t>(static_cast<uint8_t*>(dst), static_cast<const uint8_t*>(src), n);
#endif
}
} // {anonymous}
// ============================================================================
// [blMemSetInline]
// ============================================================================
namespace {
template<typename T>
static BL_INLINE void blMemSetInlineT(T* dst, const T& pattern, size_t count) noexcept {
for (size_t i = 0; i < count; i++)
dst[i] = pattern;
}
} // {anonymous}
// ============================================================================
// [BLWrap<T>]
// ============================================================================
//! Wrapper to control construction & destruction of `T`.
template<typename T>
struct alignas(alignof(T)) BLWrap {
//! Storage required to instantiate `T`.
char _data[sizeof(T)];
//! \name Init / Destroy
//! \{
//! Placement new constructor.
BL_INLINE T* init() noexcept {
#if defined(_MSC_VER) && !defined(__clang__)
BL_ASSUME(_data != nullptr);
#endif
return new(static_cast<void*>(_data)) T;
}
//! Placement new constructor with arguments.
template<typename... Args>
BL_INLINE T* init(Args&&... args) noexcept {
#if defined(_MSC_VER) && !defined(__clang__)
BL_ASSUME(_data != nullptr);
#endif
return new(static_cast<void*>(_data)) T(std::forward<Args>(args)...);
}
//! Placement delete destructor.
BL_INLINE void destroy() noexcept {
#if defined(_MSC_VER) && !defined(__clang__)
BL_ASSUME(_data != nullptr);
#endif
static_cast<T*>(static_cast<void*>(_data))->~T();
}
//! \}
//! \name Accessors
//! \{
BL_INLINE T* p() noexcept { return static_cast<T*>(static_cast<void*>(_data)); }
BL_INLINE const T* p() const noexcept { return static_cast<const T*>(static_cast<const void*>(_data)); }
BL_INLINE operator T&() noexcept { return *p(); }
BL_INLINE operator const T&() const noexcept { return *p(); }
BL_INLINE T& operator()() noexcept { return *p(); }
BL_INLINE const T& operator()() const noexcept { return *p(); }
BL_INLINE T* operator&() noexcept { return p(); }
BL_INLINE const T* operator&() const noexcept { return p(); }
BL_INLINE T* operator->() noexcept { return p(); }
BL_INLINE T const* operator->() const noexcept { return p(); }
//! \}
};
// ============================================================================
// [BLMemBuffer]
// ============================================================================
//! Memory buffer.
//!
//! Memory buffer is a helper class which holds pointer to an allocated memory
//! block, which will be released automatically by `BLMemBuffer` destructor or by
//! `reset()` call.
class BLMemBuffer {
public:
BL_NONCOPYABLE(BLMemBuffer)
void* _mem;
void* _buf;
size_t _capacity;
BL_INLINE BLMemBuffer() noexcept
: _mem(nullptr),
_buf(nullptr),
_capacity(0) {}
BL_INLINE ~BLMemBuffer() noexcept {
_reset();
}
protected:
BL_INLINE BLMemBuffer(void* mem, void* buf, size_t capacity) noexcept
: _mem(mem),
_buf(buf),
_capacity(capacity) {}
public:
BL_NODISCARD
BL_INLINE void* get() const noexcept { return _mem; }
BL_NODISCARD
BL_INLINE size_t capacity() const noexcept { return _capacity; }
BL_INLINE void* alloc(size_t size) noexcept {
if (size <= _capacity)
return _mem;
if (_mem != _buf)
free(_mem);
_mem = malloc(size);
_capacity = size;
return _mem;
}
BL_INLINE void _reset() noexcept {
if (_mem != _buf)
free(_mem);
}
BL_INLINE void reset() noexcept {
_reset();
_mem = nullptr;
_capacity = 0;
}
};
// ============================================================================
// [BLMemBufferTmp<>]
// ============================================================================
//! Memory buffer (temporary).
//!
//! This template is for fast routines that need to use memory allocated on
//! the stack, but the memory requirement is not known at compile time. The
//! number of bytes allocated on the stack is described by `N` parameter.
template<size_t N>
class BLMemBufferTmp : public BLMemBuffer {
public:
BL_NONCOPYABLE(BLMemBufferTmp<N>)
uint8_t _storage[N];
BL_INLINE BLMemBufferTmp() noexcept
: BLMemBuffer(_storage, _storage, N) {}
BL_INLINE ~BLMemBufferTmp() noexcept {}
using BLMemBuffer::alloc;
BL_INLINE void reset() noexcept {
_reset();
_mem = _buf;
_capacity = N;
}
};
//! \}
//! \endcond
#endif // BLEND2D_SUPPORT_P_H_INCLUDED
| 44.299838 | 173 | 0.678209 | [
"vector"
] |
7f4554b04e82e712d1a2296d82e5fa0e712718b7 | 21,963 | h | C | src/lib/dhcpsrv/tests/alloc_engine_utils.h | Acidburn0zzz/kea | 3036e88d4ff730919cd7d2fb50a961a5d33bf390 | [
"Apache-2.0"
] | 1 | 2017-08-24T19:55:21.000Z | 2017-08-24T19:55:21.000Z | src/lib/dhcpsrv/tests/alloc_engine_utils.h | Acidburn0zzz/kea | 3036e88d4ff730919cd7d2fb50a961a5d33bf390 | [
"Apache-2.0"
] | null | null | null | src/lib/dhcpsrv/tests/alloc_engine_utils.h | Acidburn0zzz/kea | 3036e88d4ff730919cd7d2fb50a961a5d33bf390 | [
"Apache-2.0"
] | null | null | null | // Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef LIBDHCPSRV_ALLOC_ENGINE_UTILS_H
#define LIBDHCPSRV_ALLOC_ENGINE_UTILS_H
#include <dhcpsrv/lease_mgr.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/alloc_engine.h>
#include <dhcpsrv/cfgmgr.h>
#include <asiolink/io_address.h>
#include <gtest/gtest.h>
#include <vector>
namespace isc {
namespace dhcp {
namespace test {
/// @file alloc_engine_utils.h
///
/// @brief This is a header file for all Allocation Engine tests.
///
/// There used to be one, huge (over 3kloc) alloc_engine_unittest.cc. It is now
/// split into serveral smaller files:
/// alloc_engine_utils.h - contains test class definitions (this file)
/// alloc_engine_utils.cc - contains test class implementation
/// alloc_engine4_unittest.cc - all unit-tests dedicated to IPv4
/// alloc_engine6_unittest.cc - all unit-tests dedicated to IPv6
/// alloc_engine_hooks_unittest.cc - all unit-tests dedicated to hooks
/// @brief Test that statistic manager holds a given value.
///
/// This function may be used in many allocation tests and there's no
/// single base class for it. @todo consider moving it src/lib/util.
///
/// @param stat_name Statistic name.
/// @param exp_value Expected value.
/// @param subnet_id subnet_id of the desired subnet, if not zero
///
/// @return true if the statistic manager holds a particular value,
/// false otherwise.
bool testStatistics(const std::string& stat_name, const int64_t exp_value,
const SubnetID subnet_id = 0);
/// @brief Allocation engine with some internal methods exposed
class NakedAllocEngine : public AllocEngine {
public:
/// @brief the sole constructor
/// @param engine_type specifies engine type (e.g. iterative)
/// @param attempts number of lease selection attempts before giving up
/// @param ipv6 specifies if the engine is IPv6 or IPv4
NakedAllocEngine(AllocEngine::AllocType engine_type,
unsigned int attempts, bool ipv6 = true)
:AllocEngine(engine_type, attempts, ipv6) {
}
// Expose internal classes for testing purposes
using AllocEngine::Allocator;
using AllocEngine::IterativeAllocator;
using AllocEngine::getAllocator;
/// @brief IterativeAllocator with internal methods exposed
class NakedIterativeAllocator: public AllocEngine::IterativeAllocator {
public:
/// @brief constructor
/// @param type pool types that will be iterated through
NakedIterativeAllocator(Lease::Type type)
:IterativeAllocator(type) {
}
using AllocEngine::IterativeAllocator::increasePrefix;
};
};
/// @brief Used in Allocation Engine tests for IPv6
class AllocEngine6Test : public ::testing::Test {
public:
/// @brief Specified expected result of a given operation
enum ExpectedResult {
SHOULD_PASS,
SHOULD_FAIL
};
/// @brief Default constructor
///
/// Sets duid_, iaid_, subnet_, pool_ fields to example values used
/// in many tests, initializes cfg_mgr configuration and creates
/// lease database.
AllocEngine6Test();
/// @brief Configures a subnet and adds one pool to it.
///
/// This function removes existing v6 subnets before configuring
/// a new one.
///
/// @param subnet Address of a subnet to be configured.
/// @param pool_start First address in the address pool.
/// @param pool_end Last address in the address pool.
/// @param pd_pool_prefix Prefix for the prefix delegation pool. It
/// defaults to 0 which means that PD pool is not specified.
/// @param pd_pool_length Length of the PD pool prefix.
/// @param pd_delegated_length Delegated prefix length.
void initSubnet(const asiolink::IOAddress& subnet,
const asiolink::IOAddress& pool_start,
const asiolink::IOAddress& pool_end,
const asiolink::IOAddress& pd_pool_prefix =
asiolink::IOAddress::IPV6_ZERO_ADDRESS(),
const uint8_t pd_pool_length = 0,
const uint8_t pd_delegated_length = 0);
/// @brief Initializes FQDN data for a test.
///
/// The initialized values are used by the test fixture class members to
/// verify the correctness of a lease.
///
/// @param hostname Hostname to be assigned to a lease.
/// @param fqdn_fwd Indicates whether or not to perform forward DNS update
/// for a lease.
/// @param fqdn_fwd Indicates whether or not to perform reverse DNS update
/// for a lease.
void initFqdn(const std::string& hostname, const bool fqdn_fwd,
const bool fqdn_rev) {
hostname_ = hostname;
fqdn_fwd_ = fqdn_fwd;
fqdn_rev_ = fqdn_rev;
}
/// @brief Wrapper around call to AllocEngine6::findReservation
///
/// If a reservation is found by the engine, the function sets
/// ctx.hostname_ accordingly.
///
/// @param engine allocation engine to use
/// @param ctx client context to pass into engine's findReservation method
void findReservation(AllocEngine& engine, AllocEngine::ClientContext6& ctx);
/// @brief attempts to convert leases collection to a single lease
///
/// This operation makes sense if there is at most one lease in the
/// collection. Otherwise it will throw.
///
/// @param col collection of leases (zero or one leases allowed)
/// @throw MultipleRecords if there is more than one lease
/// @return Lease6 pointer (or NULL if collection was empty)
Lease6Ptr expectOneLease(const Lease6Collection& col) {
if (col.size() > 1) {
isc_throw(MultipleRecords, "More than one lease found in collection");
}
if (col.empty()) {
return (Lease6Ptr());
}
return (*col.begin());
}
/// @brief checks if Lease6 matches expected configuration
///
/// @param lease lease to be checked
/// @param exp_type expected lease type
/// @param exp_pd_len expected prefix length
/// @param expected_in_subnet whether the lease is expected to be in subnet
/// @param expected_in_pool whether the lease is expected to be in dynamic
void checkLease6(const Lease6Ptr& lease, Lease::Type exp_type,
uint8_t exp_pd_len = 128, bool expected_in_subnet = true,
bool expected_in_pool = true) {
// that is belongs to the right subnet
EXPECT_EQ(lease->subnet_id_, subnet_->getID());
if (expected_in_subnet) {
EXPECT_TRUE(subnet_->inRange(lease->addr_));
} else {
EXPECT_FALSE(subnet_->inRange(lease->addr_));
}
if (expected_in_pool) {
EXPECT_TRUE(subnet_->inPool(exp_type, lease->addr_));
} else {
EXPECT_FALSE(subnet_->inPool(exp_type, lease->addr_));
}
// that it have proper parameters
EXPECT_EQ(exp_type, lease->type_);
EXPECT_EQ(iaid_, lease->iaid_);
EXPECT_EQ(subnet_->getValid(), lease->valid_lft_);
EXPECT_EQ(subnet_->getPreferred(), lease->preferred_lft_);
EXPECT_EQ(subnet_->getT1(), lease->t1_);
EXPECT_EQ(subnet_->getT2(), lease->t2_);
EXPECT_EQ(exp_pd_len, lease->prefixlen_);
EXPECT_EQ(fqdn_fwd_, lease->fqdn_fwd_);
EXPECT_EQ(fqdn_rev_, lease->fqdn_rev_);
EXPECT_EQ(hostname_, lease->hostname_);
EXPECT_TRUE(*lease->duid_ == *duid_);
/// @todo: check cltt
}
/// @brief Checks if specified address or prefix has been recorded as
/// allocated to the client.
///
/// @param lease Allocated lease.
/// @param ctx Context structure in which this function should check if
/// leased address is stored as allocated resource.
void checkAllocatedResources(const Lease6Ptr& lease,
AllocEngine::ClientContext6& ctx) {
EXPECT_TRUE(ctx.isAllocated(lease->addr_, lease->prefixlen_));
}
/// @brief Checks if specified address is increased properly
///
/// Method uses gtest macros to mark check failure. This is a proxy
/// method, since increaseAddress was moved to IOAddress class.
///
/// @param alloc IterativeAllocator that is tested
/// @param input address to be increased
/// @param exp_output expected address after increase
void
checkAddrIncrease(NakedAllocEngine::NakedIterativeAllocator&,
std::string input, std::string exp_output) {
EXPECT_EQ(exp_output, asiolink::IOAddress::increase(
asiolink::IOAddress(input)).toText());
}
/// @brief Checks if increasePrefix() works as expected
///
/// Method uses gtest macros to mark check failure.
///
/// @param alloc allocator to be tested
/// @param input IPv6 prefix (as a string)
/// @param prefix_len prefix len
/// @param exp_output expected output (string)
void
checkPrefixIncrease(NakedAllocEngine::NakedIterativeAllocator& alloc,
std::string input, uint8_t prefix_len,
std::string exp_output) {
EXPECT_EQ(exp_output, alloc.increasePrefix(asiolink::IOAddress(input),
prefix_len).toText());
}
/// @brief Checks if the simple allocation can succeed
///
/// The type of lease is determined by pool type (pool->getType()
///
/// @param pool pool from which the lease will be allocated from
/// @param hint address to be used as a hint
/// @param fake true - this is fake allocation (SOLICIT)
/// @param in_pool specifies whether the lease is expected to be in pool
/// @return allocated lease (or NULL)
Lease6Ptr simpleAlloc6Test(const Pool6Ptr& pool,
const asiolink::IOAddress& hint,
bool fake, bool in_pool = true);
/// @brief Checks if the allocation can succeed.
///
/// The type of lease is determined by pool type (pool->getType()).
/// This test is particularly useful in connection with @ref renewTest.
///
/// @param engine a reference to Allocation Engine
/// @param pool pool from which the lease will be allocated from
/// @param hint address to be used as a hint
/// @param fake true - this is fake allocation (SOLICIT)
/// @param in_pool specifies whether the lease is expected to be in pool
/// @return allocated lease(s) (may be empty)
Lease6Collection allocateTest(AllocEngine& engine, const Pool6Ptr& pool,
const asiolink::IOAddress& hint, bool fake,
bool in_pool = true);
/// @brief Checks if the allocation can be renewed.
///
/// The type of lease is determined by pool type (pool->getType()).
/// This test is particularly useful as a follow up to @ref allocateTest.
///
/// @param engine a reference to Allocation Engine
/// @param pool pool from which the lease will be allocated from
/// @param hints address to be used as a hint
/// @param in_pool specifies whether the lease is expected to be in pool
/// @return allocated lease(s) (may be empty)
Lease6Collection renewTest(AllocEngine& engine, const Pool6Ptr& pool,
AllocEngine::HintContainer& hints,
bool in_pool = true);
/// @brief Checks if the address allocation with a hint that is in range,
/// in pool, but is currently used, can succeed
///
/// Method uses gtest macros to mark check failure.
///
/// @param type lease type
/// @param used_addr address should be preallocated (simulates prior
/// allocation by some other user)
/// @param requested address requested by the client
/// @param expected_pd_len expected PD len (128 for addresses)
void allocWithUsedHintTest(Lease::Type type, asiolink::IOAddress used_addr,
asiolink::IOAddress requested,
uint8_t expected_pd_len);
/// @brief Generic test used for IPv6 lease allocation and reuse
///
/// This test inserts existing_lease (if specified, may be null) into the
/// LeaseMgr, then conducts lease allocation (pretends that client
/// sent either Solicit or Request, depending on fake_allocation).
/// Allocated lease is then returned (using result) for further inspection.
///
/// @param alloc_engine allocation engine
/// @param existing_lease optional lease to be inserted in the database
/// @param addr address to be requested by client
/// @param fake_allocation true = SOLICIT, false = REQUEST
/// @param exp_result expected result
/// @param result [out] allocated lease
void testReuseLease6(const AllocEnginePtr& alloc_engine,
Lease6Ptr& existing_lease,
const std::string& addr,
const bool fake_allocation,
ExpectedResult exp_result,
Lease6Ptr& result);
/// @brief Creates a declined IPv6 lease with specified expiration time
///
/// expired parameter controls probation period. Positive value
/// means that the lease will expire in X seconds. Negative means
/// that the lease expired X seconds ago. 0 means it expires now.
/// Probation period is a parameter that specifies for how long
/// a lease will stay unavailable after decline.
///
/// @param addr address of the lease
/// @param probation_period expressed in seconds
/// @param expired number of seconds when the lease will expire
Lease6Ptr generateDeclinedLease(const std::string& addr,
time_t probation_period,
int32_t expired);
/// @brief checks if bogus hint can be ignored and the allocation succeeds
///
/// This test checks if the allocation with a hing that is out of the blue
/// can succeed. The invalid hint should be ignored completely.
///
/// @param type Lease type
/// @param hint hint (as send by a client)
/// @param expected_pd_len (used in validation)
void allocBogusHint6(Lease::Type type, asiolink::IOAddress hint,
uint8_t expected_pd_len);
/// @brief Utility function that creates a host reservation (duid)
///
/// @param add_to_host_mgr true if the reservation should be added
/// @param type specifies reservation type
/// @param addr specifies reserved address or prefix
/// @param prefix_len prefix length (should be 128 for addresses)
/// @return created Host object.
HostPtr
createHost6(bool add_to_host_mgr, IPv6Resrv::Type type,
const asiolink::IOAddress& addr, uint8_t prefix_len) {
HostPtr host(new Host(&duid_->getDuid()[0], duid_->getDuid().size(),
Host::IDENT_DUID, SubnetID(0), subnet_->getID(),
asiolink::IOAddress("0.0.0.0")));
IPv6Resrv resv(type, addr, prefix_len);
host->addReservation(resv);
if (add_to_host_mgr) {
addHost(host);
}
return (host);
}
/// @brief Add a host reservation to the current configuration
///
/// Adds the given host reservation to the current configuration by
/// casting it to non-const. We do it this way rather than adding it to
/// staging and then committing as that wipes out the current configuration
/// such as subnets.
///
/// @param host host reservation to add
void
addHost(HostPtr& host) {
SrvConfigPtr cfg = boost::const_pointer_cast<SrvConfig>(CfgMgr::instance().getCurrentCfg());
cfg->getCfgHosts()->add(host);
}
/// @brief Utility function that creates a host reservation (hwaddr)
///
/// @param add_to_host_mgr true if the reservation should be added
/// @param type specifies reservation type
/// @param hwaddr hardware address to be reserved to
/// @param addr specifies reserved address or prefix
/// @param prefix_len prefix length (should be 128 for addresses)
/// @return created Host object.
HostPtr
createHost6HWAddr(bool add_to_host_mgr, IPv6Resrv::Type type,
HWAddrPtr& hwaddr, const asiolink::IOAddress& addr,
uint8_t prefix_len);
virtual ~AllocEngine6Test() {
factory_.destroy();
}
DuidPtr duid_; ///< client-identifier (value used in tests)
HWAddrPtr hwaddr_; ///< client's hardware address
uint32_t iaid_; ///< IA identifier (value used in tests)
Subnet6Ptr subnet_; ///< subnet6 (used in tests)
Pool6Ptr pool_; ///< NA pool belonging to subnet_
Pool6Ptr pd_pool_; ///< PD pool belonging to subnet_
std::string hostname_; ///< Hostname
bool fqdn_fwd_; ///< Perform forward update for a lease.
bool fqdn_rev_; ///< Perform reverse update for a lease.
LeaseMgrFactory factory_; ///< pointer to LeaseMgr factory
};
/// @brief Used in Allocation Engine tests for IPv4
class AllocEngine4Test : public ::testing::Test {
public:
/// @brief Specified expected result of a given operation
enum ExpectedResult {
SHOULD_PASS,
SHOULD_FAIL
};
/// @brief Default constructor
///
/// Sets clientid_, hwaddr_, subnet_, pool_ fields to example values
/// used in many tests, initializes cfg_mgr configuration and creates
/// lease database.
///
/// It also re-initializes the Host Manager.
AllocEngine4Test();
/// @brief checks if Lease4 matches expected configuration
///
/// @param lease lease to be checked
void checkLease4(const Lease4Ptr& lease) {
// Check that is belongs to the right subnet
EXPECT_EQ(lease->subnet_id_, subnet_->getID());
EXPECT_TRUE(subnet_->inRange(lease->addr_));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_V4, lease->addr_));
// Check that it has proper parameters
EXPECT_EQ(subnet_->getValid(), lease->valid_lft_);
EXPECT_EQ(subnet_->getT1(), lease->t1_);
EXPECT_EQ(subnet_->getT2(), lease->t2_);
if (lease->client_id_ && !clientid_) {
ADD_FAILURE() << "Lease4 has a client-id, while it should have none.";
} else
if (!lease->client_id_ && clientid_) {
ADD_FAILURE() << "Lease4 has no client-id, but it was expected to have one.";
} else
if (lease->client_id_ && clientid_) {
EXPECT_TRUE(*lease->client_id_ == *clientid_);
}
EXPECT_TRUE(*lease->hwaddr_ == *hwaddr_);
/// @todo: check cltt
}
/// @brief Generic test used for IPv4 lease allocation and reuse
///
/// This test inserts existing_lease (if specified, may be null) into the
/// LeaseMgr, then conducts lease allocation (pretends that client
/// sent either Discover or Request, depending on fake_allocation).
/// Allocated lease is then returned (using result) for further inspection.
///
/// @param alloc_engine allocation engine
/// @param existing_lease optional lease to be inserted in the database
/// @param addr address to be requested by client
/// @param fake_allocation true = DISCOVER, false = REQUEST
/// @param exp_result expected result
/// @param result [out] allocated lease
void testReuseLease4(const AllocEnginePtr& alloc_engine,
Lease4Ptr& existing_lease,
const std::string& addr,
const bool fake_allocation,
ExpectedResult exp_result,
Lease4Ptr& result);
/// @brief Creates a declined IPv4 lease with specified expiration time
///
/// expired parameter controls probation period. Positive value
/// means that the lease will expire in X seconds. Negative means
/// that the lease expired X seconds ago. 0 means it expires now.
/// Probation period is a parameter that specifies for how long
/// a lease will stay unavailable after decline.
///
/// @param addr address of the lease
/// @param probation_period expressed in seconds
/// @param expired number of seconds when the lease will expire
Lease4Ptr generateDeclinedLease(const std::string& addr,
time_t probation_period,
int32_t expired);
/// @brief Create a subnet with a specified pool of addresses.
///
/// @param pool_start First address in the pool.
/// @param pool_end Last address in the pool.
void initSubnet(const asiolink::IOAddress& pool_start,
const asiolink::IOAddress& pool_end);
virtual ~AllocEngine4Test() {
factory_.destroy();
}
ClientIdPtr clientid_; ///< Client-identifier (value used in tests)
ClientIdPtr clientid2_; ///< Alternative client-identifier.
HWAddrPtr hwaddr_; ///< Hardware address (value used in tests)
HWAddrPtr hwaddr2_; ///< Alternative hardware address.
Subnet4Ptr subnet_; ///< Subnet4 (used in tests)
Pool4Ptr pool_; ///< Pool belonging to subnet_
LeaseMgrFactory factory_; ///< Pointer to LeaseMgr factory
AllocEngine::ClientContext4 ctx_; ///< Context information passed to various
///< allocation engine functions.
};
}; // namespace test
}; // namespace dhcp
}; // namespace isc
#endif
| 42.236538 | 141 | 0.643446 | [
"object",
"vector"
] |
7f4ebc3e788bedbb2721a928a65fc1c5337e310b | 5,781 | h | C | Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionWindowPlugin.h | cypherdotXd/o3de | bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676 | [
"Apache-2.0",
"MIT"
] | 8 | 2021-08-31T02:14:19.000Z | 2021-12-28T19:20:59.000Z | Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionWindowPlugin.h | cypherdotXd/o3de | bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676 | [
"Apache-2.0",
"MIT"
] | 8 | 2021-07-12T13:55:00.000Z | 2021-10-04T14:53:21.000Z | Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionWindowPlugin.h | cypherdotXd/o3de | bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-09-16T05:06:18.000Z | 2021-09-16T05:06:18.000Z | /*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include "../StandardPluginsConfig.h"
#include <AzCore/std/containers/vector.h>
#include <MysticQt/Source/DialogStack.h>
#include "../../../../EMStudioSDK/Source/DockWidgetPlugin.h"
#include <EMotionFX/CommandSystem/Source/ImporterCommands.h>
#include <EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/Commands.h>
#include <EMotionFX/Source/MotionInstance.h>
#include <EMotionFX/Source/EventHandler.h>
#endif
QT_FORWARD_DECLARE_CLASS(QLabel)
namespace EMStudio
{
// forward declaration
class MotionListWindow;
class MotionPropertiesWindow;
class MotionExtractionWindow;
class MotionRetargetingWindow;
class SaveDirtyMotionFilesCallback;
class MotionWindowPlugin
: public EMStudio::DockWidgetPlugin
{
Q_OBJECT
MCORE_MEMORYOBJECTCATEGORY(MotionWindowPlugin, MCore::MCORE_DEFAULT_ALIGNMENT, MEMCATEGORY_STANDARDPLUGINS);
public:
enum
{
CLASS_ID = 0x00000005
};
MotionWindowPlugin();
~MotionWindowPlugin();
// overloaded
const char* GetCompileDate() const override { return MCORE_DATE; }
const char* GetName() const override { return "Motions"; }
uint32 GetClassID() const override { return MotionWindowPlugin::CLASS_ID; }
const char* GetCreatorName() const override { return "O3DE"; }
float GetVersion() const override { return 1.0f; }
bool GetIsClosable() const override { return true; }
bool GetIsFloatable() const override { return true; }
bool GetIsVertical() const override { return false; }
// overloaded main init function
bool Init() override;
EMStudioPlugin* Clone() override;
void Render(RenderPlugin* renderPlugin, EMStudioPlugin::RenderInfo* renderInfo) override;
void ReInit();
struct MotionTableEntry
{
MCORE_MEMORYOBJECTCATEGORY(MotionTableEntry, MCore::MCORE_DEFAULT_ALIGNMENT, MEMCATEGORY_STANDARDPLUGINS);
MotionTableEntry(EMotionFX::Motion* motion);
EMotionFX::Motion* m_motion;
uint32 m_motionId;
};
MotionTableEntry* FindMotionEntryByID(uint32 motionID);
MCORE_INLINE size_t GetNumMotionEntries() { return m_motionEntries.size(); }
MCORE_INLINE MotionTableEntry* GetMotionEntry(size_t index) { return m_motionEntries[index]; }
bool AddMotion(uint32 motionID);
bool RemoveMotionByIndex(size_t index);
bool RemoveMotionById(uint32 motionID);
static AZStd::vector<EMotionFX::MotionInstance*>& GetSelectedMotionInstances();
MCORE_INLINE MotionRetargetingWindow* GetMotionRetargetingWindow() { return m_motionRetargetingWindow; }
MCORE_INLINE MotionExtractionWindow* GetMotionExtractionWindow() { return m_motionExtractionWindow; }
MCORE_INLINE MotionListWindow* GetMotionListWindow() { return m_motionListWindow; }
MCORE_INLINE const char* GetDefaultNodeSelectionLabelText() { return "Click to select node"; }
int OnSaveDirtyMotions();
int SaveDirtyMotion(EMotionFX::Motion* motion, MCore::CommandGroup* commandGroup, bool askBeforeSaving, bool showCancelButton = true);
void PlayMotions(const AZStd::vector<EMotionFX::Motion*>& motions);
void PlayMotion(EMotionFX::Motion* motion);
void StopSelectedMotions();
public slots:
void UpdateInterface();
void UpdateMotions();
void VisibilityChanged(bool visible);
void OnAddMotions();
void OnClearMotions();
void OnRemoveMotions();
void OnSave();
private:
void ClearMotionEntries();
// declare the callbacks
MCORE_DEFINECOMMANDCALLBACK(CommandImportMotionCallback);
MCORE_DEFINECOMMANDCALLBACK(CommandLoadMotionSetCallback);
MCORE_DEFINECOMMANDCALLBACK(CommandRemoveMotionPostCallback);
MCORE_DEFINECOMMANDCALLBACK(CommandSaveMotionAssetInfoCallback);
MCORE_DEFINECOMMANDCALLBACK(CommandAdjustDefaultPlayBackInfoCallback);
MCORE_DEFINECOMMANDCALLBACK(CommandAdjustMotionCallback);
MCORE_DEFINECOMMANDCALLBACK(CommandScaleMotionDataCallback);
MCORE_DEFINECOMMANDCALLBACK(CommandSelectCallback);
AZStd::vector<MCore::Command::Callback*> m_callbacks;
AZStd::vector<MotionTableEntry*> m_motionEntries;
MysticQt::DialogStack* m_dialogStack;
MotionListWindow* m_motionListWindow;
MotionPropertiesWindow* m_motionPropertiesWindow;
MotionExtractionWindow* m_motionExtractionWindow;
MotionRetargetingWindow* m_motionRetargetingWindow;
SaveDirtyMotionFilesCallback* m_dirtyFilesCallback;
QAction* m_addMotionsAction;
QAction* m_saveAction;
QLabel* m_motionNameLabel;
static AZStd::vector<EMotionFX::MotionInstance*> s_internalMotionInstanceSelection;
};
} // namespace EMStudio
| 40.711268 | 142 | 0.643487 | [
"render",
"vector",
"3d"
] |
7f50c291334edbee1f1eecdf494baec5f936c610 | 6,953 | h | C | Code/Base/accessors/current/tests/imageaccess/FitsImageAccessTest.h | rtobar/askapsoft | 6bae06071d7d24f41abe3f2b7f9ee06cb0a9445e | [
"BSL-1.0",
"Apache-2.0",
"OpenSSL"
] | null | null | null | Code/Base/accessors/current/tests/imageaccess/FitsImageAccessTest.h | rtobar/askapsoft | 6bae06071d7d24f41abe3f2b7f9ee06cb0a9445e | [
"BSL-1.0",
"Apache-2.0",
"OpenSSL"
] | null | null | null | Code/Base/accessors/current/tests/imageaccess/FitsImageAccessTest.h | rtobar/askapsoft | 6bae06071d7d24f41abe3f2b7f9ee06cb0a9445e | [
"BSL-1.0",
"Apache-2.0",
"OpenSSL"
] | null | null | null | /// @file
///
/// Unit test for the CASA image access code
///
///
/// @copyright (c) 2007 CSIRO
/// Australia Telescope National Facility (ATNF)
/// Commonwealth Scientific and Industrial Research Organisation (CSIRO)
/// PO Box 76, Epping NSW 1710, Australia
/// atnf-enquiries@csiro.au
///
/// This file is part of the ASKAP software distribution.
///
/// The ASKAP software distribution is free software: you can redistribute it
/// and/or modify it under the terms of the GNU General Public License as
/// published by the Free Software Foundation; either version 2 of the License,
/// or (at your option) any later version.
///
/// This program is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with this program; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///
/// @author Max Voronkov <maxim.voronkov@csiro.au>
#include <imageaccess/ImageAccessFactory.h>
#include <cppunit/extensions/HelperMacros.h>
#include <casacore/casa/Arrays/Vector.h>
#include <casacore/casa/Arrays/IPosition.h>
#include <casacore/casa/Arrays/Matrix.h>
#include <casacore/casa/Arrays/ArrayIO.h>
#include <casacore/coordinates/Coordinates/LinearCoordinate.h>
#include <casacore/coordinates/Coordinates/DirectionCoordinate.h>
#include <casacore/coordinates/Coordinates/SpectralCoordinate.h>
#include <casacore/coordinates/Coordinates/Projection.h>
#include <casacore/coordinates/Coordinates/CoordinateSystem.h>
#include <boost/shared_ptr.hpp>
#include <Common/ParameterSet.h>
#include <askap_accessors.h>
#include <askap/AskapLogging.h>
namespace askap {
namespace accessors {
class FitsImageAccessTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(FitsImageAccessTest);
CPPUNIT_TEST(testReadWrite);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
LOFAR::ParameterSet parset;
parset.add("imagetype","fits");
itsImageAccessor = imageAccessFactory(parset);
}
void testReadWrite() {
// Create FITS image
const std::string name = "tmpfitsimage";
CPPUNIT_ASSERT(itsImageAccessor);
size_t ra=100, dec=100, spec=5;
const casa::IPosition shape(3,ra,dec,spec);
casa::Array<float> arr(shape);
arr.set(1.);
// Build a coordinate system for the image
casa::Matrix<double> xform(2,2); // 1
xform = 0.0; xform.diagonal() = 1.0; // 2
casa::DirectionCoordinate radec(casa::MDirection::J2000, // 3
casa::Projection(casa::Projection::SIN), // 4
135*casa::C::pi/180.0, 60*casa::C::pi/180.0, // 5
-1*casa::C::pi/180.0, 1*casa::C::pi/180, // 6
xform, // 7
ra/2., dec/2.); // 8
casa::Vector<casa::String> units(2); units = "deg"; // 9
radec.setWorldAxisUnits(units);
// Build a coordinate system for the spectral axis
// SpectralCoordinate
casa::SpectralCoordinate spectral(casa::MFrequency::TOPO, // 27
1400 * 1.0E+6, // 28
20 * 1.0E+3, // 29
0, // 30
1420.40575 * 1.0E+6); // 31
units.resize(1);
units = "MHz";
spectral.setWorldAxisUnits(units);
casa::CoordinateSystem coordsys;
coordsys.addCoordinate(radec);
coordsys.addCoordinate(spectral);
itsImageAccessor->create(name, shape, coordsys);
itsImageAccessor->write(name,arr);
// // check shape
CPPUNIT_ASSERT(itsImageAccessor->shape(name) == shape);
// // // read the whole array and check
casa::Array<float> readBack = itsImageAccessor->read(name);
CPPUNIT_ASSERT(readBack.shape() == shape);
for (int x=0; x<shape[0]; ++x) {
for (int y=0; y<shape[1]; ++y) {
for (int z = 0; z < shape[2]; ++z) {
std::cout << x << ":" << y << ":" << z << std::endl;
const casa::IPosition index(3,x,y,z);
CPPUNIT_ASSERT(fabs(readBack(index)-arr(index))<1e-7);
}
}
}
// write a slice
const casa::IPosition chanShape(2,ra,dec);
casa::Array<float> chanArr(chanShape);
chanArr.set(2.0);
itsImageAccessor->write(name,chanArr,casa::IPosition(3,0,0,2));
// // read a slice
// vec = itsImageAccessor->read(name,casa::IPosition(2,0,1),casa::IPosition(2,9,1));
// CPPUNIT_ASSERT(vec.nelements() == 10);
// for (int x=0; x<10; ++x) {
// CPPUNIT_ASSERT(fabs(vec[x] - arr(casa::IPosition(2,x,1)))<1e-7);
// }
// vec = itsImageAccessor->read(name,casa::IPosition(2,0,3),casa::IPosition(2,9,3));
// CPPUNIT_ASSERT(vec.nelements() == 10);
// for (int x=0; x<10; ++x) {
// CPPUNIT_ASSERT(fabs(vec[x] - arr(casa::IPosition(2,x,3)))>1e-7);
// CPPUNIT_ASSERT(fabs(vec[x] - 2.)<1e-7);
// }
// read the whole array and check
// casa::Array<float> readBack = itsImageAccessor->read(name);
// CPPUNIT_ASSERT(readBack.shape() == shape);
// for (int x=0; x<shape[0]; ++x) {
// for (int y=0; y<shape[1]; ++y) {
// const casa::IPosition index(2,x,y);
// CPPUNIT_ASSERT(fabs(readBack(index) - (y == 3 ? 2. : 1.))<1e-7);
// }
// }
// CPPUNIT_ASSERT(itsImageAccessor->coordSys(name).nCoordinates() == 1);
// CPPUNIT_ASSERT(itsImageAccessor->coordSys(name).type(0) == casa::CoordinateSystem::LINEAR);
//
// // auxilliary methods
itsImageAccessor->setUnits(name,"Jy/pixel");
itsImageAccessor->setBeamInfo(name,0.02,0.01,1.0);
casa::Vector<casa::Quantum<double> > beamInfo = itsImageAccessor->beamInfo(name);
}
protected:
casa::CoordinateSystem makeCoords() {
casa::Vector<casa::String> names(2);
names[0]="x"; names[1]="y";
casa::Vector<double> increment(2 ,1.);
casa::Matrix<double> xform(2,2,0.);
xform.diagonal() = 1.;
casa::LinearCoordinate linear(names, casa::Vector<casa::String>(2,"pixel"),
casa::Vector<double>(2,0.),increment, xform, casa::Vector<double>(2,0.));
casa::CoordinateSystem coords;
coords.addCoordinate(linear);
return coords;
}
private:
/// @brief method to access image
boost::shared_ptr<IImageAccess> itsImageAccessor;
};
} // namespace accessors
} // namespace askap
| 36.025907 | 100 | 0.594563 | [
"shape",
"vector"
] |
7f50f7201b6bb135873f6ca0bc8dd049ea281b95 | 1,716 | h | C | System/Library/Frameworks/SceneKit.framework/SCNManipulableItem.h | lechium/tvOS142Headers | c7696f6d760e4822f61b9f2c2adcd18749700fda | [
"MIT"
] | 1 | 2020-11-11T06:05:23.000Z | 2020-11-11T06:05:23.000Z | System/Library/Frameworks/SceneKit.framework/SCNManipulableItem.h | lechium/tvOS142Headers | c7696f6d760e4822f61b9f2c2adcd18749700fda | [
"MIT"
] | null | null | null | System/Library/Frameworks/SceneKit.framework/SCNManipulableItem.h | lechium/tvOS142Headers | c7696f6d760e4822f61b9f2c2adcd18749700fda | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.5
* on Tuesday, November 10, 2020 at 10:15:41 PM Mountain Standard Time
* Operating System: Version 14.2 (Build 18K57)
* Image Source: /System/Library/Frameworks/SceneKit.framework/SceneKit
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley.
*/
#import <SceneKit/SceneKit-Structs.h>
@class SCNNode;
@interface SCNManipulableItem : NSObject {
double _screenSize;
SCNNode* node;
id component;
unsigned long long elementIndex;
}
@property (nonatomic,retain) SCNNode * node;
@property (nonatomic,retain) id component;
@property (assign,nonatomic) unsigned long long elementIndex;
@property (assign,nonatomic) SCNMatrix4 transform;
@property (assign,nonatomic) SCNMatrix4 worldTransform;
@property (nonatomic,readonly) SCNVector3 elementPosition;
+(void)removeItemsFromScene:(id)arg1 ;
+(void)addItems:(id)arg1 toScene:(id)arg2 ;
-(BOOL)isEqual:(id)arg1 ;
-(unsigned long long)hash;
-(void)dealloc;
-(SCNMatrix4)transform;
-(SCNVector3)scale;
-(void)setPosition:(SCNVector3)arg1 ;
-(SCNNode *)node;
-(void)setTransform:(SCNMatrix4)arg1 ;
-(void)setComponent:(id)arg1 ;
-(id)component;
-(double)screenSize;
-(void)setScreenSize:(double)arg1 ;
-(id)parentItem;
-(void)setNode:(SCNNode *)arg1 ;
-(SCNVector3)elementPosition;
-(SCNMatrix4)worldTransform;
-(void)setWorldTransform:(SCNMatrix4)arg1 ;
-(void)validateClone;
-(id)cloneForManipulators;
-(unsigned long long)elementIndex;
-(BOOL)isNodeManipulator;
-(void)setElementIndex:(unsigned long long)arg1 ;
@end
| 31.777778 | 130 | 0.704545 | [
"transform"
] |
7f5284ef153709f4ef5cbf73f4280b97aeecfd7e | 24,437 | h | C | src/type.h | RamiHg/yarpgen | f43efd771ebb216208465e5db5658f28bf79f136 | [
"Apache-2.0"
] | 1 | 2019-03-28T21:38:11.000Z | 2019-03-28T21:38:11.000Z | src/type.h | UncleGoGA/yarpgen | 4a8e74ae1179015968ab6aabe8449b49baa41386 | [
"Apache-2.0"
] | null | null | null | src/type.h | UncleGoGA/yarpgen | 4a8e74ae1179015968ab6aabe8449b49baa41386 | [
"Apache-2.0"
] | null | null | null | /*
Copyright (c) 2015-2017, Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <iostream>
#include <climits>
#include <memory>
#include <vector>
#include "options.h"
namespace yarpgen {
class Context;
class Data;
class ScalarVariable;
class Struct;
// Abstract class, serves as a common ancestor for all types.
class Type {
public:
// ID for top-level Type kind
enum TypeID {
BUILTIN_TYPE,
STRUCT_TYPE,
ARRAY_TYPE,
POINTER_TYPE,
MAX_TYPE_ID
};
// CV-qualifiers.
enum CV_Qual {
NTHG,
VOLAT,
CONST,
CONST_VOLAT,
MAX_CV_QUAL
};
// ID for builtin types (in C terminology they "atomic", in C++ they are "fundamental" types)
enum BuiltinTypeID {
Integer, Max_BuiltinTypeID
};
enum IntegerTypeID {
BOOL,
// Note, char and signed char types are not distinguished,
// though they are distinguished in C++ standard and char may
// map to unsigned char in some implementations. By "CHAR" we assume "signed char"
CHAR,
UCHAR,
SHRT,
USHRT,
INT,
UINT,
LINT,
ULINT,
LLINT,
ULLINT,
MAX_INT_ID,
};
Type (TypeID _id) : cv_qual(CV_Qual::NTHG), is_static(false), align(0), id (_id) {}
Type (TypeID _id, CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
cv_qual (_cv_qual), is_static (_is_static), align (_align), id (_id) {}
// Getters and setters for general Type properties
Type::TypeID get_type_id () { return id; }
virtual BuiltinTypeID get_builtin_type_id() { return Max_BuiltinTypeID; }
virtual IntegerTypeID get_int_type_id () { return MAX_INT_ID; }
virtual bool get_is_signed() { return false; }
virtual bool get_is_bit_field() { return false; }
void set_cv_qual (CV_Qual _cv_qual) { cv_qual = _cv_qual; }
CV_Qual get_cv_qual () { return cv_qual; }
void set_is_static (bool _is_static) { is_static = _is_static; }
bool get_is_static () { return is_static; }
void set_align (uint32_t _align) { align = _align; }
uint32_t get_align () { return align; }
// We assume static storage duration, cv-qualifier and alignment as a part of Type's full name
std::string get_name ();
std::string get_simple_name () { return name; }
virtual std::string get_type_suffix() { return ""; }
// Utility functions, which allows quickly determine Type kind
virtual bool is_builtin_type() { return false; }
virtual bool is_int_type() { return false; }
virtual bool is_struct_type() { return false; }
virtual bool is_array_type() { return false; }
virtual bool is_ptr_type() { return false; }
// Pure virtual function, used for debug purposes
virtual void dbg_dump() = 0;
virtual ~Type () {}
protected:
std::string name;
CV_Qual cv_qual;
bool is_static;
uint32_t align;
private:
TypeID id;
};
// Class which represents structures
class StructType : public Type {
public:
// Class which represents member of a structure, including bit-fields
//TODO: add generator?
struct StructMember {
public:
StructMember (std::shared_ptr<Type> _type, std::string _name);
std::string get_name () { return name; }
std::shared_ptr<Type> get_type() { return type; }
std::shared_ptr<Data> get_data () { return data; }
std::string get_definition (std::string offset = "");
private:
std::shared_ptr<Type> type;
std::string name;
std::shared_ptr<Data> data; //TODO: it is a stub for static members
};
StructType (std::string _name) : Type (Type::STRUCT_TYPE), nest_depth(0) { name = _name; }
StructType (std::string _name, CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
Type (Type::STRUCT_TYPE, _cv_qual, _is_static, _align), nest_depth(0) { name = _name; }
bool is_struct_type() { return true; }
// Getters and setters for StructType properties
//TODO: it should handle nest_depth change
void add_member (std::shared_ptr<StructMember> new_mem) { members.push_back(new_mem); shadow_members.push_back(new_mem); }
void add_member (std::shared_ptr<Type> _type, std::string _name);
void add_shadow_member (std::shared_ptr<Type> _type) { shadow_members.push_back(std::make_shared<StructMember>(_type, "")); }
uint32_t get_member_count () { return members.size(); }
uint32_t get_shadow_member_count () { return shadow_members.size(); }
uint32_t get_nest_depth () { return nest_depth; }
std::shared_ptr<StructMember> get_member (unsigned int num);
std::string get_definition (std::string offset = "");
// It returns an out-of-line definition for all static members of the structure
std::string get_static_memb_def (std::string offset = "");
std::string get_static_memb_check (std::string offset = "");
void dbg_dump();
// Randomly generate StructType
static std::shared_ptr<StructType> generate (std::shared_ptr<Context> ctx);
static std::shared_ptr<StructType> generate (std::shared_ptr<Context> ctx, std::vector<std::shared_ptr<StructType>> nested_struct_types);
private:
//TODO: it is a stub for unnamed bit fields. Nobody should know about them
std::vector<std::shared_ptr<StructMember>> shadow_members;
std::vector<std::shared_ptr<StructMember>> members;
uint32_t nest_depth;
};
// ID for all handled Undefined Behaviour
enum UB {
NoUB,
NullPtr, // nullptr ptr dereferencing
SignOvf, // Signed overflow
SignOvfMin, // Special case of signed overflow: INT_MIN * (-1)
ZeroDiv, // FPE
ShiftRhsNeg, // Shift by negative value
ShiftRhsLarge, // // Shift by large value
NegShift, // Shift of negative value
NoMemeber, // Can't find member of structure
MaxUB
};
// Common ancestor for all builtin types.
class BuiltinType : public Type {
public:
// We need something to link together Type and Value (it should be consistent with Type).
class ScalarTypedVal {
public:
union Val {
bool bool_val;
signed char char_val;
unsigned char uchar_val;
short shrt_val;
unsigned short ushrt_val;
int int_val;
unsigned int uint_val;
int lint32_val; // for 32-bit mode
unsigned int ulint32_val; // for 32-bit mode
long long int lint64_val; // for 64-bit mode
unsigned long long int ulint64_val; // for 64-bit mode
long long int llint_val;
unsigned long long int ullint_val;
};
ScalarTypedVal (BuiltinType::IntegerTypeID _int_type_id) : int_type_id(_int_type_id), res_of_ub(NoUB) { val.ullint_val = 0; }
ScalarTypedVal (BuiltinType::IntegerTypeID _int_type_id, UB _res_of_ub) : int_type_id (_int_type_id), res_of_ub(_res_of_ub) { val.ullint_val = 0; }
Type::IntegerTypeID get_int_type_id () const { return int_type_id; }
// Utility functions for UB
UB get_ub () { return res_of_ub; }
void set_ub (UB _ub) { res_of_ub = _ub; }
bool has_ub () { return res_of_ub != NoUB; }
// Interface to value through uint64_t
//TODO: it is a stub for shift rebuild. Can we do it better?
uint64_t get_abs_val ();
void set_abs_val (uint64_t new_val);
// Functions which implements UB detection and semantics of all operators
ScalarTypedVal cast_type (Type::IntegerTypeID to_type_id);
ScalarTypedVal operator++ (int) { return pre_op(true ); } // Postfix, but used also as prefix
ScalarTypedVal operator-- (int) { return pre_op(false); }// Postfix, but used also as prefix
ScalarTypedVal operator- ();
ScalarTypedVal operator~ ();
ScalarTypedVal operator! ();
ScalarTypedVal operator+ (ScalarTypedVal rhs);
ScalarTypedVal operator- (ScalarTypedVal rhs);
ScalarTypedVal operator* (ScalarTypedVal rhs);
ScalarTypedVal operator/ (ScalarTypedVal rhs);
ScalarTypedVal operator% (ScalarTypedVal rhs);
ScalarTypedVal operator< (ScalarTypedVal rhs);
ScalarTypedVal operator> (ScalarTypedVal rhs);
ScalarTypedVal operator<= (ScalarTypedVal rhs);
ScalarTypedVal operator>= (ScalarTypedVal rhs);
ScalarTypedVal operator== (ScalarTypedVal rhs);
ScalarTypedVal operator!= (ScalarTypedVal rhs);
ScalarTypedVal operator&& (ScalarTypedVal rhs);
ScalarTypedVal operator|| (ScalarTypedVal rhs);
ScalarTypedVal operator& (ScalarTypedVal rhs);
ScalarTypedVal operator| (ScalarTypedVal rhs);
ScalarTypedVal operator^ (ScalarTypedVal rhs);
ScalarTypedVal operator<< (ScalarTypedVal rhs);
ScalarTypedVal operator>> (ScalarTypedVal rhs);
// Randomly generate ScalarTypedVal
static ScalarTypedVal generate (std::shared_ptr<Context> ctx, BuiltinType::IntegerTypeID _int_type_id);
static ScalarTypedVal generate (std::shared_ptr<Context> ctx, ScalarTypedVal min, ScalarTypedVal max);
// The value itself
Val val;
private:
// Common fuction for all pre-increment and post-increment operators
ScalarTypedVal pre_op (bool inc);
BuiltinType::IntegerTypeID int_type_id;
// If we can use the value or it was obtained from operation with UB
UB res_of_ub;
};
BuiltinType (BuiltinTypeID _builtin_id) : Type (Type::BUILTIN_TYPE), bit_size (0), suffix(""), builtin_id (_builtin_id) {}
BuiltinType (BuiltinTypeID _builtin_id, CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
Type (Type::BUILTIN_TYPE, _cv_qual, _is_static, _align), bit_size (0), suffix(""), builtin_id (_builtin_id) {}
bool is_builtin_type() { return true; }
// Getters for BuiltinType properties
BuiltinTypeID get_builtin_type_id() { return builtin_id; }
uint32_t get_bit_size () { return bit_size; }
std::string get_int_literal_suffix() { return suffix; }
protected:
unsigned int bit_size;
// Suffix for integer literals
std::string suffix;
private:
BuiltinTypeID builtin_id;
};
std::ostream& operator<< (std::ostream &out, const BuiltinType::ScalarTypedVal &scalar_typed_val);
// Class which serves as common ancestor for all standard integer types, bool and bit-fields
class IntegerType : public BuiltinType {
public:
IntegerType (IntegerTypeID it_id) : BuiltinType (BuiltinTypeID::Integer), is_signed (false), min(it_id), max(it_id), int_type_id (it_id) {}
IntegerType (IntegerTypeID it_id, CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
BuiltinType (BuiltinTypeID::Integer, _cv_qual, _is_static, _align),
is_signed (false), min(it_id), max(it_id), int_type_id (it_id) {}
bool is_int_type() { return true; }
// Getters for IntegerType properties
IntegerTypeID get_int_type_id () { return int_type_id; }
bool get_is_signed () { return is_signed; }
BuiltinType::ScalarTypedVal get_min () { return min; }
BuiltinType::ScalarTypedVal get_max () { return max; }
// This utility functions take IntegerTypeID and return shared pointer to corresponding type
static std::shared_ptr<IntegerType> init (BuiltinType::IntegerTypeID _type_id);
static std::shared_ptr<IntegerType> init (BuiltinType::IntegerTypeID _type_id, CV_Qual _cv_qual, bool _is_static, uint32_t _align);
// If type A can represent all the values of type B
static bool can_repr_value (BuiltinType::IntegerTypeID A, BuiltinType::IntegerTypeID B); // if type B can represent all of the values of the type A
// Returns corresponding unsigned type
static BuiltinType::IntegerTypeID get_corr_unsig (BuiltinType::IntegerTypeID _type_id);
// Randomly generate IntegerType (except bit-fields)
static std::shared_ptr<IntegerType> generate (std::shared_ptr<Context> ctx);
protected:
bool is_signed;
// Minimum and maximum value, which can fit in type
BuiltinType::ScalarTypedVal min;
BuiltinType::ScalarTypedVal max;
private:
IntegerTypeID int_type_id;
};
// Class which represents bit-field
class BitField : public IntegerType {
public:
BitField (IntegerTypeID it_id, uint32_t _bit_size) : IntegerType(it_id) { init_type(it_id, _bit_size); }
BitField (IntegerTypeID it_id, uint32_t _bit_size, CV_Qual _cv_qual) : IntegerType(it_id, _cv_qual, false, 0) { init_type(it_id, _bit_size); }
// Getters of BitField properties
bool get_is_bit_field() { return true; }
uint32_t get_bit_field_width() { return bit_field_width; }
// If all values of the bit-field can fit in signed/unsigned int
static bool can_fit_in_int (BuiltinType::ScalarTypedVal val, bool is_unsigned);
// Randomly generate BitField
static std::shared_ptr<BitField> generate (std::shared_ptr<Context> ctx, bool is_unnamed = false);
void dbg_dump ();
private:
// Common initializer functions, used in constructors
void init_type(IntegerTypeID it_id, uint32_t _bit_size);
uint32_t bit_field_width;
};
// Following classes represents standard integer types and bool
// TODO: maybe all this classes should be singletons?
class TypeBOOL : public IntegerType {
public:
TypeBOOL () : IntegerType(BuiltinType::IntegerTypeID::BOOL) { init_type (); }
TypeBOOL (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::BOOL, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "bool";
suffix = "";
min.val.bool_val = false;
max.val.bool_val = true;
bit_size = sizeof (bool) * CHAR_BIT;
is_signed = false;
}
};
class TypeCHAR : public IntegerType {
public:
TypeCHAR () : IntegerType(BuiltinType::IntegerTypeID::CHAR) { init_type (); }
TypeCHAR (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::CHAR, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "signed char";
suffix = "";
min.val.char_val = SCHAR_MIN;
max.val.char_val = SCHAR_MAX;
bit_size = sizeof (char) * CHAR_BIT;
is_signed = true;
}
};
class TypeUCHAR : public IntegerType {
public:
TypeUCHAR () : IntegerType(BuiltinType::IntegerTypeID::UCHAR) { init_type (); }
TypeUCHAR (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::UCHAR, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "unsigned char";
suffix = "";
min.val.uchar_val = 0;
max.val.uchar_val = UCHAR_MAX;
bit_size = sizeof (unsigned char) * CHAR_BIT;
is_signed = false;
}
};
class TypeSHRT : public IntegerType {
public:
TypeSHRT () : IntegerType(BuiltinType::IntegerTypeID::SHRT) { init_type (); }
TypeSHRT (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::SHRT, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "short";
suffix = "";
min.val.shrt_val = SHRT_MIN;
max.val.shrt_val = SHRT_MAX;
bit_size = sizeof (short) * CHAR_BIT;
is_signed = true;
}
};
class TypeUSHRT : public IntegerType {
public:
TypeUSHRT () : IntegerType(BuiltinType::IntegerTypeID::USHRT) { init_type (); }
TypeUSHRT (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::USHRT, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "unsigned short";
suffix = "";
min.val.ushrt_val = 0;
max.val.ushrt_val = USHRT_MAX;
bit_size = sizeof (unsigned short) * CHAR_BIT;
is_signed = false;
}
};
class TypeINT : public IntegerType {
public:
TypeINT () : IntegerType(BuiltinType::IntegerTypeID::INT) { init_type (); }
TypeINT (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::INT, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "int";
suffix = "";
min.val.int_val = INT_MIN;
max.val.int_val = INT_MAX;
bit_size = sizeof (int) * CHAR_BIT;
is_signed = true;
}
};
class TypeUINT : public IntegerType {
public:
TypeUINT () : IntegerType(BuiltinType::IntegerTypeID::UINT) { init_type (); }
TypeUINT (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::UINT, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "unsigned int";
suffix = "U";
min.val.uint_val = 0;
max.val.uint_val = UINT_MAX;
bit_size = sizeof (unsigned int) * CHAR_BIT;
is_signed = false;
}
};
class TypeLINT : public IntegerType {
public:
TypeLINT () : IntegerType(BuiltinType::IntegerTypeID::LINT) { init_type (); }
TypeLINT (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::LINT, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "long int";
suffix = "L";
if (options->mode_64bit) {
bit_size = sizeof(long long int) * CHAR_BIT;
min.val.lint64_val = LLONG_MIN;
max.val.lint64_val = LLONG_MAX;
}
else {
bit_size = sizeof(int) * CHAR_BIT;
min.val.lint32_val = INT_MIN;
max.val.lint32_val = INT_MAX;
}
is_signed = true;
}
};
class TypeULINT : public IntegerType {
public:
TypeULINT () : IntegerType(BuiltinType::IntegerTypeID::ULINT) { init_type (); }
TypeULINT (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::ULINT, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "unsigned long int";
suffix = "UL";
if (options->mode_64bit) {
bit_size = sizeof (unsigned long long int) * CHAR_BIT;
min.val.ulint64_val = 0;
max.val.ulint64_val = ULLONG_MAX;
}
else {
bit_size = sizeof(unsigned int) * CHAR_BIT;
min.val.ulint32_val = 0;
max.val.ulint32_val = UINT_MAX;
}
is_signed = false;
}
};
class TypeLLINT : public IntegerType {
public:
TypeLLINT () : IntegerType(BuiltinType::IntegerTypeID::LLINT) { init_type (); }
TypeLLINT (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::LLINT, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "long long int";
suffix = "LL";
min.val.llint_val = LLONG_MIN;
max.val.llint_val = LLONG_MAX;
bit_size = sizeof (long long int) * CHAR_BIT;
is_signed = true;
}
};
class TypeULLINT : public IntegerType {
public:
TypeULLINT () : IntegerType(BuiltinType::IntegerTypeID::ULLINT) { init_type (); }
TypeULLINT (CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
IntegerType(BuiltinType::IntegerTypeID::ULLINT, _cv_qual, _is_static, _align) { init_type (); }
void dbg_dump ();
private:
void init_type () {
name = "unsigned long long int";
suffix = "ULL";
min.val.ullint_val = 0;
max.val.ullint_val = ULLONG_MAX;
bit_size = sizeof (unsigned long long int) * CHAR_BIT;
is_signed = false;
}
};
// ArrayType represents arrays of all kinds.
//TODO: 1) maybe we should split it to several classes?
// 2) nowadays it can represent only one-dimensional array
class ArrayType : public Type {
public:
enum ElementSubscript {
Brackets, At, MaxElementSubscript
};
enum Kind {
C_ARR,
VAL_ARR,
STD_ARR,
STD_VEC,
MAX_KIND
};
ArrayType(std::shared_ptr<Type> _base_type, uint32_t _size, Kind _kind);
bool is_array_type () { return true; }
std::shared_ptr<Type> get_base_type () { return base_type; }
uint32_t get_size () { return size; }
Kind get_kind () { return kind; }
std::string get_type_suffix();
void dbg_dump();
static std::shared_ptr<ArrayType> generate(std::shared_ptr<Context> ctx);
private:
std::shared_ptr<Type> base_type;
uint32_t size;
Kind kind;
};
// Class which represents pointers
class PointerType : public Type {
public:
PointerType (std::shared_ptr<Type> base_type) :
Type(TypeID::POINTER_TYPE), pointee_type(base_type), depth(1) { init(); }
PointerType (std::shared_ptr<Type> base_type, CV_Qual _cv_qual, bool _is_static, uint32_t _align) :
Type(TypeID::POINTER_TYPE, _cv_qual, _is_static, _align), pointee_type(base_type), depth(1) { init(); }
bool is_ptr_type() { return true; }
std::shared_ptr<Type> get_pointee_type() { return pointee_type; }
uint32_t get_depth() { return depth; }
void dbg_dump();
private:
void init();
std::shared_ptr<Type> pointee_type;
uint32_t depth;
};
// This function checks if we can assign one pointer type to another
bool is_pointers_compatible (std::shared_ptr<PointerType> type_a, std::shared_ptr<PointerType> type_b);
}
| 39.287781 | 164 | 0.606376 | [
"vector"
] |
7f558f74f048dc78022749a2667ec1466e04da4a | 945 | h | C | CPP_files/line.h | GuiiFerrari/pyRANSAC-3D | d9fa1371d972ccb50d80067a5719b3cd5be63cbc | [
"Apache-2.0"
] | 1 | 2021-01-19T18:26:32.000Z | 2021-01-19T18:26:32.000Z | CPP_files/line.h | GuiiFerrari/pyRANSAC-3D | d9fa1371d972ccb50d80067a5719b3cd5be63cbc | [
"Apache-2.0"
] | null | null | null | CPP_files/line.h | GuiiFerrari/pyRANSAC-3D | d9fa1371d972ccb50d80067a5719b3cd5be63cbc | [
"Apache-2.0"
] | null | null | null | #ifndef __LINE__H
#define __LINE__H
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <time.h>
#include <vector>
#include <random>
/*
Author: Guilherme Ferrari Fortino
Adaptation from https://github.com/jczamorac/Tracking_RANSAC
*/
extern "C" {
void swap(int &a, int &b);
void getPDF(double* charge, double Tcharge, int size, double* PDF);
void get_random(int &ind1, int &ind2, double (*data)[3], double* charge, double* PDF, double TCharge, double AvgCharge, double TwiceAvCharge, int mode, int size);
int Ransac(double (*data)[3], double *versor, double* pb, int *inliers, double* charge, int number_it, double min_dist, int size, int mode);
int Ransac_2(double (*data)[3], double *versor, double* pb, int *inliers, double* charge, int number_it, double min_dist, int size, int mode);
void Fit3D(double *vX, double *vY, double *vZ, double *vQ, double *versor, double *Pb, int size);
}
#endif
| 33.75 | 163 | 0.702646 | [
"vector"
] |
7f578ea9be545c0f3cdc8a2e6223472be1e7e04d | 3,400 | h | C | services/service_manager/public/cpp/standalone_connector_impl.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 76 | 2020-09-02T03:05:41.000Z | 2022-03-30T04:40:55.000Z | services/service_manager/public/cpp/standalone_connector_impl.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 45 | 2020-09-02T03:21:37.000Z | 2022-03-31T22:19:45.000Z | services/service_manager/public/cpp/standalone_connector_impl.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 8 | 2020-07-22T18:49:18.000Z | 2022-02-08T10:27:16.000Z | // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_STANDALONE_CONNECTOR_IMPL_H_
#define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_STANDALONE_CONNECTOR_IMPL_H_
#include "base/component_export.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/generic_pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/service_manager/public/mojom/connector.mojom.h"
namespace service_manager {
// StandaloneConnectorImpl is a helper class which can be used to provide a
// backend for |Connector| objects to route requests somewhere other than the
// Service Manager.
//
// This exists to aid in transitioning code away from Service Manager APIs.
// Typically an instance of this class would live in the browser process, with a
// Delegate implementation that knows how to bind any interfaces that its
// clients might request.
class COMPONENT_EXPORT(SERVICE_MANAGER_CPP) StandaloneConnectorImpl
: private mojom::Connector {
public:
class Delegate {
public:
virtual ~Delegate() {}
// Invoked whenever a client asks to have an interface bound by the service
// named |service_name|. The interface endpoint to bind is contained in
// |receiver|.
virtual void OnConnect(const std::string& service_name,
mojo::GenericPendingReceiver receiver) = 0;
};
explicit StandaloneConnectorImpl(Delegate* delegate);
StandaloneConnectorImpl(const StandaloneConnectorImpl&) = delete;
StandaloneConnectorImpl& operator=(const StandaloneConnectorImpl&) = delete;
~StandaloneConnectorImpl() override;
// Produces a new remote Connector endpoint whose connection requests are
// routed to this object's Delegate. The returned PendingRemote can be passed
// around in messages, and it can eventually be used to construct a new
// concrete Connector object.
//
// Note that Connectors bound to this remote or clones of it will only support
// the basic operations of |BindInterface/Connect()|, and |Clone()|.
mojo::PendingRemote<mojom::Connector> MakeRemote();
private:
// mojom::Connector implementation:
void BindInterface(const ServiceFilter& filter,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe,
mojom::BindInterfacePriority priority,
BindInterfaceCallback callback) override;
void QueryService(const std::string& service_name,
QueryServiceCallback callback) override;
void WarmService(const ServiceFilter& filter,
WarmServiceCallback callback) override;
void RegisterServiceInstance(
const Identity& identity,
mojo::ScopedMessagePipeHandle service_pipe,
mojo::PendingReceiver<mojom::ProcessMetadata> metadata_receiver,
RegisterServiceInstanceCallback callback) override;
void Clone(mojo::PendingReceiver<mojom::Connector> receiver) override;
Delegate* const delegate_;
mojo::ReceiverSet<mojom::Connector> receivers_;
};
} // namespace service_manager
#endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_STANDALONE_CONNECTOR_IMPL_H_
| 41.463415 | 80 | 0.753824 | [
"object"
] |
7f5919189456ae785f0722da2223c6d069339cb2 | 4,558 | h | C | resources/app/native_node_modules/linux/node_modules/_nodegit@0.21.1@nodegit/include/config.h | Xmader/hydrogen | 53d4290f81727cd222cf20c11b939a8e4f83d566 | [
"MIT"
] | 20 | 2018-07-05T08:22:58.000Z | 2021-07-21T03:56:40.000Z | resources/app/native_node_modules/linux/node_modules/_nodegit@0.21.1@nodegit/include/config.h | Xmader/hydrogen | 53d4290f81727cd222cf20c11b939a8e4f83d566 | [
"MIT"
] | 7 | 2018-07-10T00:41:59.000Z | 2019-07-21T15:13:49.000Z | resources/app/native_node_modules/linux/node_modules/_nodegit@0.21.1@nodegit/include/config.h | Xmader/hydrogen | 53d4290f81727cd222cf20c11b939a8e4f83d566 | [
"MIT"
] | 3 | 2018-08-16T00:42:17.000Z | 2021-02-22T11:24:26.000Z | // This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCONFIG_H
#define GITCONFIG_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/git_buf_converter.h"
#include "../include/buf.h"
#include "../include/transaction.h"
// Forward declaration.
struct git_config {
};
using namespace node;
using namespace v8;
class GitConfig;
struct GitConfigTraits {
typedef GitConfig cppClass;
typedef git_config cType;
static const bool isDuplicable = false;
static void duplicate(git_config **dest, git_config *src) {
Nan::ThrowError("duplicate called on GitConfig which cannot be duplicated");
}
static const bool isFreeable = true;
static void free(git_config *raw) {
::git_config_free(raw); // :: to avoid calling this free recursively
}
};
class GitConfig : public
NodeGitWrapper<GitConfigTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitConfigTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitConfig()
: NodeGitWrapper<GitConfigTraits>(
"A new GitConfig cannot be instantiated."
)
{}
GitConfig(git_config *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitConfigTraits>(raw, selfFreeing, owner)
{}
~GitConfig();
struct FindProgramdataBaton {
int error_code;
const git_error* error;
git_buf * out;
};
class FindProgramdataWorker : public Nan::AsyncWorker {
public:
FindProgramdataWorker(
FindProgramdataBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FindProgramdataWorker() {};
void Execute();
void HandleOKCallback();
private:
FindProgramdataBaton *baton;
};
static NAN_METHOD(FindProgramdata);
struct GetStringBufBaton {
int error_code;
const git_error* error;
git_buf * out;
const git_config * cfg;
const char * name;
};
class GetStringBufWorker : public Nan::AsyncWorker {
public:
GetStringBufWorker(
GetStringBufBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetStringBufWorker() {};
void Execute();
void HandleOKCallback();
private:
GetStringBufBaton *baton;
};
static NAN_METHOD(GetStringBuf);
static NAN_METHOD(Lock);
struct OpenDefaultBaton {
int error_code;
const git_error* error;
git_config * out;
};
class OpenDefaultWorker : public Nan::AsyncWorker {
public:
OpenDefaultWorker(
OpenDefaultBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~OpenDefaultWorker() {};
void Execute();
void HandleOKCallback();
private:
OpenDefaultBaton *baton;
};
static NAN_METHOD(OpenDefault);
static NAN_METHOD(SetInt64);
static NAN_METHOD(SetMultivar);
struct SetStringBaton {
int error_code;
const git_error* error;
git_config * cfg;
const char * name;
const char * value;
};
class SetStringWorker : public Nan::AsyncWorker {
public:
SetStringWorker(
SetStringBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~SetStringWorker() {};
void Execute();
void HandleOKCallback();
private:
SetStringBaton *baton;
};
static NAN_METHOD(SetString);
struct SnapshotBaton {
int error_code;
const git_error* error;
git_config * out;
git_config * config;
};
class SnapshotWorker : public Nan::AsyncWorker {
public:
SnapshotWorker(
SnapshotBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~SnapshotWorker() {};
void Execute();
void HandleOKCallback();
private:
SnapshotBaton *baton;
};
static NAN_METHOD(Snapshot);
};
#endif
| 23.863874 | 103 | 0.613866 | [
"object"
] |
7f5c0f4f779b2b67d24ae8eb45ac7dd02d12ec4a | 18,426 | h | C | controllers/player/protobuf/include/google/protobuf/any_test.pb.h | elsiros/elsiros_webots | 01a5d1e279a5d9d21eb0e8cf9be609d62428a4f3 | [
"MIT"
] | null | null | null | controllers/player/protobuf/include/google/protobuf/any_test.pb.h | elsiros/elsiros_webots | 01a5d1e279a5d9d21eb0e8cf9be609d62428a4f3 | [
"MIT"
] | 17 | 2021-07-26T13:57:53.000Z | 2021-09-09T13:16:13.000Z | controllers/player/protobuf/include/google/protobuf/any_test.pb.h | RoboCupHSJL/elsiros_webots | 01a5d1e279a5d9d21eb0e8cf9be609d62428a4f3 | [
"MIT"
] | 1 | 2021-11-25T18:51:43.000Z | 2021-11-25T18:51:43.000Z | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/any_test.proto
#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_5ftest_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_5ftest_2eproto
#include <limits>
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3017000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3017003 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/any.pb.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fany_5ftest_2eproto
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
} // namespace internal
PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_google_2fprotobuf_2fany_5ftest_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const ::PROTOBUF_NAMESPACE_ID::uint32 offsets[];
};
extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_5ftest_2eproto;
namespace protobuf_unittest {
class TestAny;
struct TestAnyDefaultTypeInternal;
extern TestAnyDefaultTypeInternal _TestAny_default_instance_;
} // namespace protobuf_unittest
PROTOBUF_NAMESPACE_OPEN
template<> ::protobuf_unittest::TestAny* Arena::CreateMaybeMessage<::protobuf_unittest::TestAny>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
namespace protobuf_unittest {
// ===================================================================
class TestAny final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.TestAny) */ {
public:
inline TestAny() : TestAny(nullptr) {}
~TestAny() override;
explicit constexpr TestAny(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
TestAny(const TestAny& from);
TestAny(TestAny&& from) noexcept
: TestAny() {
*this = ::std::move(from);
}
inline TestAny& operator=(const TestAny& from) {
CopyFrom(from);
return *this;
}
inline TestAny& operator=(TestAny&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
&& GetOwningArena() != nullptr
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
return default_instance().GetMetadata().descriptor;
}
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
return default_instance().GetMetadata().reflection;
}
static const TestAny& default_instance() {
return *internal_default_instance();
}
static inline const TestAny* internal_default_instance() {
return reinterpret_cast<const TestAny*>(
&_TestAny_default_instance_);
}
static constexpr int kIndexInFileMessages =
0;
friend void swap(TestAny& a, TestAny& b) {
a.Swap(&b);
}
inline void Swap(TestAny* other) {
if (other == this) return;
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() != nullptr &&
GetOwningArena() == other->GetOwningArena()) {
#else // PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() == other->GetOwningArena()) {
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(TestAny* other) {
if (other == this) return;
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
inline TestAny* New() const final {
return new TestAny();
}
TestAny* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<TestAny>(arena);
}
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
void CopyFrom(const TestAny& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
void MergeFrom(const TestAny& from);
private:
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message* to, const ::PROTOBUF_NAMESPACE_ID::Message& from);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const final;
void InternalSwap(TestAny* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "protobuf_unittest.TestAny";
}
protected:
explicit TestAny(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
static const ClassData _class_data_;
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kRepeatedAnyValueFieldNumber = 3,
kTextFieldNumber = 4,
kAnyValueFieldNumber = 2,
kInt32ValueFieldNumber = 1,
};
// repeated .google.protobuf.Any repeated_any_value = 3;
int repeated_any_value_size() const;
private:
int _internal_repeated_any_value_size() const;
public:
void clear_repeated_any_value();
::PROTOBUF_NAMESPACE_ID::Any* mutable_repeated_any_value(int index);
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any >*
mutable_repeated_any_value();
private:
const ::PROTOBUF_NAMESPACE_ID::Any& _internal_repeated_any_value(int index) const;
::PROTOBUF_NAMESPACE_ID::Any* _internal_add_repeated_any_value();
public:
const ::PROTOBUF_NAMESPACE_ID::Any& repeated_any_value(int index) const;
::PROTOBUF_NAMESPACE_ID::Any* add_repeated_any_value();
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any >&
repeated_any_value() const;
// string text = 4;
void clear_text();
const std::string& text() const;
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_text(ArgT0&& arg0, ArgT... args);
std::string* mutable_text();
PROTOBUF_MUST_USE_RESULT std::string* release_text();
void set_allocated_text(std::string* text);
private:
const std::string& _internal_text() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_text(const std::string& value);
std::string* _internal_mutable_text();
public:
// .google.protobuf.Any any_value = 2;
bool has_any_value() const;
private:
bool _internal_has_any_value() const;
public:
void clear_any_value();
const ::PROTOBUF_NAMESPACE_ID::Any& any_value() const;
PROTOBUF_MUST_USE_RESULT ::PROTOBUF_NAMESPACE_ID::Any* release_any_value();
::PROTOBUF_NAMESPACE_ID::Any* mutable_any_value();
void set_allocated_any_value(::PROTOBUF_NAMESPACE_ID::Any* any_value);
private:
const ::PROTOBUF_NAMESPACE_ID::Any& _internal_any_value() const;
::PROTOBUF_NAMESPACE_ID::Any* _internal_mutable_any_value();
public:
void unsafe_arena_set_allocated_any_value(
::PROTOBUF_NAMESPACE_ID::Any* any_value);
::PROTOBUF_NAMESPACE_ID::Any* unsafe_arena_release_any_value();
// int32 int32_value = 1;
void clear_int32_value();
::PROTOBUF_NAMESPACE_ID::int32 int32_value() const;
void set_int32_value(::PROTOBUF_NAMESPACE_ID::int32 value);
private:
::PROTOBUF_NAMESPACE_ID::int32 _internal_int32_value() const;
void _internal_set_int32_value(::PROTOBUF_NAMESPACE_ID::int32 value);
public:
// @@protoc_insertion_point(class_scope:protobuf_unittest.TestAny)
private:
class _Internal;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any > repeated_any_value_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr text_;
::PROTOBUF_NAMESPACE_ID::Any* any_value_;
::PROTOBUF_NAMESPACE_ID::int32 int32_value_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_google_2fprotobuf_2fany_5ftest_2eproto;
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// TestAny
// int32 int32_value = 1;
inline void TestAny::clear_int32_value() {
int32_value_ = 0;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestAny::_internal_int32_value() const {
return int32_value_;
}
inline ::PROTOBUF_NAMESPACE_ID::int32 TestAny::int32_value() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestAny.int32_value)
return _internal_int32_value();
}
inline void TestAny::_internal_set_int32_value(::PROTOBUF_NAMESPACE_ID::int32 value) {
int32_value_ = value;
}
inline void TestAny::set_int32_value(::PROTOBUF_NAMESPACE_ID::int32 value) {
_internal_set_int32_value(value);
// @@protoc_insertion_point(field_set:protobuf_unittest.TestAny.int32_value)
}
// .google.protobuf.Any any_value = 2;
inline bool TestAny::_internal_has_any_value() const {
return this != internal_default_instance() && any_value_ != nullptr;
}
inline bool TestAny::has_any_value() const {
return _internal_has_any_value();
}
inline const ::PROTOBUF_NAMESPACE_ID::Any& TestAny::_internal_any_value() const {
const ::PROTOBUF_NAMESPACE_ID::Any* p = any_value_;
return p != nullptr ? *p : reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Any&>(
::PROTOBUF_NAMESPACE_ID::_Any_default_instance_);
}
inline const ::PROTOBUF_NAMESPACE_ID::Any& TestAny::any_value() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestAny.any_value)
return _internal_any_value();
}
inline void TestAny::unsafe_arena_set_allocated_any_value(
::PROTOBUF_NAMESPACE_ID::Any* any_value) {
if (GetArenaForAllocation() == nullptr) {
delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(any_value_);
}
any_value_ = any_value;
if (any_value) {
} else {
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:protobuf_unittest.TestAny.any_value)
}
inline ::PROTOBUF_NAMESPACE_ID::Any* TestAny::release_any_value() {
::PROTOBUF_NAMESPACE_ID::Any* temp = any_value_;
any_value_ = nullptr;
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp);
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
if (GetArenaForAllocation() == nullptr) { delete old; }
#else // PROTOBUF_FORCE_COPY_IN_RELEASE
if (GetArenaForAllocation() != nullptr) {
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
}
#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
return temp;
}
inline ::PROTOBUF_NAMESPACE_ID::Any* TestAny::unsafe_arena_release_any_value() {
// @@protoc_insertion_point(field_release:protobuf_unittest.TestAny.any_value)
::PROTOBUF_NAMESPACE_ID::Any* temp = any_value_;
any_value_ = nullptr;
return temp;
}
inline ::PROTOBUF_NAMESPACE_ID::Any* TestAny::_internal_mutable_any_value() {
if (any_value_ == nullptr) {
auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Any>(GetArenaForAllocation());
any_value_ = p;
}
return any_value_;
}
inline ::PROTOBUF_NAMESPACE_ID::Any* TestAny::mutable_any_value() {
::PROTOBUF_NAMESPACE_ID::Any* _msg = _internal_mutable_any_value();
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestAny.any_value)
return _msg;
}
inline void TestAny::set_allocated_any_value(::PROTOBUF_NAMESPACE_ID::Any* any_value) {
::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
if (message_arena == nullptr) {
delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(any_value_);
}
if (any_value) {
::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<
::PROTOBUF_NAMESPACE_ID::MessageLite>::GetOwningArena(
reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(any_value));
if (message_arena != submessage_arena) {
any_value = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
message_arena, any_value, submessage_arena);
}
} else {
}
any_value_ = any_value;
// @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestAny.any_value)
}
// repeated .google.protobuf.Any repeated_any_value = 3;
inline int TestAny::_internal_repeated_any_value_size() const {
return repeated_any_value_.size();
}
inline int TestAny::repeated_any_value_size() const {
return _internal_repeated_any_value_size();
}
inline ::PROTOBUF_NAMESPACE_ID::Any* TestAny::mutable_repeated_any_value(int index) {
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestAny.repeated_any_value)
return repeated_any_value_.Mutable(index);
}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any >*
TestAny::mutable_repeated_any_value() {
// @@protoc_insertion_point(field_mutable_list:protobuf_unittest.TestAny.repeated_any_value)
return &repeated_any_value_;
}
inline const ::PROTOBUF_NAMESPACE_ID::Any& TestAny::_internal_repeated_any_value(int index) const {
return repeated_any_value_.Get(index);
}
inline const ::PROTOBUF_NAMESPACE_ID::Any& TestAny::repeated_any_value(int index) const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestAny.repeated_any_value)
return _internal_repeated_any_value(index);
}
inline ::PROTOBUF_NAMESPACE_ID::Any* TestAny::_internal_add_repeated_any_value() {
return repeated_any_value_.Add();
}
inline ::PROTOBUF_NAMESPACE_ID::Any* TestAny::add_repeated_any_value() {
::PROTOBUF_NAMESPACE_ID::Any* _add = _internal_add_repeated_any_value();
// @@protoc_insertion_point(field_add:protobuf_unittest.TestAny.repeated_any_value)
return _add;
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Any >&
TestAny::repeated_any_value() const {
// @@protoc_insertion_point(field_list:protobuf_unittest.TestAny.repeated_any_value)
return repeated_any_value_;
}
// string text = 4;
inline void TestAny::clear_text() {
text_.ClearToEmpty();
}
inline const std::string& TestAny::text() const {
// @@protoc_insertion_point(field_get:protobuf_unittest.TestAny.text)
return _internal_text();
}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void TestAny::set_text(ArgT0&& arg0, ArgT... args) {
text_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:protobuf_unittest.TestAny.text)
}
inline std::string* TestAny::mutable_text() {
std::string* _s = _internal_mutable_text();
// @@protoc_insertion_point(field_mutable:protobuf_unittest.TestAny.text)
return _s;
}
inline const std::string& TestAny::_internal_text() const {
return text_.Get();
}
inline void TestAny::_internal_set_text(const std::string& value) {
text_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* TestAny::_internal_mutable_text() {
return text_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* TestAny::release_text() {
// @@protoc_insertion_point(field_release:protobuf_unittest.TestAny.text)
return text_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
}
inline void TestAny::set_allocated_text(std::string* text) {
if (text != nullptr) {
} else {
}
text_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), text,
GetArenaForAllocation());
// @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestAny.text)
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
} // namespace protobuf_unittest
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_5ftest_2eproto
| 38.149068 | 141 | 0.751113 | [
"object"
] |
7f6499ce15afbaca5c02bffd8a768615faebc43c | 1,986 | h | C | src/throttler_timed.h | jqll/cloud-profiler-java | f210b18ed3db28c3f72cbf0ee29d0cc21a49a438 | [
"Apache-2.0"
] | null | null | null | src/throttler_timed.h | jqll/cloud-profiler-java | f210b18ed3db28c3f72cbf0ee29d0cc21a49a438 | [
"Apache-2.0"
] | null | null | null | src/throttler_timed.h | jqll/cloud-profiler-java | f210b18ed3db28c3f72cbf0ee29d0cc21a49a438 | [
"Apache-2.0"
] | 1 | 2021-07-01T09:36:32.000Z | 2021-07-01T09:36:32.000Z | /*
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CLOUD_PROFILER_AGENT_JAVA_THROTTLER_TIMED_H_
#define CLOUD_PROFILER_AGENT_JAVA_THROTTLER_TIMED_H_
#include <memory>
#include <random>
#include "src/clock.h"
#include "src/throttler.h"
#include "src/uploader.h"
namespace cloud {
namespace profiler {
// Throttler implementation that uses a local timer and uploader interface.
class TimedThrottler : public Throttler {
public:
// Creates a timed throttler where path specifies the prefix path at which to
// store the collected profiles. The path may be a Google Cloud Storage path,
// prefixed with "gs://".
explicit TimedThrottler(const string& path);
// Testing-only constructor.
TimedThrottler(std::unique_ptr<ProfileUploader> uploader, Clock* clock,
bool fixed_seed);
bool WaitNext() override;
string ProfileType() override;
int64_t DurationNanos() override;
bool Upload(string profile) override;
private:
Clock* clock_;
int64_t duration_cpu_ns_, duration_wall_ns_;
int64_t interval_ns_;
std::default_random_engine gen_;
std::uniform_int_distribution<int64_t> dist_;
struct timespec next_interval_;
// Counts profile sets really (CPU + wall).
int profile_count_;
std::vector<std::pair<string, int64_t>> cur_;
std::unique_ptr<ProfileUploader> uploader_;
};
} // namespace profiler
} // namespace cloud
#endif // CLOUD_PROFILER_AGENT_JAVA_THROTTLER_TIMED_H_
| 30.090909 | 79 | 0.752266 | [
"vector"
] |
7f663f7abd12dd7b5abade0a6b20547936278612 | 22,877 | h | C | SymbolExtractorAndRenamer/lldb/include/lldb/Core/ArchSpec.h | Polidea/SiriusObfuscator | b0e590d8130e97856afe578869b83a209e2b19be | [
"Apache-2.0"
] | 427 | 2018-05-29T14:21:02.000Z | 2022-03-16T03:17:54.000Z | SymbolExtractorAndRenamer/lldb/include/lldb/Core/ArchSpec.h | PolideaPlayground/SiriusObfuscator | b0e590d8130e97856afe578869b83a209e2b19be | [
"Apache-2.0"
] | 25 | 2018-07-23T08:34:15.000Z | 2021-11-05T07:13:36.000Z | SymbolExtractorAndRenamer/lldb/include/lldb/Core/ArchSpec.h | PolideaPlayground/SiriusObfuscator | b0e590d8130e97856afe578869b83a209e2b19be | [
"Apache-2.0"
] | 52 | 2018-07-19T19:57:32.000Z | 2022-03-11T16:05:38.000Z | //===-- ArchSpec.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_ArchSpec_h_
#define liblldb_ArchSpec_h_
#if defined(__cplusplus)
#include "lldb/Core/ConstString.h"
#include "lldb/lldb-forward.h"
#include "llvm/ADT/Triple.h"
namespace lldb_private {
struct CoreDefinition;
//----------------------------------------------------------------------
/// @class ArchSpec ArchSpec.h "lldb/Core/ArchSpec.h"
/// @brief An architecture specification class.
///
/// A class designed to be created from a cpu type and subtype, a
/// string representation, or an llvm::Triple. Keeping all of the
/// conversions of strings to architecture enumeration values confined
/// to this class allows new architecture support to be added easily.
//----------------------------------------------------------------------
class ArchSpec {
public:
enum MIPSSubType {
eMIPSSubType_unknown,
eMIPSSubType_mips32,
eMIPSSubType_mips32r2,
eMIPSSubType_mips32r6,
eMIPSSubType_mips32el,
eMIPSSubType_mips32r2el,
eMIPSSubType_mips32r6el,
eMIPSSubType_mips64,
eMIPSSubType_mips64r2,
eMIPSSubType_mips64r6,
eMIPSSubType_mips64el,
eMIPSSubType_mips64r2el,
eMIPSSubType_mips64r6el,
};
// Masks for the ases word of an ABI flags structure.
enum MIPSASE {
eMIPSAse_dsp = 0x00000001, // DSP ASE
eMIPSAse_dspr2 = 0x00000002, // DSP R2 ASE
eMIPSAse_eva = 0x00000004, // Enhanced VA Scheme
eMIPSAse_mcu = 0x00000008, // MCU (MicroController) ASE
eMIPSAse_mdmx = 0x00000010, // MDMX ASE
eMIPSAse_mips3d = 0x00000020, // MIPS-3D ASE
eMIPSAse_mt = 0x00000040, // MT ASE
eMIPSAse_smartmips = 0x00000080, // SmartMIPS ASE
eMIPSAse_virt = 0x00000100, // VZ ASE
eMIPSAse_msa = 0x00000200, // MSA ASE
eMIPSAse_mips16 = 0x00000400, // MIPS16 ASE
eMIPSAse_micromips = 0x00000800, // MICROMIPS ASE
eMIPSAse_xpa = 0x00001000, // XPA ASE
eMIPSAse_mask = 0x00001fff,
eMIPSABI_O32 = 0x00002000,
eMIPSABI_N32 = 0x00004000,
eMIPSABI_N64 = 0x00008000,
eMIPSABI_O64 = 0x00020000,
eMIPSABI_EABI32 = 0x00040000,
eMIPSABI_EABI64 = 0x00080000,
eMIPSABI_mask = 0x000ff000
};
// MIPS Floating point ABI Values
enum MIPS_ABI_FP {
eMIPS_ABI_FP_ANY = 0x00000000,
eMIPS_ABI_FP_DOUBLE = 0x00100000, // hard float / -mdouble-float
eMIPS_ABI_FP_SINGLE = 0x00200000, // hard float / -msingle-float
eMIPS_ABI_FP_SOFT = 0x00300000, // soft float
eMIPS_ABI_FP_OLD_64 = 0x00400000, // -mips32r2 -mfp64
eMIPS_ABI_FP_XX = 0x00500000, // -mfpxx
eMIPS_ABI_FP_64 = 0x00600000, // -mips32r2 -mfp64
eMIPS_ABI_FP_64A = 0x00700000, // -mips32r2 -mfp64 -mno-odd-spreg
eMIPS_ABI_FP_mask = 0x00700000
};
// ARM specific e_flags
enum ARMeflags {
eARM_abi_soft_float = 0x00000200,
eARM_abi_hard_float = 0x00000400
};
enum Core {
eCore_arm_generic,
eCore_arm_armv4,
eCore_arm_armv4t,
eCore_arm_armv5,
eCore_arm_armv5e,
eCore_arm_armv5t,
eCore_arm_armv6,
eCore_arm_armv6m,
eCore_arm_armv7,
eCore_arm_armv7f,
eCore_arm_armv7s,
eCore_arm_armv7k,
eCore_arm_armv7m,
eCore_arm_armv7em,
eCore_arm_xscale,
eCore_thumb,
eCore_thumbv4t,
eCore_thumbv5,
eCore_thumbv5e,
eCore_thumbv6,
eCore_thumbv6m,
eCore_thumbv7,
eCore_thumbv7s,
eCore_thumbv7k,
eCore_thumbv7f,
eCore_thumbv7m,
eCore_thumbv7em,
eCore_arm_arm64,
eCore_arm_armv8,
eCore_arm_aarch64,
eCore_mips32,
eCore_mips32r2,
eCore_mips32r3,
eCore_mips32r5,
eCore_mips32r6,
eCore_mips32el,
eCore_mips32r2el,
eCore_mips32r3el,
eCore_mips32r5el,
eCore_mips32r6el,
eCore_mips64,
eCore_mips64r2,
eCore_mips64r3,
eCore_mips64r5,
eCore_mips64r6,
eCore_mips64el,
eCore_mips64r2el,
eCore_mips64r3el,
eCore_mips64r5el,
eCore_mips64r6el,
eCore_ppc_generic,
eCore_ppc_ppc601,
eCore_ppc_ppc602,
eCore_ppc_ppc603,
eCore_ppc_ppc603e,
eCore_ppc_ppc603ev,
eCore_ppc_ppc604,
eCore_ppc_ppc604e,
eCore_ppc_ppc620,
eCore_ppc_ppc750,
eCore_ppc_ppc7400,
eCore_ppc_ppc7450,
eCore_ppc_ppc970,
eCore_ppc64_generic,
eCore_ppc64_ppc970_64,
eCore_s390x_generic,
eCore_sparc_generic,
eCore_sparc9_generic,
eCore_x86_32_i386,
eCore_x86_32_i486,
eCore_x86_32_i486sx,
eCore_x86_32_i686,
eCore_x86_64_x86_64,
eCore_x86_64_x86_64h, // Haswell enabled x86_64
eCore_hexagon_generic,
eCore_hexagon_hexagonv4,
eCore_hexagon_hexagonv5,
eCore_uknownMach32,
eCore_uknownMach64,
eCore_kalimba3,
eCore_kalimba4,
eCore_kalimba5,
kNumCores,
kCore_invalid,
// The following constants are used for wildcard matching only
kCore_any,
kCore_arm_any,
kCore_ppc_any,
kCore_ppc64_any,
kCore_x86_32_any,
kCore_x86_64_any,
kCore_hexagon_any,
kCore_arm_first = eCore_arm_generic,
kCore_arm_last = eCore_arm_xscale,
kCore_thumb_first = eCore_thumb,
kCore_thumb_last = eCore_thumbv7em,
kCore_ppc_first = eCore_ppc_generic,
kCore_ppc_last = eCore_ppc_ppc970,
kCore_ppc64_first = eCore_ppc64_generic,
kCore_ppc64_last = eCore_ppc64_ppc970_64,
kCore_x86_32_first = eCore_x86_32_i386,
kCore_x86_32_last = eCore_x86_32_i686,
kCore_x86_64_first = eCore_x86_64_x86_64,
kCore_x86_64_last = eCore_x86_64_x86_64h,
kCore_hexagon_first = eCore_hexagon_generic,
kCore_hexagon_last = eCore_hexagon_hexagonv5,
kCore_kalimba_first = eCore_kalimba3,
kCore_kalimba_last = eCore_kalimba5,
kCore_mips32_first = eCore_mips32,
kCore_mips32_last = eCore_mips32r6,
kCore_mips32el_first = eCore_mips32el,
kCore_mips32el_last = eCore_mips32r6el,
kCore_mips64_first = eCore_mips64,
kCore_mips64_last = eCore_mips64r6,
kCore_mips64el_first = eCore_mips64el,
kCore_mips64el_last = eCore_mips64r6el,
kCore_mips_first = eCore_mips32,
kCore_mips_last = eCore_mips64r6el
};
typedef void (*StopInfoOverrideCallbackType)(lldb_private::Thread &thread);
//------------------------------------------------------------------
/// Default constructor.
///
/// Default constructor that initializes the object with invalid
/// cpu type and subtype values.
//------------------------------------------------------------------
ArchSpec();
//------------------------------------------------------------------
/// Constructor over triple.
///
/// Constructs an ArchSpec with properties consistent with the given
/// Triple.
//------------------------------------------------------------------
explicit ArchSpec(const llvm::Triple &triple);
explicit ArchSpec(const char *triple_cstr);
explicit ArchSpec(llvm::StringRef triple_str);
ArchSpec(const char *triple_cstr, Platform *platform);
ArchSpec(llvm::StringRef triple_str, Platform *platform);
//------------------------------------------------------------------
/// Constructor over architecture name.
///
/// Constructs an ArchSpec with properties consistent with the given
/// object type and architecture name.
//------------------------------------------------------------------
explicit ArchSpec(ArchitectureType arch_type, uint32_t cpu_type,
uint32_t cpu_subtype);
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
~ArchSpec();
//------------------------------------------------------------------
/// Assignment operator.
///
/// @param[in] rhs another ArchSpec object to copy.
///
/// @return A const reference to this object.
//------------------------------------------------------------------
const ArchSpec &operator=(const ArchSpec &rhs);
static size_t AutoComplete(llvm::StringRef name, StringList &matches);
//------------------------------------------------------------------
/// Returns a static string representing the current architecture.
///
/// @return A static string correcponding to the current
/// architecture.
//------------------------------------------------------------------
const char *GetArchitectureName() const;
//-----------------------------------------------------------------
/// if MIPS architecture return true.
///
/// @return a boolean value.
//-----------------------------------------------------------------
bool IsMIPS() const;
//------------------------------------------------------------------
/// Returns a string representing current architecture as a target CPU
/// for tools like compiler, disassembler etc.
///
/// @return A string representing target CPU for the current
/// architecture.
//------------------------------------------------------------------
std::string GetClangTargetCPU();
//------------------------------------------------------------------
/// Return a string representing target application ABI.
///
/// @return A string representing target application ABI.
//------------------------------------------------------------------
std::string GetTargetABI() const;
//------------------------------------------------------------------
/// Clears the object state.
///
/// Clears the object state back to a default invalid state.
//------------------------------------------------------------------
void Clear();
//------------------------------------------------------------------
/// Returns the size in bytes of an address of the current
/// architecture.
///
/// @return The byte size of an address of the current architecture.
//------------------------------------------------------------------
uint32_t GetAddressByteSize() const;
//------------------------------------------------------------------
/// Returns a machine family for the current architecture.
///
/// @return An LLVM arch type.
//------------------------------------------------------------------
llvm::Triple::ArchType GetMachine() const;
//------------------------------------------------------------------
/// Returns the distribution id of the architecture.
///
/// This will be something like "ubuntu", "fedora", etc. on Linux.
///
/// @return A ConstString ref containing the distribution id,
/// potentially empty.
//------------------------------------------------------------------
const ConstString &GetDistributionId() const;
//------------------------------------------------------------------
/// Set the distribution id of the architecture.
///
/// This will be something like "ubuntu", "fedora", etc. on Linux.
/// This should be the same value returned by
/// HostInfo::GetDistributionId ().
///------------------------------------------------------------------
void SetDistributionId(const char *distribution_id);
//------------------------------------------------------------------
/// Tests if this ArchSpec is valid.
///
/// @return True if the current architecture is valid, false
/// otherwise.
//------------------------------------------------------------------
bool IsValid() const {
return m_core >= eCore_arm_generic && m_core < kNumCores;
}
bool TripleVendorWasSpecified() const {
return !m_triple.getVendorName().empty();
}
bool TripleVendorIsUnspecifiedUnknown() const {
return m_triple.getVendor() == llvm::Triple::UnknownVendor &&
m_triple.getVendorName().empty();
}
bool TripleOSWasSpecified() const { return !m_triple.getOSName().empty(); }
bool TripleEnvironmentWasSpecified() const {
return !m_triple.getEnvironmentName().empty();
}
bool TripleOSIsUnspecifiedUnknown() const {
return m_triple.getOS() == llvm::Triple::UnknownOS &&
m_triple.getOSName().empty();
}
//------------------------------------------------------------------
/// Merges fields from another ArchSpec into this ArchSpec.
///
/// This will use the supplied ArchSpec to fill in any fields of
/// the triple in this ArchSpec which were unspecified. This can
/// be used to refine a generic ArchSpec with a more specific one.
/// For example, if this ArchSpec's triple is something like
/// i386-unknown-unknown-unknown, and we have a triple which is
/// x64-pc-windows-msvc, then merging that triple into this one
/// will result in the triple i386-pc-windows-msvc.
///
//------------------------------------------------------------------
void MergeFrom(const ArchSpec &other);
//------------------------------------------------------------------
/// Change the architecture object type, CPU type and OS type.
///
/// @param[in] arch_type The object type of this ArchSpec.
///
/// @param[in] cpu The required CPU type.
///
/// @param[in] os The optional OS type
/// The default value of 0 was chosen to from the ELF spec value
/// ELFOSABI_NONE. ELF is the only one using this parameter. If another
/// format uses this parameter and 0 does not work, use a value over
/// 255 because in the ELF header this is value is only a byte.
///
/// @return True if the object, and CPU were successfully set.
///
/// As a side effect, the vendor value is usually set to unknown.
/// The exections are
/// aarch64-apple-ios
/// arm-apple-ios
/// thumb-apple-ios
/// x86-apple-
/// x86_64-apple-
///
/// As a side effect, the os value is usually set to unknown
/// The exceptions are
/// *-*-aix
/// aarch64-apple-ios
/// arm-apple-ios
/// thumb-apple-ios
/// powerpc-apple-darwin
/// *-*-freebsd
/// *-*-linux
/// *-*-netbsd
/// *-*-openbsd
/// *-*-solaris
//------------------------------------------------------------------
bool SetArchitecture(ArchitectureType arch_type, uint32_t cpu, uint32_t sub,
uint32_t os = 0);
//------------------------------------------------------------------
/// Returns the byte order for the architecture specification.
///
/// @return The endian enumeration for the current endianness of
/// the architecture specification
//------------------------------------------------------------------
lldb::ByteOrder GetByteOrder() const;
//------------------------------------------------------------------
/// Sets this ArchSpec's byte order.
///
/// In the common case there is no need to call this method as the
/// byte order can almost always be determined by the architecture.
/// However, many CPU's are bi-endian (ARM, Alpha, PowerPC, etc)
/// and the default/assumed byte order may be incorrect.
//------------------------------------------------------------------
void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; }
uint32_t GetMinimumOpcodeByteSize() const;
uint32_t GetMaximumOpcodeByteSize() const;
Core GetCore() const { return m_core; }
uint32_t GetMachOCPUType() const;
uint32_t GetMachOCPUSubType() const;
//------------------------------------------------------------------
/// Architecture data byte width accessor
///
/// @return the size in 8-bit (host) bytes of a minimum addressable
/// unit from the Architecture's data bus
//------------------------------------------------------------------
uint32_t GetDataByteSize() const;
//------------------------------------------------------------------
/// Architecture code byte width accessor
///
/// @return the size in 8-bit (host) bytes of a minimum addressable
/// unit from the Architecture's code bus
//------------------------------------------------------------------
uint32_t GetCodeByteSize() const;
//------------------------------------------------------------------
/// Architecture tripple accessor.
///
/// @return A triple describing this ArchSpec.
//------------------------------------------------------------------
llvm::Triple &GetTriple() { return m_triple; }
//------------------------------------------------------------------
/// Architecture tripple accessor.
///
/// @return A triple describing this ArchSpec.
//------------------------------------------------------------------
const llvm::Triple &GetTriple() const { return m_triple; }
void DumpTriple(Stream &s) const;
//------------------------------------------------------------------
/// Architecture tripple setter.
///
/// Configures this ArchSpec according to the given triple. If the
/// triple has unknown components in all of the vendor, OS, and
/// the optional environment field (i.e. "i386-unknown-unknown")
/// then default values are taken from the host. Architecture and
/// environment components are used to further resolve the CPU type
/// and subtype, endian characteristics, etc.
///
/// @return A triple describing this ArchSpec.
//------------------------------------------------------------------
bool SetTriple(const llvm::Triple &triple);
bool SetTriple(llvm::StringRef triple_str);
bool SetTriple(llvm::StringRef triple_str, Platform *platform);
bool SetTriple(const char *triple_cstr);
bool SetTriple(const char *triple_cstr, Platform *platform);
//------------------------------------------------------------------
/// Returns the default endianness of the architecture.
///
/// @return The endian enumeration for the default endianness of
/// the architecture.
//------------------------------------------------------------------
lldb::ByteOrder GetDefaultEndian() const;
//------------------------------------------------------------------
/// Returns true if 'char' is a signed type by defualt in the
/// architecture false otherwise
///
/// @return True if 'char' is a signed type by default on the
/// architecture and false otherwise.
//------------------------------------------------------------------
bool CharIsSignedByDefault() const;
//------------------------------------------------------------------
/// Compare an ArchSpec to another ArchSpec, requiring an exact cpu
/// type match between them.
/// e.g. armv7s is not an exact match with armv7 - this would return false
///
/// @return true if the two ArchSpecs match.
//------------------------------------------------------------------
bool IsExactMatch(const ArchSpec &rhs) const;
//------------------------------------------------------------------
/// Compare an ArchSpec to another ArchSpec, requiring a compatible
/// cpu type match between them.
/// e.g. armv7s is compatible with armv7 - this method would return true
///
/// @return true if the two ArchSpecs are compatible
//------------------------------------------------------------------
bool IsCompatibleMatch(const ArchSpec &rhs) const;
//------------------------------------------------------------------
/// Get a stop info override callback for the current architecture.
///
/// Most platform specific code should go in lldb_private::Platform,
/// but there are cases where no matter which platform you are on
/// certain things hold true.
///
/// This callback is currently intended to handle cases where a
/// program stops at an instruction that won't get executed and it
/// allows the stop reasonm, like "breakpoint hit", to be replaced
/// with a different stop reason like "no stop reason".
///
/// This is specifically used for ARM in Thumb code when we stop in
/// an IT instruction (if/then/else) where the instruction won't get
/// executed and therefore it wouldn't be correct to show the program
/// stopped at the current PC. The code is generic and applies to all
/// ARM CPUs.
///
/// @return NULL or a valid stop info override callback for the
/// current architecture.
//------------------------------------------------------------------
StopInfoOverrideCallbackType GetStopInfoOverrideCallback() const;
bool IsFullySpecifiedTriple() const;
void PiecewiseTripleCompare(const ArchSpec &other, bool &arch_different,
bool &vendor_different, bool &os_different,
bool &os_version_different, bool &env_different);
//------------------------------------------------------------------
/// Detect whether this architecture uses thumb code exclusively
///
/// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can
/// only execute the Thumb instructions, never Arm. We should normally
/// pick up arm/thumbness from their the processor status bits (cpsr/xpsr)
/// or hints on each function - but when doing bare-boards low level
/// debugging (especially common with these embedded processors), we may
/// not have those things easily accessible.
///
/// @return true if this is an arm ArchSpec which can only execute Thumb
/// instructions
//------------------------------------------------------------------
bool IsAlwaysThumbInstructions() const;
uint32_t GetFlags() const { return m_flags; }
void SetFlags(uint32_t flags) { m_flags = flags; }
void SetFlags(std::string elf_abi);
protected:
bool IsEqualTo(const ArchSpec &rhs, bool exact_match) const;
llvm::Triple m_triple;
Core m_core = kCore_invalid;
lldb::ByteOrder m_byte_order = lldb::eByteOrderInvalid;
// Additional arch flags which we cannot get from triple and core
// For MIPS these are application specific extensions like
// micromips, mips16 etc.
uint32_t m_flags = 0;
ConstString m_distribution_id;
// Called when m_def or m_entry are changed. Fills in all remaining
// members with default values.
void CoreUpdated(bool update_triple);
};
//------------------------------------------------------------------
/// @fn bool operator< (const ArchSpec& lhs, const ArchSpec& rhs)
/// @brief Less than operator.
///
/// Tests two ArchSpec objects to see if \a lhs is less than \a
/// rhs.
///
/// @param[in] lhs The Left Hand Side ArchSpec object to compare.
/// @param[in] rhs The Left Hand Side ArchSpec object to compare.
///
/// @return true if \a lhs is less than \a rhs
//------------------------------------------------------------------
bool operator<(const ArchSpec &lhs, const ArchSpec &rhs);
bool ParseMachCPUDashSubtypeTriple(llvm::StringRef triple_str, ArchSpec &arch);
} // namespace lldb_private
#endif // #if defined(__cplusplus)
#endif // #ifndef liblldb_ArchSpec_h_
| 35.358578 | 80 | 0.559426 | [
"object",
"3d"
] |
7f6bc787e77f8659bf2ec21cb613c0167dbb21c5 | 2,680 | h | C | src/util/region.h | crowell/z3 | ac21ffebdf1512da2a77dc46c47bde87cc3850f3 | [
"MIT"
] | 2 | 2016-08-28T07:10:51.000Z | 2021-03-25T23:59:41.000Z | src/util/region.h | crowell/z3 | ac21ffebdf1512da2a77dc46c47bde87cc3850f3 | [
"MIT"
] | null | null | null | src/util/region.h | crowell/z3 | ac21ffebdf1512da2a77dc46c47bde87cc3850f3 | [
"MIT"
] | null | null | null | /*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
region.h
Abstract:
Region/Arena memory manager
Author:
Leonardo de Moura (leonardo) 2006-09-13.
Revision History:
--*/
#ifndef _REGION_H_
#define _REGION_H_
#include<cstdlib>
#include<iostream>
#ifdef Z3DEBUG
#include"vector.h"
class region {
ptr_vector<char> m_chuncks;
unsigned_vector m_scopes;
public:
~region() {
reset();
}
void * allocate(size_t size) {
char * r = alloc_svect(char, size);
m_chuncks.push_back(r);
return r;
}
void reset() {
ptr_vector<char>::iterator it = m_chuncks.begin();
ptr_vector<char>::iterator end = m_chuncks.end();
for (; it != end; ++it) {
dealloc_svect(*it);
}
m_chuncks.reset();
m_scopes.reset();
}
void push_scope() {
m_scopes.push_back(m_chuncks.size());
}
void pop_scope() {
unsigned old_size = m_scopes.back();
m_scopes.pop_back();
ptr_vector<char>::iterator it = m_chuncks.begin() + old_size;
ptr_vector<char>::iterator end = m_chuncks.end();
for (; it != end; ++it) {
dealloc_svect(*it);
}
m_chuncks.shrink(old_size);
}
void pop_scope(unsigned num_scopes) {
for (unsigned i = 0; i < num_scopes; i++) {
pop_scope();
}
}
void display_mem_stats(std::ostream & out) const;
};
#else
/**
\brief Implement explicit region memory manager.
*/
class region {
struct mark {
char * m_curr_page;
char * m_curr_ptr;
mark * m_prev_mark;
mark(char * page, char * ptr, mark * m):m_curr_page(page), m_curr_ptr(ptr), m_prev_mark(m) {}
};
char * m_curr_page;
char * m_curr_ptr; //!< Next free space in the current page.
char * m_curr_end_ptr; //!< Point to the end of the current page.
char * m_free_pages;
mark * m_mark;
void allocate_page();
void recycle_curr_page();
public:
region();
~region();
void * allocate(size_t size);
void reset();
void push_scope();
void pop_scope();
void pop_scope(unsigned num_scopes) {
for (unsigned i = 0; i < num_scopes; i++) {
pop_scope();
}
}
void display_mem_stats(std::ostream & out) const;
};
#endif
inline void * operator new(size_t s, region & r) { return r.allocate(s); }
inline void * operator new[](size_t s, region & r) { return r.allocate(s); }
inline void operator delete(void *, region & ) { /* do nothing */ }
inline void operator delete[](void *, region & ) { /* do nothing */ }
#endif /* _REGION_H_ */
| 21.967213 | 101 | 0.586194 | [
"vector"
] |
7f6f8e09cd31ab712777ef781e7ffd235da3a1b7 | 8,128 | c | C | c/serializer/samples/simplesample_mqtt/simplesample_mqtt.c | sunilsamal4commit/IOT | 1d20556c15595259241c99fd086b7e2599f5ca83 | [
"MIT"
] | 1 | 2021-07-14T00:43:24.000Z | 2021-07-14T00:43:24.000Z | c/serializer/samples/simplesample_mqtt/simplesample_mqtt.c | sunilsamal4commit/IOT | 1d20556c15595259241c99fd086b7e2599f5ca83 | [
"MIT"
] | null | null | null | c/serializer/samples/simplesample_mqtt/simplesample_mqtt.c | sunilsamal4commit/IOT | 1d20556c15595259241c99fd086b7e2599f5ca83 | [
"MIT"
] | null | null | null | // Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
/* This sample uses the _LL APIs of iothub_client for example purposes.
That does not mean that MQTT only works with the _LL APIs.
Simply changing the using the convenience layer (functions not having _LL)
and removing calls to _DoWork will yield the same results. */
#include "azure_c_shared_utility/threadapi.h"
#include "azure_c_shared_utility/platform.h"
#include "serializer.h"
#include "iothub_client_ll.h"
#include "iothubtransportmqtt.h"
#ifdef MBED_BUILD_TIMESTAMP
#include "certs.h"
#endif // MBED_BUILD_TIMESTAMP
/*String containing Hostname, Device Id & Device Key in the format: */
/* "HostName=<host_name>;DeviceId=<device_id>;SharedAccessKey=<device_key>" */
static const char* connectionString = "[device connection string]";
// Define the Model
BEGIN_NAMESPACE(WeatherStation);
DECLARE_MODEL(ContosoAnemometer,
WITH_DATA(ascii_char_ptr, DeviceId),
WITH_DATA(int, WindSpeed),
WITH_ACTION(TurnFanOn),
WITH_ACTION(TurnFanOff),
WITH_ACTION(SetAirResistance, int, Position)
);
END_NAMESPACE(WeatherStation);
EXECUTE_COMMAND_RESULT TurnFanOn(ContosoAnemometer* device)
{
(void)device;
(void)printf("Turning fan on.\r\n");
return EXECUTE_COMMAND_SUCCESS;
}
EXECUTE_COMMAND_RESULT TurnFanOff(ContosoAnemometer* device)
{
(void)device;
(void)printf("Turning fan off.\r\n");
return EXECUTE_COMMAND_SUCCESS;
}
EXECUTE_COMMAND_RESULT SetAirResistance(ContosoAnemometer* device, int Position)
{
(void)device;
(void)printf("Setting Air Resistance Position to %d.\r\n", Position);
return EXECUTE_COMMAND_SUCCESS;
}
void sendCallback(IOTHUB_CLIENT_CONFIRMATION_RESULT result, void* userContextCallback)
{
unsigned int messageTrackingId = (unsigned int)(uintptr_t)userContextCallback;
(void)printf("Message Id: %u Received.\r\n", messageTrackingId);
(void)printf("Result Call Back Called! Result is: %s \r\n", ENUM_TO_STRING(IOTHUB_CLIENT_CONFIRMATION_RESULT, result));
}
static void sendMessage(IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, const unsigned char* buffer, size_t size)
{
static unsigned int messageTrackingId;
IOTHUB_MESSAGE_HANDLE messageHandle = IoTHubMessage_CreateFromByteArray(buffer, size);
if (messageHandle == NULL)
{
printf("unable to create a new IoTHubMessage\r\n");
}
else
{
if (IoTHubClient_LL_SendEventAsync(iotHubClientHandle, messageHandle, sendCallback, (void*)(uintptr_t)messageTrackingId) != IOTHUB_CLIENT_OK)
{
printf("failed to hand over the message to IoTHubClient");
}
else
{
printf("IoTHubClient accepted the message for delivery\r\n");
}
IoTHubMessage_Destroy(messageHandle);
}
free((void*)buffer);
messageTrackingId++;
}
/*this function "links" IoTHub to the serialization library*/
static IOTHUBMESSAGE_DISPOSITION_RESULT IoTHubMessage(IOTHUB_MESSAGE_HANDLE message, void* userContextCallback)
{
IOTHUBMESSAGE_DISPOSITION_RESULT result;
const unsigned char* buffer;
size_t size;
if (IoTHubMessage_GetByteArray(message, &buffer, &size) != IOTHUB_MESSAGE_OK)
{
printf("unable to IoTHubMessage_GetByteArray\r\n");
result = EXECUTE_COMMAND_ERROR;
}
else
{
/*buffer is not zero terminated*/
char* temp = malloc(size + 1);
if (temp == NULL)
{
printf("failed to malloc\r\n");
result = EXECUTE_COMMAND_ERROR;
}
else
{
memcpy(temp, buffer, size);
temp[size] = '\0';
EXECUTE_COMMAND_RESULT executeCommandResult = EXECUTE_COMMAND(userContextCallback, temp);
result =
(executeCommandResult == EXECUTE_COMMAND_ERROR) ? IOTHUBMESSAGE_ABANDONED :
(executeCommandResult == EXECUTE_COMMAND_SUCCESS) ? IOTHUBMESSAGE_ACCEPTED :
IOTHUBMESSAGE_REJECTED;
free(temp);
}
}
return result;
}
void simplesample_mqtt_run(void)
{
if (platform_init() != 0)
{
(void)printf("Failed to initialize platform.\r\n");
}
else
{
if (serializer_init(NULL) != SERIALIZER_OK)
{
(void)printf("Failed on serializer_init\r\n");
}
else
{
IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle = IoTHubClient_LL_CreateFromConnectionString(connectionString, MQTT_Protocol);
srand((unsigned int)time(NULL));
int avgWindSpeed = 10;
if (iotHubClientHandle == NULL)
{
(void)printf("Failed on IoTHubClient_LL_Create\r\n");
}
else
{
#ifdef MBED_BUILD_TIMESTAMP
// For mbed add the certificate information
if (IoTHubClient_LL_SetOption(iotHubClientHandle, "TrustedCerts", certificates) != IOTHUB_CLIENT_OK)
{
(void)printf("failure to set option \"TrustedCerts\"\r\n");
}
#endif // MBED_BUILD_TIMESTAMP
ContosoAnemometer* myWeather = CREATE_MODEL_INSTANCE(WeatherStation, ContosoAnemometer);
if (myWeather == NULL)
{
(void)printf("Failed on CREATE_MODEL_INSTANCE\r\n");
}
else
{
if (IoTHubClient_LL_SetMessageCallback(iotHubClientHandle, IoTHubMessage, myWeather) != IOTHUB_CLIENT_OK)
{
printf("unable to IoTHubClient_SetMessageCallback\r\n");
}
else
{
myWeather->DeviceId = "myFirstDevice";
myWeather->WindSpeed = avgWindSpeed + (rand() % 4 + 2);
{
unsigned char* destination;
size_t destinationSize;
if (SERIALIZE(&destination, &destinationSize, myWeather->DeviceId, myWeather->WindSpeed) != CODEFIRST_OK)
{
(void)printf("Failed to serialize\r\n");
}
else
{
IOTHUB_MESSAGE_HANDLE messageHandle = IoTHubMessage_CreateFromByteArray(destination, destinationSize);
if (messageHandle == NULL)
{
printf("unable to create a new IoTHubMessage\r\n");
}
else
{
if (IoTHubClient_LL_SendEventAsync(iotHubClientHandle, messageHandle, sendCallback, (void*)1) != IOTHUB_CLIENT_OK)
{
printf("failed to hand over the message to IoTHubClient");
}
else
{
printf("IoTHubClient accepted the message for delivery\r\n");
}
IoTHubMessage_Destroy(messageHandle);
}
free(destination);
}
}
/* wait for commands */
while (1)
{
IoTHubClient_LL_DoWork(iotHubClientHandle);
ThreadAPI_Sleep(100);
}
}
DESTROY_MODEL_INSTANCE(myWeather);
}
IoTHubClient_LL_Destroy(iotHubClientHandle);
}
serializer_deinit();
}
platform_deinit();
}
}
| 35.806167 | 150 | 0.571604 | [
"model"
] |
7f708da616f8ce5000956345a2a452369b9b2ed6 | 3,548 | c | C | matlab/+liblinear/linear_model_matlab.c | mprat/liblinear | ee6bd52c7e18880f0838d0c294df21c60c60ef84 | [
"BSD-3-Clause"
] | null | null | null | matlab/+liblinear/linear_model_matlab.c | mprat/liblinear | ee6bd52c7e18880f0838d0c294df21c60c60ef84 | [
"BSD-3-Clause"
] | null | null | null | matlab/+liblinear/linear_model_matlab.c | mprat/liblinear | ee6bd52c7e18880f0838d0c294df21c60c60ef84 | [
"BSD-3-Clause"
] | null | null | null | #include <stdlib.h>
#include <string.h>
#include "../../linear.h"
#include "mex.h"
#ifdef MX_API_VER
#if MX_API_VER < 0x07030000
typedef int mwIndex;
#endif
#endif
#define Malloc(type,n) (type *)malloc((n)*sizeof(type))
#define NUM_OF_RETURN_FIELD 6
static const char *field_names[] = {
"Parameters",
"nr_class",
"nr_feature",
"bias",
"Label",
"w",
};
const char *model_to_matlab_structure(mxArray *plhs[], struct model *model_)
{
int i;
int nr_w;
double *ptr;
mxArray *return_model, **rhs;
int out_id = 0;
int n, w_size;
rhs = (mxArray **)mxMalloc(sizeof(mxArray *)*NUM_OF_RETURN_FIELD);
// Parameters
// for now, only solver_type is needed
rhs[out_id] = mxCreateDoubleMatrix(1, 1, mxREAL);
ptr = mxGetPr(rhs[out_id]);
ptr[0] = model_->param.solver_type;
out_id++;
// nr_class
rhs[out_id] = mxCreateDoubleMatrix(1, 1, mxREAL);
ptr = mxGetPr(rhs[out_id]);
ptr[0] = model_->nr_class;
out_id++;
if(model_->nr_class==2 && model_->param.solver_type != MCSVM_CS)
nr_w=1;
else
nr_w=model_->nr_class;
// nr_feature
rhs[out_id] = mxCreateDoubleMatrix(1, 1, mxREAL);
ptr = mxGetPr(rhs[out_id]);
ptr[0] = model_->nr_feature;
out_id++;
// bias
rhs[out_id] = mxCreateDoubleMatrix(1, 1, mxREAL);
ptr = mxGetPr(rhs[out_id]);
ptr[0] = model_->bias;
out_id++;
if(model_->bias>=0)
n=model_->nr_feature+1;
else
n=model_->nr_feature;
w_size = n;
// Label
if(model_->label)
{
rhs[out_id] = mxCreateDoubleMatrix(model_->nr_class, 1, mxREAL);
ptr = mxGetPr(rhs[out_id]);
for(i = 0; i < model_->nr_class; i++)
ptr[i] = model_->label[i];
}
else
rhs[out_id] = mxCreateDoubleMatrix(0, 0, mxREAL);
out_id++;
// w
rhs[out_id] = mxCreateDoubleMatrix(nr_w, w_size, mxREAL);
ptr = mxGetPr(rhs[out_id]);
for(i = 0; i < w_size*nr_w; i++)
ptr[i]=model_->w[i];
out_id++;
/* Create a struct matrix contains NUM_OF_RETURN_FIELD fields */
return_model = mxCreateStructMatrix(1, 1, NUM_OF_RETURN_FIELD, field_names);
/* Fill struct matrix with input arguments */
for(i = 0; i < NUM_OF_RETURN_FIELD; i++)
mxSetField(return_model,0,field_names[i],mxDuplicateArray(rhs[i]));
/* return */
plhs[0] = return_model;
mxFree(rhs);
return NULL;
}
const char *matlab_matrix_to_model(struct model *model_, const mxArray *matlab_struct)
{
int i, num_of_fields;
int nr_w;
double *ptr;
int id = 0;
int n, w_size;
mxArray **rhs;
num_of_fields = mxGetNumberOfFields(matlab_struct);
rhs = (mxArray **) mxMalloc(sizeof(mxArray *)*num_of_fields);
for(i=0;i<num_of_fields;i++)
rhs[i] = mxGetFieldByNumber(matlab_struct, 0, i);
model_->nr_class=0;
nr_w=0;
model_->nr_feature=0;
model_->w=NULL;
model_->label=NULL;
// Parameters
ptr = mxGetPr(rhs[id]);
model_->param.solver_type = (int)ptr[0];
id++;
// nr_class
ptr = mxGetPr(rhs[id]);
model_->nr_class = (int)ptr[0];
id++;
if(model_->nr_class==2 && model_->param.solver_type != MCSVM_CS)
nr_w=1;
else
nr_w=model_->nr_class;
// nr_feature
ptr = mxGetPr(rhs[id]);
model_->nr_feature = (int)ptr[0];
id++;
// bias
ptr = mxGetPr(rhs[id]);
model_->bias = ptr[0];
id++;
if(model_->bias>=0)
n=model_->nr_feature+1;
else
n=model_->nr_feature;
w_size = n;
// Label
if(mxIsEmpty(rhs[id]) == 0)
{
model_->label = Malloc(int, model_->nr_class);
ptr = mxGetPr(rhs[id]);
for(i=0;i<model_->nr_class;i++)
model_->label[i] = (int)ptr[i];
}
id++;
ptr = mxGetPr(rhs[id]);
model_->w=Malloc(double, w_size*nr_w);
for(i = 0; i < w_size*nr_w; i++)
model_->w[i]=ptr[i];
id++;
mxFree(rhs);
return NULL;
}
| 20.045198 | 86 | 0.662627 | [
"model"
] |
7f714bc8a57cfce8c65c82e924b43bf75078f15b | 1,062 | h | C | SendBirdSDK.framework/Headers/SBDThreadInfoUpdateEvent.h | jayden-lee-sb/sendbird-ios-framework | 423ea3745c9d88009710859ff8d3d87d0a242314 | [
"BSD-3-Clause"
] | null | null | null | SendBirdSDK.framework/Headers/SBDThreadInfoUpdateEvent.h | jayden-lee-sb/sendbird-ios-framework | 423ea3745c9d88009710859ff8d3d87d0a242314 | [
"BSD-3-Clause"
] | null | null | null | SendBirdSDK.framework/Headers/SBDThreadInfoUpdateEvent.h | jayden-lee-sb/sendbird-ios-framework | 423ea3745c9d88009710859ff8d3d87d0a242314 | [
"BSD-3-Clause"
] | null | null | null | //
// SBDThreadInfoUpdateEvent.h
// SendBirdSDK
//
// Created by Jed Gyeong on 4/29/20.
// Copyright © 2020 SENDBIRD.COM. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SBDThreadInfo.h"
#import "SBDTypes.h"
/// An object that is returned through the event handler when a threaded reply is added or deleted. This object should be applied to the parent message.
/// @note This class is available from 3.0.181
@interface SBDThreadInfoUpdateEvent : NSObject
/// An object that has the information about threaded messages.
/// @since 3.0.181
@property (strong, readonly, nonnull) SBDThreadInfo *threadInfo;
/// The unique ID of the message that contains thread information.
/// @since 3.0.181
@property (atomic, readonly) long long targetMessageId;
/// The unique URL of the channel where threaded messages belong.
/// @since 3.0.181
@property (strong, readonly, nonnull) NSString *channelUrl;
/// The type of the channel where threaded messages belong.
/// @since 3.0.181
@property (atomic, readonly) SBDChannelType channelType;
@end
| 30.342857 | 152 | 0.745763 | [
"object"
] |
7f745e66b65375a0f3c43faebe592d701326e515 | 333 | h | C | common/util/os.h | LuminarLight/jak-project | f341be65e9848977158c9a9a2898f0f047a157df | [
"ISC"
] | 54 | 2022-02-08T13:07:50.000Z | 2022-03-31T14:18:42.000Z | common/util/os.h | LuminarLight/jak-project | f341be65e9848977158c9a9a2898f0f047a157df | [
"ISC"
] | 120 | 2022-02-08T05:19:11.000Z | 2022-03-30T22:26:52.000Z | common/util/os.h | LuminarLight/jak-project | f341be65e9848977158c9a9a2898f0f047a157df | [
"ISC"
] | 8 | 2022-02-13T22:39:55.000Z | 2022-03-30T02:17:57.000Z | #pragma once
#include <cstddef>
#include <string>
// Note: these are not implemented on windows and will return zero.
size_t get_peak_rss();
void setup_cpu_info();
struct CpuInfo {
bool initialized = false;
bool has_avx = false;
bool has_avx2 = false;
std::string brand;
std::string model;
};
CpuInfo& get_cpu_info();
| 16.65 | 67 | 0.714715 | [
"model"
] |
7f7575e48cde8321a401663c1ec24359813fa83f | 1,615 | h | C | src/tools/pegasus-mpi-cluster/dag.h | ahnitz/pegasus | e269b460f4d87eb3f3a7e91cd82e2c28fdb55573 | [
"Apache-2.0"
] | 127 | 2015-01-28T19:19:13.000Z | 2022-03-31T05:57:40.000Z | src/tools/pegasus-mpi-cluster/dag.h | ahnitz/pegasus | e269b460f4d87eb3f3a7e91cd82e2c28fdb55573 | [
"Apache-2.0"
] | 14 | 2015-04-15T17:44:20.000Z | 2022-02-22T22:48:49.000Z | src/tools/pegasus-mpi-cluster/dag.h | ahnitz/pegasus | e269b460f4d87eb3f3a7e91cd82e2c28fdb55573 | [
"Apache-2.0"
] | 70 | 2015-01-22T15:20:32.000Z | 2022-02-21T22:50:23.000Z | #ifndef DAG_H
#define DAG_H
#include <string>
#include <map>
#include <vector>
#include <list>
#include "tools.h"
using std::string;
using std::map;
using std::vector;
using std::list;
class Task {
public:
string name;
list<string> args;
vector<Task *> children;
vector<Task *> parents;
// This comes from the pegasus cluster arguments
string pegasus_id;
bool success;
bool io_failed;
int last_exitcode;
unsigned memory;
cpu_t cpus;
unsigned tries;
unsigned failures;
int priority;
map<string, string> *pipe_forwards;
map<string, string> *file_forwards;
unsigned submit_seq;
Task(const string &name, const list<string> &args, unsigned memory, unsigned cpus, unsigned tries, int priority, const map<string,string> &pipe_forwards, const map<string,string> &file_forwards);
~Task();
bool is_ready();
};
class DAG {
map<string, Task *> tasks;
bool lock;
int dagfd;
unsigned tries;
void read_dag(const string &filename);
void read_rescue(const string &filename);
void add_task(Task *task);
void add_edge(const string &parent, const string &child);
public:
typedef map<string, Task *>::iterator iterator;
DAG(const string &dagfile, const string &rescuefile = "", const bool lock = true, unsigned tries = 1);
~DAG();
bool has_task(const string &name) const;
Task *get_task(const string &name) const;
iterator begin() { return this->tasks.begin(); }
iterator end() { return this->tasks.end(); }
unsigned size() { return this->tasks.size(); }
};
#endif /* DAG_H */
| 23.071429 | 199 | 0.668111 | [
"vector"
] |
7f76ca7a2818f5dd2d07e9286728b108f419016a | 3,382 | c | C | src/benjie_robot_part/Benji/Kinematics.c | gonmiermu/Benjie | c0e29697519a0efcae22075cfa454e596d1be7e9 | [
"MIT"
] | null | null | null | src/benjie_robot_part/Benji/Kinematics.c | gonmiermu/Benjie | c0e29697519a0efcae22075cfa454e596d1be7e9 | [
"MIT"
] | null | null | null | src/benjie_robot_part/Benji/Kinematics.c | gonmiermu/Benjie | c0e29697519a0efcae22075cfa454e596d1be7e9 | [
"MIT"
] | null | null | null | /*
* ======= Kinematics ========
* Kinematics target-side implementation
*
* Created on: 3/11/2015
* Author: Julio
*/
#include <string.h>
#include <xdc/std.h>
#include <xdc/runtime/Startup.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/drivers/GPIO.h>
#include <xdc/runtime/Memory.h>
#include <xdc/runtime/Error.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Queue.h>
#include "Kinematics.h"
#include "Control.h"
//#include "../tcpEchoCC3100.h"
/* include Kinematics internal implementation definitions */
//#include "package/internal/Kinematics.xdc.h"
// External variables
extern int Motor1, Motor2;
extern char datos[TCPPACKETSIZE];
extern int WifiON;
extern uint8_t controlON;
char datoLocal1, datoLocal2;
volatile uint8_t actualiza_ref;
volatile uint8_t mandoON = 0,actualiza_ref = 0;
// Receiving structure
#ifdef FINAL_PROYECT
struct msg_struct tcp_msg;
#endif
#ifdef PWM_TEST
int8_t vDer, vIzq; // For debugging
#endif
/*
* ======== Kinematics_Module_startup ========
*/
Int Kinematics_Module_startup(Int state)
{
return (Startup_DONE);
}
void Kinematics_Module_Execution( void )
{
//Semaphore_post(ControlSemaphore);
Semaphore_pend(StartSemaphore1, BIOS_WAIT_FOREVER);
while(!WifiON);
while(1)
{
if(dato_rec)
{
//System_printf("Comienzo impresion"); // For debugging
//System_flush();
Semaphore_pend(WifiSemaphore, BIOS_WAIT_FOREVER); //Here data must be processed
#ifdef PWM_TEST
if(datos[0] == '0'){
_Right_Motor_Speed((float)(int8_t)datos[1]);
vDer = (int8_t)datos[1];}
else{
_Left_Motor_Speed((float)(int8_t)datos[1]);
vIzq = (int8_t)datos[1];}
#else
if(datos[0] == 2) // Options change
{
Semaphore_pend(ControlSemaphore, BIOS_WAIT_FOREVER);
controlON = datos[1];
actualiza_ref = datos[2];
mandoON = datos[3];
Semaphore_post(ControlSemaphore);
}
else if(datos[0] == 1) // Direct movement order
{
if(mandoON){
Semaphore_pend(ControlSemaphore, BIOS_WAIT_FOREVER);
_Right_Motor_Speed((float)(int8_t)datos[1]);
_Left_Motor_Speed((float)(int8_t)datos[2]);
Semaphore_post(ControlSemaphore);
}
}
else // Camera info
{
Semaphore_pend(ControlSemaphore, BIOS_WAIT_FOREVER);
tcp_msg = *(struct msg_struct *)datos;
// Store message parameters
robot.cx = ((double)tcp_msg.robot_marker.cx)/10.0;
robot.cy = ((double)tcp_msg.robot_marker.cy)/10.0;
robot.theta = ((double)tcp_msg.robot_marker.theta)/1000.0;
if (tcp_msg.type == 4)
{
ref.cx = ((double)tcp_msg.ref_marker.cx)/10.0;
ref.cy = ((double)tcp_msg.ref_marker.cy)/10.0;
ref.theta = ((double)tcp_msg.ref_marker.theta)/1000.0;
actualiza_ref = 0; // Reference is now actualized
}
Semaphore_post(ControlSemaphore);
}
#endif
Semaphore_post(WifiSemaphore);
dato_rec = 0;
}
}
}
#ifdef Kinematics_Object
/*
* ======== Kinematics_Instance_init ========
* Kinematics created or constructed instance object initialization
*/
Void Kinematics_Instance_init(Kinematics_Object *obj, const Kinematics_Params *params)
{
/* TODO: initialize Kinematics instance state fields */
}
#endif
| 26.015385 | 87 | 0.669722 | [
"object"
] |
7f772dc665910fa0c5db8041df634718b4caa7b3 | 1,331 | h | C | include/icp/icp_yogo.h | FaiScofield/csm | 5850a70abd26c2a848cc36d7011e1b75dbdaab3e | [
"MIT"
] | 7 | 2019-06-17T09:31:03.000Z | 2022-03-29T00:58:40.000Z | include/icp/icp_yogo.h | FaiScofield/csm | 5850a70abd26c2a848cc36d7011e1b75dbdaab3e | [
"MIT"
] | null | null | null | include/icp/icp_yogo.h | FaiScofield/csm | 5850a70abd26c2a848cc36d7011e1b75dbdaab3e | [
"MIT"
] | null | null | null | #ifndef _PL_ICP_
#define _PL_ICP_
#include <vector>
#include "csm/csm_all.h"
#include "csm/utils.h"
/**
* @brief set_plicp_params 设置icp运行的参数
* @param[out] params icp运行的参数
*
* 线上使用,此法已经被写到机器人的icp线程里,参数在主线程里设置
*/
void set_plicp_params(sm_params* params);
/**
* @brief get_global_pose get robot global position
* @param[out] global_pos 当前帧的全局位姿
* @param[in] gp_ref 参考帧的全局位姿
* @param[in] delta_trans 两帧点云间的相对位姿变换
*/
void get_global_pose(double* global_pos, const double* gp_ref, const double* delta_trans);
/**
* @brief valid_transform 判断相对变换是否正确
* @param params 相关参数
* @param delta_trans 相对变换
* @return 相对变换过大时返回false
*
* 相对变换小于阈值时会设为0变换,防止静置漂移
*/
bool valid_transform(sm_params* const params, double* delta_trans);
/**
* @brief valid_odometry 判断两帧间的里程差值是否合理
* @param[in] params 相关参数
* @param[in] delta_odom 两帧间的里程差值
* @return 里程差值过大时返回false
*
* 主要是判断是否有跳帧丢帧和imu数值突变的现象
*/
bool valid_odometry(const sm_params* params, const double* delta_odom);
/**
* @brief set_first_guess 设置icp初始变换的估计,以减少迭代次数
* @param[in/out] params 相关参数
*/
void set_first_guess(sm_params* params);
/**
* @brief valid_time_stamp 判断两帧间的时间戳是否合理
* @param[in] params 相关参数
* @return 时间戳相隔1秒一上返回false
*
* 主要是判断是否有跳帧丢帧的现象
*/
bool valid_time_stamp(const sm_params* params);
#endif
| 21.467742 | 90 | 0.7145 | [
"vector"
] |
7f7a22da443b7cbac3bd5f6ae76020590c55f609 | 1,190 | h | C | inc/core/electrodeRenderer3D.h | BetaRavener/BrainActivityVisualizer | baf61856d67fbe31880bc4c6610621142777ac19 | [
"BSD-3-Clause"
] | null | null | null | inc/core/electrodeRenderer3D.h | BetaRavener/BrainActivityVisualizer | baf61856d67fbe31880bc4c6610621142777ac19 | [
"BSD-3-Clause"
] | null | null | null | inc/core/electrodeRenderer3D.h | BetaRavener/BrainActivityVisualizer | baf61856d67fbe31880bc4c6610621142777ac19 | [
"BSD-3-Clause"
] | 1 | 2021-07-12T00:49:41.000Z | 2021-07-12T00:49:41.000Z | // Author: Ivan Sevcik <ivan-sevcik@hotmail.com>
// Licensed under BSD 3-Clause License (see licenses/LICENSE.txt)
#ifndef ELECTRODE_RENDERER_3D_H
#define ELECTRODE_RENDERER_3D_H
#include <vector>
#include <UniShader/UniShader.h>
#include "electrodeRenderer.h"
/**
* @brief The ElectrodeRenderer2D class is a specific class for rendering electrodes in 3D.
*/
class ElectrodeRenderer3D : public ElectrodeRenderer
{
public:
ElectrodeRenderer3D();
/**
* @brief Updates the rendering configuration.
* @param eyePos New camera position.
* @param upDir Up vector of the camera.
* @param rightDir Right vector of the camera.
* @param mvpMatrix ModelViewProjection matrix.
*/
void update(glm::vec3 eyePos, glm::vec3 upDir, glm::vec3 rightDir, glm::mat4 mvpMatrix);
private:
virtual void initializeShaders();
virtual void prepareColorBuffer();
virtual void updateElectrodes();
virtual bool electrodePresent(Electrode::WeakPtr electrode);
// Attributes
us::Attribute::Ptr _electrodePosAttr;
// Uniforms
us::Uniform::Ptr _radiusUnif;
us::Uniform::Ptr _eyePosUnif;
us::Uniform::Ptr _mvpMatrixUnif;
};
#endif
| 25.869565 | 92 | 0.721008 | [
"vector",
"3d"
] |
7f7c11ec7a277b5270827aa5957bc6f0e111788c | 23,666 | c | C | src/modules/headset/openvr.c | porglezomp-misc/lovr | 7ca23bc58a065c4be05af0a2717ee83bc501ecee | [
"MIT"
] | null | null | null | src/modules/headset/openvr.c | porglezomp-misc/lovr | 7ca23bc58a065c4be05af0a2717ee83bc501ecee | [
"MIT"
] | null | null | null | src/modules/headset/openvr.c | porglezomp-misc/lovr | 7ca23bc58a065c4be05af0a2717ee83bc501ecee | [
"MIT"
] | null | null | null | #include "headset/headset.h"
#include "resources/actions.json.h"
#include "resources/bindings_vive.json.h"
#include "resources/bindings_knuckles.json.h"
#include "resources/bindings_touch.json.h"
#include "event/event.h"
#include "filesystem/filesystem.h"
#include "graphics/graphics.h"
#include "graphics/canvas.h"
#include "core/maf.h"
#include "core/os.h"
#include "core/ref.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#undef EXTERN_C
#include <openvr_capi.h>
// From openvr_capi.h
extern intptr_t VR_InitInternal(EVRInitError *peError, EVRApplicationType eType);
extern void VR_ShutdownInternal();
extern bool VR_IsHmdPresent();
extern intptr_t VR_GetGenericInterface(const char* pchInterfaceVersion, EVRInitError* peError);
extern bool VR_IsRuntimeInstalled();
#define HEADSET k_unTrackedDeviceIndex_Hmd
#define INVALID_DEVICE k_unTrackedDeviceIndexInvalid
static struct {
struct VR_IVRSystem_FnTable* system;
struct VR_IVRCompositor_FnTable* compositor;
struct VR_IVRChaperone_FnTable* chaperone;
struct VR_IVRRenderModels_FnTable* renderModels;
struct VR_IVRInput_FnTable* input;
VRActionSetHandle_t actionSet;
VRActionHandle_t poseActions[MAX_DEVICES];
VRActionHandle_t buttonActions[2][MAX_BUTTONS];
VRActionHandle_t touchActions[2][MAX_BUTTONS];
VRActionHandle_t axisActions[2][MAX_AXES];
VRActionHandle_t skeletonActions[2];
VRActionHandle_t hapticActions[2];
TrackedDevicePose_t headPose;
RenderModel_t* deviceModels[16];
RenderModel_TextureMap_t* deviceTextures[16];
Canvas* canvas;
float* mask;
float boundsGeometry[16];
float clipNear;
float clipFar;
float offset;
int msaa;
} state;
static TrackedDeviceIndex_t getDeviceIndex(Device device) {
switch (device) {
case DEVICE_HEAD: return HEADSET;
case DEVICE_HAND_LEFT: return state.system->GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole_TrackedControllerRole_LeftHand);
case DEVICE_HAND_RIGHT: return state.system->GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole_TrackedControllerRole_RightHand);
default: return INVALID_DEVICE;
}
}
static bool openvr_getName(char* name, size_t length);
static bool openvr_init(float offset, uint32_t msaa) {
if (!VR_IsHmdPresent() || !VR_IsRuntimeInstalled()) {
return false;
}
EVRInitError vrError;
VR_InitInternal(&vrError, EVRApplicationType_VRApplication_Scene);
if (vrError != EVRInitError_VRInitError_None) {
return false;
}
char buffer[64];
sprintf(buffer, "FnTable:%s", IVRSystem_Version), state.system = (struct VR_IVRSystem_FnTable*) VR_GetGenericInterface(buffer, &vrError);
sprintf(buffer, "FnTable:%s", IVRCompositor_Version), state.compositor = (struct VR_IVRCompositor_FnTable*) VR_GetGenericInterface(buffer, &vrError);
sprintf(buffer, "FnTable:%s", IVRChaperone_Version), state.chaperone = (struct VR_IVRChaperone_FnTable*) VR_GetGenericInterface(buffer, &vrError);
sprintf(buffer, "FnTable:%s", IVRRenderModels_Version), state.renderModels = (struct VR_IVRRenderModels_FnTable*) VR_GetGenericInterface(buffer, &vrError);
sprintf(buffer, "FnTable:%s", IVRInput_Version), state.input = (struct VR_IVRInput_FnTable*) VR_GetGenericInterface(buffer, &vrError);
if (!state.system || !state.compositor || !state.chaperone || !state.renderModels || !state.input) {
VR_ShutdownInternal();
return false;
}
// Find the location of the action manifest, create it if it doesn't exist or isn't in the save directory
const char* actionManifestLocation = lovrFilesystemGetRealDirectory("actions.json");
if (!actionManifestLocation || strcmp(actionManifestLocation, lovrFilesystemGetSaveDirectory())) {
if (
lovrFilesystemWrite("actions.json", (const char*) src_resources_actions_json, src_resources_actions_json_len, false) != src_resources_actions_json_len ||
lovrFilesystemWrite("bindings_vive.json", (const char*) src_resources_bindings_vive_json, src_resources_bindings_vive_json_len, false) != src_resources_bindings_vive_json_len ||
lovrFilesystemWrite("bindings_knuckles.json", (const char*) src_resources_bindings_knuckles_json, src_resources_bindings_knuckles_json_len, false) != src_resources_bindings_knuckles_json_len ||
lovrFilesystemWrite("bindings_touch.json", (const char*) src_resources_bindings_touch_json, src_resources_bindings_touch_json_len, false) != src_resources_bindings_touch_json_len
) {
VR_ShutdownInternal();
return false;
}
}
char path[LOVR_PATH_MAX];
snprintf(path, sizeof(path), "%s%cactions.json", lovrFilesystemGetSaveDirectory(), LOVR_PATH_SEP);
state.input->SetActionManifestPath(path);
state.input->GetActionSetHandle("/actions/lovr", &state.actionSet);
state.input->GetActionHandle("/actions/lovr/in/headPose", &state.poseActions[DEVICE_HEAD]);
state.input->GetActionHandle("/actions/lovr/in/leftHandPose", &state.poseActions[DEVICE_HAND_LEFT]);
state.input->GetActionHandle("/actions/lovr/in/rightHandPose", &state.poseActions[DEVICE_HAND_RIGHT]);
state.input->GetActionHandle("/actions/lovr/in/leftTriggerDown", &state.buttonActions[0][BUTTON_TRIGGER]);
state.input->GetActionHandle("/actions/lovr/in/leftThumbstickDown", &state.buttonActions[0][BUTTON_THUMBSTICK]);
state.input->GetActionHandle("/actions/lovr/in/leftTouchpadDown", &state.buttonActions[0][BUTTON_TOUCHPAD]);
state.input->GetActionHandle("/actions/lovr/in/leftGripDown", &state.buttonActions[0][BUTTON_GRIP]);
state.input->GetActionHandle("/actions/lovr/in/leftMenuDown", &state.buttonActions[0][BUTTON_MENU]);
state.input->GetActionHandle("/actions/lovr/in/leftADown", &state.buttonActions[0][BUTTON_A]);
state.input->GetActionHandle("/actions/lovr/in/leftBDown", &state.buttonActions[0][BUTTON_B]);
state.input->GetActionHandle("/actions/lovr/in/leftXDown", &state.buttonActions[0][BUTTON_X]);
state.input->GetActionHandle("/actions/lovr/in/leftYDown", &state.buttonActions[0][BUTTON_Y]);
state.input->GetActionHandle("/actions/lovr/in/rightTriggerDown", &state.buttonActions[1][BUTTON_TRIGGER]);
state.input->GetActionHandle("/actions/lovr/in/rightThumbstickDown", &state.buttonActions[1][BUTTON_THUMBSTICK]);
state.input->GetActionHandle("/actions/lovr/in/rightTouchpadDown", &state.buttonActions[1][BUTTON_TOUCHPAD]);
state.input->GetActionHandle("/actions/lovr/in/rightGripDown", &state.buttonActions[1][BUTTON_GRIP]);
state.input->GetActionHandle("/actions/lovr/in/rightMenuDown", &state.buttonActions[1][BUTTON_MENU]);
state.input->GetActionHandle("/actions/lovr/in/rightADown", &state.buttonActions[1][BUTTON_A]);
state.input->GetActionHandle("/actions/lovr/in/rightBDown", &state.buttonActions[1][BUTTON_B]);
state.input->GetActionHandle("/actions/lovr/in/rightXDown", &state.buttonActions[1][BUTTON_X]);
state.input->GetActionHandle("/actions/lovr/in/rightYDown", &state.buttonActions[1][BUTTON_Y]);
state.input->GetActionHandle("/actions/lovr/in/leftTriggerTouch", &state.touchActions[0][BUTTON_TRIGGER]);
state.input->GetActionHandle("/actions/lovr/in/leftThumbstickTouch", &state.touchActions[0][BUTTON_THUMBSTICK]);
state.input->GetActionHandle("/actions/lovr/in/leftTouchpadTouch", &state.touchActions[0][BUTTON_TOUCHPAD]);
state.input->GetActionHandle("/actions/lovr/in/leftGripTouch", &state.touchActions[0][BUTTON_GRIP]);
state.input->GetActionHandle("/actions/lovr/in/leftMenuTouch", &state.touchActions[0][BUTTON_MENU]);
state.input->GetActionHandle("/actions/lovr/in/leftATouch", &state.touchActions[0][BUTTON_A]);
state.input->GetActionHandle("/actions/lovr/in/leftBTouch", &state.touchActions[0][BUTTON_B]);
state.input->GetActionHandle("/actions/lovr/in/leftXTouch", &state.touchActions[0][BUTTON_X]);
state.input->GetActionHandle("/actions/lovr/in/leftYTouch", &state.touchActions[0][BUTTON_Y]);
state.input->GetActionHandle("/actions/lovr/in/rightTriggerTouch", &state.touchActions[1][BUTTON_TRIGGER]);
state.input->GetActionHandle("/actions/lovr/in/rightThumbstickTouch", &state.touchActions[1][BUTTON_THUMBSTICK]);
state.input->GetActionHandle("/actions/lovr/in/rightTouchpadTouch", &state.touchActions[1][BUTTON_TOUCHPAD]);
state.input->GetActionHandle("/actions/lovr/in/rightGripTouch", &state.touchActions[1][BUTTON_GRIP]);
state.input->GetActionHandle("/actions/lovr/in/rightMenuTouch", &state.touchActions[1][BUTTON_MENU]);
state.input->GetActionHandle("/actions/lovr/in/rightATouch", &state.touchActions[1][BUTTON_A]);
state.input->GetActionHandle("/actions/lovr/in/rightBTouch", &state.touchActions[1][BUTTON_B]);
state.input->GetActionHandle("/actions/lovr/in/rightXTouch", &state.touchActions[1][BUTTON_X]);
state.input->GetActionHandle("/actions/lovr/in/rightYTouch", &state.touchActions[1][BUTTON_Y]);
state.input->GetActionHandle("/actions/lovr/in/leftTriggerAxis", &state.axisActions[0][AXIS_TRIGGER]);
state.input->GetActionHandle("/actions/lovr/in/leftThumbstickAxis", &state.axisActions[0][AXIS_THUMBSTICK]);
state.input->GetActionHandle("/actions/lovr/in/leftTouchpadAxis", &state.axisActions[0][AXIS_TOUCHPAD]);
state.input->GetActionHandle("/actions/lovr/in/leftGripAxis", &state.axisActions[0][AXIS_GRIP]);
state.input->GetActionHandle("/actions/lovr/in/rightTriggerAxis", &state.axisActions[1][AXIS_TRIGGER]);
state.input->GetActionHandle("/actions/lovr/in/rightThumbstickAxis", &state.axisActions[1][AXIS_THUMBSTICK]);
state.input->GetActionHandle("/actions/lovr/in/rightTouchpadAxis", &state.axisActions[1][AXIS_TOUCHPAD]);
state.input->GetActionHandle("/actions/lovr/in/rightGripAxis", &state.axisActions[1][AXIS_GRIP]);
state.input->GetActionHandle("/actions/lovr/in/leftHandSkeleton", &state.skeletonActions[0]);
state.input->GetActionHandle("/actions/lovr/in/rightHandSkeleton", &state.skeletonActions[1]);
state.input->GetActionHandle("/actions/lovr/out/leftHandBZZ", &state.hapticActions[0]);
state.input->GetActionHandle("/actions/lovr/out/rightHandBZZ", &state.hapticActions[1]);
state.clipNear = 0.1f;
state.clipFar = 30.f;
state.offset = state.compositor->GetTrackingSpace() == ETrackingUniverseOrigin_TrackingUniverseStanding ? 0. : offset;
state.msaa = msaa;
return true;
}
static void openvr_destroy(void) {
lovrRelease(Canvas, state.canvas);
for (int i = 0; i < 16; i++) {
if (state.deviceModels[i]) {
state.renderModels->FreeRenderModel(state.deviceModels[i]);
}
if (state.deviceTextures[i]) {
state.renderModels->FreeTexture(state.deviceTextures[i]);
}
state.deviceModels[i] = NULL;
state.deviceTextures[i] = NULL;
}
VR_ShutdownInternal();
free(state.mask);
memset(&state, 0, sizeof(state));
}
static bool openvr_getName(char* name, size_t length) {
ETrackedPropertyError error;
state.system->GetStringTrackedDeviceProperty(HEADSET, ETrackedDeviceProperty_Prop_ManufacturerName_String, name, (uint32_t) length, &error);
return error == ETrackedPropertyError_TrackedProp_Success;
}
static HeadsetOrigin openvr_getOriginType(void) {
switch (state.compositor->GetTrackingSpace()) {
case ETrackingUniverseOrigin_TrackingUniverseSeated: return ORIGIN_HEAD;
case ETrackingUniverseOrigin_TrackingUniverseStanding: return ORIGIN_FLOOR;
default: return ORIGIN_HEAD;
}
}
static void openvr_getDisplayDimensions(uint32_t* width, uint32_t* height) {
state.system->GetRecommendedRenderTargetSize(width, height);
}
static float openvr_getDisplayFrequency() {
return state.system->GetFloatTrackedDeviceProperty(HEADSET, ETrackedDeviceProperty_Prop_DisplayFrequency_Float, NULL);
}
static const float* openvr_getDisplayMask(uint32_t* count) {
struct HiddenAreaMesh_t hiddenAreaMesh = state.system->GetHiddenAreaMesh(EVREye_Eye_Left, EHiddenAreaMeshType_k_eHiddenAreaMesh_Standard);
if (hiddenAreaMesh.unTriangleCount == 0) {
*count = 0;
return NULL;
}
state.mask = realloc(state.mask, hiddenAreaMesh.unTriangleCount * 3 * 2 * sizeof(float));
lovrAssert(state.mask, "Out of memory");
for (uint32_t i = 0; i < 3 * hiddenAreaMesh.unTriangleCount; i++) {
state.mask[2 * i + 0] = hiddenAreaMesh.pVertexData[i].v[0];
state.mask[2 * i + 1] = hiddenAreaMesh.pVertexData[i].v[1];
}
*count = hiddenAreaMesh.unTriangleCount * 3 * 2;
return state.mask;
}
static double openvr_getDisplayTime(void) {
float secondsSinceVsync;
state.system->GetTimeSinceLastVsync(&secondsSinceVsync, NULL);
float frequency = openvr_getDisplayFrequency();
float frameDuration = 1.f / frequency;
float vsyncToPhotons = state.system->GetFloatTrackedDeviceProperty(HEADSET, ETrackedDeviceProperty_Prop_SecondsFromVsyncToPhotons_Float, NULL);
return lovrPlatformGetTime() + (double) (frameDuration - secondsSinceVsync + vsyncToPhotons);
}
static void openvr_getClipDistance(float* clipNear, float* clipFar) {
*clipNear = state.clipNear;
*clipFar = state.clipFar;
}
static void openvr_setClipDistance(float clipNear, float clipFar) {
state.clipNear = clipNear;
state.clipFar = clipFar;
}
static void openvr_getBoundsDimensions(float* width, float* depth) {
state.chaperone->GetPlayAreaSize(width, depth);
}
static const float* openvr_getBoundsGeometry(uint32_t* count) {
struct HmdQuad_t quad;
if (state.chaperone->GetPlayAreaRect(&quad)) {
for (int i = 0; i < 4; i++) {
state.boundsGeometry[4 * i + 0] = quad.vCorners[i].v[0];
state.boundsGeometry[4 * i + 1] = quad.vCorners[i].v[1];
state.boundsGeometry[4 * i + 2] = quad.vCorners[i].v[2];
}
*count = 16;
return state.boundsGeometry;
}
return NULL;
}
static bool openvr_getPose(Device device, vec3 position, quat orientation) {
InputPoseActionData_t actionData;
TrackedDevicePose_t* pose;
if (device == DEVICE_HEAD) {
pose = &state.headPose;
} else if (device == DEVICE_HAND_LEFT || device == DEVICE_HAND_RIGHT) {
state.input->GetPoseActionData(state.poseActions[device], state.compositor->GetTrackingSpace(), 0.f, &actionData, sizeof(actionData), 0);
pose = &actionData.pose;
} else {
return false;
}
float transform[16];
mat4_fromMat34(transform, pose->mDeviceToAbsoluteTracking.m);
mat4_getPosition(transform, position);
mat4_getOrientation(transform, orientation);
transform[13] += state.offset;
return pose->bPoseIsValid;
}
static bool openvr_getVelocity(Device device, vec3 velocity, vec3 angularVelocity) {
InputPoseActionData_t actionData;
TrackedDevicePose_t* pose;
if (device == DEVICE_HEAD) {
pose = &state.headPose;
} else if (device == DEVICE_HAND_LEFT || device == DEVICE_HAND_RIGHT) {
state.input->GetPoseActionData(state.poseActions[device], state.compositor->GetTrackingSpace(), 0.f, &actionData, sizeof(actionData), 0);
pose = &actionData.pose;
} else {
return false;
}
vec3_init(velocity, pose->vVelocity.v);
vec3_init(angularVelocity, pose->vAngularVelocity.v);
return pose->bPoseIsValid;
}
static bool openvr_isDown(Device device, DeviceButton button, bool* down, bool* changed) {
if (device != DEVICE_HAND_LEFT && device != DEVICE_HAND_RIGHT) {
return false;
}
InputDigitalActionData_t actionData;
state.input->GetDigitalActionData(state.buttonActions[device - DEVICE_HAND_LEFT][button], &actionData, sizeof(actionData), 0);
*down = actionData.bState;
*changed = actionData.bChanged;
return actionData.bActive;
}
static bool openvr_isTouched(Device device, DeviceButton button, bool* touched) {
if (device != DEVICE_HAND_LEFT && device != DEVICE_HAND_RIGHT) {
return false;
}
InputDigitalActionData_t actionData;
state.input->GetDigitalActionData(state.touchActions[device - DEVICE_HAND_LEFT][button], &actionData, sizeof(actionData), 0);
*touched = actionData.bState;
return actionData.bActive;
}
static bool openvr_getAxis(Device device, DeviceAxis axis, vec3 value) {
if (device != DEVICE_HAND_LEFT && device != DEVICE_HAND_RIGHT) {
return false;
}
InputAnalogActionData_t actionData;
state.input->GetAnalogActionData(state.axisActions[device - DEVICE_HAND_LEFT][axis], &actionData, sizeof(actionData), 0);
vec3_set(value, actionData.x, actionData.y, actionData.z);
return actionData.bActive;
}
static bool openvr_vibrate(Device device, float strength, float duration, float frequency) {
if (duration <= 0.f || (device != DEVICE_HAND_LEFT && device != DEVICE_HAND_RIGHT)) return false;
if (frequency <= 0.f) {
frequency = 1.f;
}
state.input->TriggerHapticVibrationAction(state.hapticActions[device - DEVICE_HAND_LEFT], 0.f, duration, frequency, strength, 0);
return true;
}
static ModelData* openvr_newModelData(Device device) {
TrackedDeviceIndex_t index = getDeviceIndex(device);
if (index == INVALID_DEVICE) return false;
char renderModelName[1024];
ETrackedDeviceProperty renderModelNameProperty = ETrackedDeviceProperty_Prop_RenderModelName_String;
state.system->GetStringTrackedDeviceProperty(index, renderModelNameProperty, renderModelName, 1024, NULL);
if (!state.deviceModels[index]) {
while (state.renderModels->LoadRenderModel_Async(renderModelName, &state.deviceModels[index]) == EVRRenderModelError_VRRenderModelError_Loading) {
lovrPlatformSleep(.001);
}
}
if (!state.deviceTextures[index]) {
while (state.renderModels->LoadTexture_Async(state.deviceModels[index]->diffuseTextureId, &state.deviceTextures[index]) == EVRRenderModelError_VRRenderModelError_Loading) {
lovrPlatformSleep(.001);
}
}
RenderModel_t* vrModel = state.deviceModels[index];
ModelData* model = lovrAlloc(ModelData);
size_t vertexSize = sizeof(RenderModel_Vertex_t);
model->bufferCount = 2;
model->attributeCount = 4;
model->textureCount = 1;
model->materialCount = 1;
model->primitiveCount = 1;
model->nodeCount = 1;
lovrModelDataAllocate(model);
model->buffers[0] = (ModelBuffer) {
.data = (char*) vrModel->rVertexData,
.size = vrModel->unVertexCount * vertexSize,
.stride = vertexSize
};
model->buffers[1] = (ModelBuffer) {
.data = (char*) vrModel->rIndexData,
.size = vrModel->unTriangleCount * 3 * sizeof(uint16_t),
.stride = sizeof(uint16_t)
};
model->attributes[0] = (ModelAttribute) {
.buffer = 0,
.offset = offsetof(RenderModel_Vertex_t, vPosition),
.count = vrModel->unVertexCount,
.type = F32,
.components = 3
};
model->attributes[1] = (ModelAttribute) {
.buffer = 0,
.offset = offsetof(RenderModel_Vertex_t, vNormal),
.count = vrModel->unVertexCount,
.type = F32,
.components = 3
};
model->attributes[2] = (ModelAttribute) {
.buffer = 0,
.offset = offsetof(RenderModel_Vertex_t, rfTextureCoord),
.count = vrModel->unVertexCount,
.type = F32,
.components = 2
};
model->attributes[3] = (ModelAttribute) {
.buffer = 1,
.offset = 0,
.count = vrModel->unTriangleCount * 3,
.type = U16,
.components = 1
};
RenderModel_TextureMap_t* vrTexture = state.deviceTextures[index];
model->textures[0] = lovrTextureDataCreate(vrTexture->unWidth, vrTexture->unHeight, 0, FORMAT_RGBA);
memcpy(model->textures[0]->blob->data, vrTexture->rubTextureMapData, vrTexture->unWidth * vrTexture->unHeight * 4);
model->materials[0] = (ModelMaterial) {
.colors[COLOR_DIFFUSE] = { 1.f, 1.f, 1.f, 1.f },
.textures[TEXTURE_DIFFUSE] = 0,
.filters[TEXTURE_DIFFUSE] = lovrGraphicsGetDefaultFilter()
};
model->primitives[0] = (ModelPrimitive) {
.mode = DRAW_TRIANGLES,
.attributes = {
[ATTR_POSITION] = &model->attributes[0],
[ATTR_NORMAL] = &model->attributes[1],
[ATTR_TEXCOORD] = &model->attributes[2]
},
.indices = &model->attributes[3],
.material = 0
};
model->nodes[0] = (ModelNode) {
.transform = MAT4_IDENTITY,
.primitiveIndex = 0,
.primitiveCount = 1,
.skin = ~0u,
.matrix = true
};
return model;
}
static void openvr_renderTo(void (*callback)(void*), void* userdata) {
if (!state.canvas) {
uint32_t width, height;
state.system->GetRecommendedRenderTargetSize(&width, &height);
CanvasFlags flags = { .depth = { true, false, FORMAT_D24S8 }, .stereo = true, .mipmaps = true, .msaa = state.msaa };
state.canvas = lovrCanvasCreate(width, height, flags);
Texture* texture = lovrTextureCreate(TEXTURE_2D, NULL, 0, true, true, state.msaa);
lovrTextureAllocate(texture, width * 2, height, 1, FORMAT_RGBA);
lovrTextureSetFilter(texture, lovrGraphicsGetDefaultFilter());
lovrCanvasSetAttachments(state.canvas, &(Attachment) { texture, 0, 0 }, 1);
lovrRelease(Texture, texture);
lovrPlatformSetSwapInterval(0);
}
Camera camera = { .canvas = state.canvas, .viewMatrix = { MAT4_IDENTITY, MAT4_IDENTITY } };
float head[16], eye[16];
mat4_fromMat34(head, state.headPose.mDeviceToAbsoluteTracking.m);
for (int i = 0; i < 2; i++) {
EVREye vrEye = (i == 0) ? EVREye_Eye_Left : EVREye_Eye_Right;
mat4_fromMat44(camera.projection[i], state.system->GetProjectionMatrix(vrEye, state.clipNear, state.clipFar).m);
mat4_multiply(camera.viewMatrix[i], head);
mat4_multiply(camera.viewMatrix[i], mat4_fromMat34(eye, state.system->GetEyeToHeadTransform(vrEye).m));
mat4_invert(camera.viewMatrix[i]);
}
lovrGraphicsSetCamera(&camera, true);
callback(userdata);
lovrGraphicsSetCamera(NULL, false);
// Submit
const Attachment* attachments = lovrCanvasGetAttachments(state.canvas, NULL);
ptrdiff_t id = attachments[0].texture->id;
Texture_t eyeTexture = { (void*) id, ETextureType_TextureType_OpenGL, EColorSpace_ColorSpace_Linear };
VRTextureBounds_t left = { 0.f, 0.f, .5f, 1.f };
VRTextureBounds_t right = { .5f, 0.f, 1.f, 1.f };
state.compositor->Submit(EVREye_Eye_Left, &eyeTexture, &left, EVRSubmitFlags_Submit_Default);
state.compositor->Submit(EVREye_Eye_Right, &eyeTexture, &right, EVRSubmitFlags_Submit_Default);
lovrGpuDirtyTexture();
}
static Texture* openvr_getMirrorTexture(void) {
return lovrCanvasGetAttachments(state.canvas, NULL)[0].texture;
}
static void openvr_update(float dt) {
state.compositor->WaitGetPoses(&state.headPose, 1, NULL, 0);
VRActiveActionSet_t activeActionSet = { .ulActionSet = state.actionSet };
state.input->UpdateActionState(&activeActionSet, sizeof(activeActionSet), 1);
struct VREvent_t vrEvent;
while (state.system->PollNextEvent(&vrEvent, sizeof(vrEvent))) {
switch (vrEvent.eventType) {
case EVREventType_VREvent_InputFocusCaptured:
case EVREventType_VREvent_InputFocusReleased: {
bool isFocused = vrEvent.eventType == EVREventType_VREvent_InputFocusReleased;
lovrEventPush((Event) { .type = EVENT_FOCUS, .data.boolean = { isFocused } });
break;
}
default: break;
}
}
}
HeadsetInterface lovrHeadsetOpenVRDriver = {
.driverType = DRIVER_OPENVR,
.init = openvr_init,
.destroy = openvr_destroy,
.getName = openvr_getName,
.getOriginType = openvr_getOriginType,
.getDisplayDimensions = openvr_getDisplayDimensions,
.getDisplayFrequency = openvr_getDisplayFrequency,
.getDisplayMask = openvr_getDisplayMask,
.getDisplayTime = openvr_getDisplayTime,
.getClipDistance = openvr_getClipDistance,
.setClipDistance = openvr_setClipDistance,
.getBoundsDimensions = openvr_getBoundsDimensions,
.getBoundsGeometry = openvr_getBoundsGeometry,
.getPose = openvr_getPose,
.getVelocity = openvr_getVelocity,
.isDown = openvr_isDown,
.isTouched = openvr_isTouched,
.getAxis = openvr_getAxis,
.vibrate = openvr_vibrate,
.newModelData = openvr_newModelData,
.renderTo = openvr_renderTo,
.getMirrorTexture = openvr_getMirrorTexture,
.update = openvr_update
};
| 42.412186 | 199 | 0.750866 | [
"model",
"transform"
] |
7f7e6e853190c9ae72808ef758c40207660731e1 | 3,247 | h | C | libs/io/include/mrpt/io/CTextFileLinesParser.h | swt2c/mrpt | 9b4fd246530ff94bb93f5703e61844c6f67aa0b9 | [
"BSD-3-Clause"
] | null | null | null | libs/io/include/mrpt/io/CTextFileLinesParser.h | swt2c/mrpt | 9b4fd246530ff94bb93f5703e61844c6f67aa0b9 | [
"BSD-3-Clause"
] | null | null | null | libs/io/include/mrpt/io/CTextFileLinesParser.h | swt2c/mrpt | 9b4fd246530ff94bb93f5703e61844c6f67aa0b9 | [
"BSD-3-Clause"
] | 1 | 2020-12-30T14:06:37.000Z | 2020-12-30T14:06:37.000Z | /* +------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| https://www.mrpt.org/ |
| |
| Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
| See: https://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See: https://www.mrpt.org/License |
+------------------------------------------------------------------------+ */
#pragma once
#include <fstream>
#include <iosfwd>
#include <memory>
#include <string>
namespace mrpt::io
{
/** A class for parsing text files, returning each non-empty and non-comment
* line, along its line number. Lines are strip out of leading and trailing
* whitespaces. By default, lines starting with either "#", "//" or "%" are
* skipped as comment lines, unless this behavior is explicitly disabled with
* \a enableCommentFilters.
* \ingroup mrpt_io_grp
*/
class CTextFileLinesParser
{
public:
/** Default constructor; should call \a open() at some moment later. */
CTextFileLinesParser() = default;
/** Constructor for opening a file \exception std::exception On error
* opening file */
explicit CTextFileLinesParser(const std::string& filename);
/** Constructor for reading from a generic std::istream. Note that a
* reference to the stream is stored in the object, so it's the user
* responsibility to make sure the stream is not destroyed before than
* this object.
*/
explicit CTextFileLinesParser(std::istream& in);
/** Open a file (an alternative to the constructor with a file name) */
void open(const std::string& fil);
/** Opens for reading a generic std::istream. Note that a
* reference to the stream is stored in the object, so it's the user
* responsibility to make sure the stream is not destroyed before than
* this object.
*/
void open(std::istream& in);
/** Close the file (no need to call it normally, the file is closed upon
* destruction) */
void close();
/** Reset the read pointer to the beginning of the file */
void rewind();
/** Reads from the file and return the next (non-comment) line, as a
* std::string
* \return false on EOF.
*/
bool getNextLine(std::string& out_str);
/** Reads from the file and stores the next (non-comment) line into the
* given stream buffer.
* \return false on EOF.
*/
bool getNextLine(std::istringstream& buf);
/** Return the line number of the last line returned with \a getNextLine */
size_t getCurrentLineNumber() const;
/** Enable/disable filtering of lines starting with "%", "//" or "#",
* respectively. */
void enableCommentFilters(
bool filter_MATLAB_comments, bool filter_C_comments,
bool filter_SH_comments);
private:
std::string m_fileName;
/** Points to either a user-owned object, or to m_my_in */
std::istream* m_in{nullptr};
std::shared_ptr<std::istream> m_my_in;
size_t m_curLineNum{0};
bool m_filter_MATLAB_comments{true};
bool m_filter_C_comments{true};
bool m_filter_SH_comments{true};
}; // end of CTextFileLinesParser
} // namespace mrpt::io
| 36.077778 | 80 | 0.639051 | [
"object"
] |
7f80bb354f9c53b1642574b8d506f5ac4de43628 | 39,778 | h | C | Source/GeneratedServices/Blogger/GTLRBloggerQuery.h | sundaleek/google-api-objectivec-client-for-rest | 6805d088b1b4cc0b631637c28aa451308a81dd57 | [
"Apache-2.0"
] | 2 | 2020-10-18T14:10:13.000Z | 2021-05-21T17:22:20.000Z | Source/GeneratedServices/Blogger/GTLRBloggerQuery.h | sundaleek/google-api-objectivec-client-for-rest | 6805d088b1b4cc0b631637c28aa451308a81dd57 | [
"Apache-2.0"
] | null | null | null | Source/GeneratedServices/Blogger/GTLRBloggerQuery.h | sundaleek/google-api-objectivec-client-for-rest | 6805d088b1b4cc0b631637c28aa451308a81dd57 | [
"Apache-2.0"
] | 2 | 2020-12-26T20:56:21.000Z | 2022-02-07T21:05:20.000Z | // NOTE: This file was generated by the ServiceGenerator.
// ----------------------------------------------------------------------------
// API:
// Blogger API v3 (blogger/v3)
// Description:
// The Blogger API provides access to posts, comments and pages of a Blogger
// blog.
// Documentation:
// https://developers.google.com/blogger/docs/3.0/getting_started
#if SWIFT_PACKAGE || GTLR_USE_MODULAR_IMPORT
@import GoogleAPIClientForRESTCore;
#elif GTLR_BUILT_AS_FRAMEWORK
#import "GTLR/GTLRQuery.h"
#else
#import "GTLRQuery.h"
#endif
#if GTLR_RUNTIME_VERSION != 3000
#error This file was generated by a different version of ServiceGenerator which is incompatible with this GTLR library source.
#endif
@class GTLRBlogger_Page;
@class GTLRBlogger_Post;
// Generated comments include content from the discovery document; avoid them
// causing warnings since clang's checks are some what arbitrary.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
NS_ASSUME_NONNULL_BEGIN
// ----------------------------------------------------------------------------
// Constants - For some of the query classes' properties below.
// ----------------------------------------------------------------------------
// orderBy
/** Value: "ORDER_BY_UNSPECIFIED" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerOrderByOrderByUnspecified;
/** Value: "PUBLISHED" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerOrderByPublished;
/** Value: "UPDATED" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerOrderByUpdated;
// ----------------------------------------------------------------------------
// range
/** Value: "all" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerRangeAll;
/** Value: "30DAYS" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerRangeX30days;
/** Value: "7DAYS" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerRangeX7days;
// ----------------------------------------------------------------------------
// role
/** Value: "ADMIN" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerRoleAdmin;
/** Value: "AUTHOR" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerRoleAuthor;
/** Value: "READER" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerRoleReader;
/** Value: "VIEW_TYPE_UNSPECIFIED" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerRoleViewTypeUnspecified;
// ----------------------------------------------------------------------------
// status
/** Value: "DELETED" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerStatusDeleted;
/** Value: "DRAFT" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerStatusDraft;
/** Value: "EMPTIED" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerStatusEmptied;
/** Value: "LIVE" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerStatusLive;
/** Value: "PENDING" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerStatusPending;
/** Value: "SCHEDULED" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerStatusScheduled;
/** Value: "SPAM" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerStatusSpam;
// ----------------------------------------------------------------------------
// view
/** Value: "ADMIN" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerViewAdmin;
/** Value: "AUTHOR" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerViewAuthor;
/** Value: "READER" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerViewReader;
/** Value: "VIEW_TYPE_UNSPECIFIED" */
FOUNDATION_EXTERN NSString * const kGTLRBloggerViewViewTypeUnspecified;
// ----------------------------------------------------------------------------
// Query Classes
//
/**
* Parent class for other Blogger query classes.
*/
@interface GTLRBloggerQuery : GTLRQuery
/** Selector specifying which fields to include in a partial response. */
@property(nonatomic, copy, nullable) NSString *fields;
@end
/**
* Gets a blog by id.
*
* Method: blogger.blogs.get
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_BlogsGet : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForBlogsGetWithblogId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, assign) NSUInteger maxPosts;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_Blog.
*
* Gets a blog by id.
*
* @param blogId NSString
*
* @return GTLRBloggerQuery_BlogsGet
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId;
@end
/**
* Gets a blog by url.
*
* Method: blogger.blogs.getByUrl
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_BlogsGetByUrl : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForBlogsGetByUrlWithurl:]
@property(nonatomic, copy, nullable) NSString *url;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_Blog.
*
* Gets a blog by url.
*
* @param url NSString
*
* @return GTLRBloggerQuery_BlogsGetByUrl
*/
+ (instancetype)queryWithUrl:(NSString *)url;
@end
/**
* Lists blogs by user.
*
* Method: blogger.blogs.listByUser
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_BlogsListByUser : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForBlogsListByUserWithuserId:]
@property(nonatomic, assign) BOOL fetchUserInfo;
/**
* role
*
* Likely values:
* @arg @c kGTLRBloggerRoleViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerRoleReader Value "READER"
* @arg @c kGTLRBloggerRoleAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerRoleAdmin Value "ADMIN"
*/
@property(nonatomic, strong, nullable) NSArray<NSString *> *role;
/**
* Default value of status is LIVE.
*
* Likely values:
* @arg @c kGTLRBloggerStatusLive Value "LIVE"
* @arg @c kGTLRBloggerStatusDeleted Value "DELETED"
*/
@property(nonatomic, strong, nullable) NSArray<NSString *> *status;
@property(nonatomic, copy, nullable) NSString *userId;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_BlogList.
*
* Lists blogs by user.
*
* @param userId NSString
*
* @return GTLRBloggerQuery_BlogsListByUser
*/
+ (instancetype)queryWithUserId:(NSString *)userId;
@end
/**
* Gets one blog and user info pair by blog id and user id.
*
* Method: blogger.blogUserInfos.get
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_BlogUserInfosGet : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForBlogUserInfosGetWithuserId:blogId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, assign) NSUInteger maxPosts;
@property(nonatomic, copy, nullable) NSString *userId;
/**
* Fetches a @c GTLRBlogger_BlogUserInfo.
*
* Gets one blog and user info pair by blog id and user id.
*
* @param userId NSString
* @param blogId NSString
*
* @return GTLRBloggerQuery_BlogUserInfosGet
*/
+ (instancetype)queryWithUserId:(NSString *)userId
blogId:(NSString *)blogId;
@end
/**
* Marks a comment as not spam by blog id, post id and comment id.
*
* Method: blogger.comments.approve
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_CommentsApprove : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForCommentsApproveWithblogId:postId:commentId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *commentId;
@property(nonatomic, copy, nullable) NSString *postId;
/**
* Fetches a @c GTLRBlogger_Comment.
*
* Marks a comment as not spam by blog id, post id and comment id.
*
* @param blogId NSString
* @param postId NSString
* @param commentId NSString
*
* @return GTLRBloggerQuery_CommentsApprove
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
postId:(NSString *)postId
commentId:(NSString *)commentId;
@end
/**
* Deletes a comment by blog id, post id and comment id.
*
* Method: blogger.comments.delete
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_CommentsDelete : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForCommentsDeleteWithblogId:postId:commentId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *commentId;
@property(nonatomic, copy, nullable) NSString *postId;
/**
* Upon successful completion, the callback's object and error parameters will
* be nil. This query does not fetch an object.
*
* Deletes a comment by blog id, post id and comment id.
*
* @param blogId NSString
* @param postId NSString
* @param commentId NSString
*
* @return GTLRBloggerQuery_CommentsDelete
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
postId:(NSString *)postId
commentId:(NSString *)commentId;
@end
/**
* Gets a comment by id.
*
* Method: blogger.comments.get
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_CommentsGet : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForCommentsGetWithblogId:postId:commentId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *commentId;
@property(nonatomic, copy, nullable) NSString *postId;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_Comment.
*
* Gets a comment by id.
*
* @param blogId NSString
* @param postId NSString
* @param commentId NSString
*
* @return GTLRBloggerQuery_CommentsGet
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
postId:(NSString *)postId
commentId:(NSString *)commentId;
@end
/**
* Lists comments.
*
* Method: blogger.comments.list
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_CommentsList : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForCommentsListWithblogId:postId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *endDate;
@property(nonatomic, assign) BOOL fetchBodies;
@property(nonatomic, assign) NSUInteger maxResults;
@property(nonatomic, copy, nullable) NSString *pageToken;
@property(nonatomic, copy, nullable) NSString *postId;
@property(nonatomic, copy, nullable) NSString *startDate;
/**
* status
*
* Likely values:
* @arg @c kGTLRBloggerStatusLive Value "LIVE"
* @arg @c kGTLRBloggerStatusEmptied Value "EMPTIED"
* @arg @c kGTLRBloggerStatusPending Value "PENDING"
* @arg @c kGTLRBloggerStatusSpam Value "SPAM"
*/
@property(nonatomic, copy, nullable) NSString *status;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_CommentList.
*
* Lists comments.
*
* @param blogId NSString
* @param postId NSString
*
* @return GTLRBloggerQuery_CommentsList
*
* @note Automatic pagination will be done when @c shouldFetchNextPages is
* enabled. See @c shouldFetchNextPages on @c GTLRService for more
* information.
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
postId:(NSString *)postId;
@end
/**
* Lists comments by blog.
*
* Method: blogger.comments.listByBlog
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_CommentsListByBlog : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForCommentsListByBlogWithblogId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *endDate;
@property(nonatomic, assign) BOOL fetchBodies;
@property(nonatomic, assign) NSUInteger maxResults;
@property(nonatomic, copy, nullable) NSString *pageToken;
@property(nonatomic, copy, nullable) NSString *startDate;
/**
* status
*
* Likely values:
* @arg @c kGTLRBloggerStatusLive Value "LIVE"
* @arg @c kGTLRBloggerStatusEmptied Value "EMPTIED"
* @arg @c kGTLRBloggerStatusPending Value "PENDING"
* @arg @c kGTLRBloggerStatusSpam Value "SPAM"
*/
@property(nonatomic, strong, nullable) NSArray<NSString *> *status;
/**
* Fetches a @c GTLRBlogger_CommentList.
*
* Lists comments by blog.
*
* @param blogId NSString
*
* @return GTLRBloggerQuery_CommentsListByBlog
*
* @note Automatic pagination will be done when @c shouldFetchNextPages is
* enabled. See @c shouldFetchNextPages on @c GTLRService for more
* information.
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId;
@end
/**
* Marks a comment as spam by blog id, post id and comment id.
*
* Method: blogger.comments.markAsSpam
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_CommentsMarkAsSpam : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForCommentsMarkAsSpamWithblogId:postId:commentId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *commentId;
@property(nonatomic, copy, nullable) NSString *postId;
/**
* Fetches a @c GTLRBlogger_Comment.
*
* Marks a comment as spam by blog id, post id and comment id.
*
* @param blogId NSString
* @param postId NSString
* @param commentId NSString
*
* @return GTLRBloggerQuery_CommentsMarkAsSpam
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
postId:(NSString *)postId
commentId:(NSString *)commentId;
@end
/**
* Removes the content of a comment by blog id, post id and comment id.
*
* Method: blogger.comments.removeContent
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_CommentsRemoveContent : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForCommentsRemoveContentWithblogId:postId:commentId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *commentId;
@property(nonatomic, copy, nullable) NSString *postId;
/**
* Fetches a @c GTLRBlogger_Comment.
*
* Removes the content of a comment by blog id, post id and comment id.
*
* @param blogId NSString
* @param postId NSString
* @param commentId NSString
*
* @return GTLRBloggerQuery_CommentsRemoveContent
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
postId:(NSString *)postId
commentId:(NSString *)commentId;
@end
/**
* Deletes a page by blog id and page id.
*
* Method: blogger.pages.delete
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PagesDelete : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPagesDeleteWithblogId:pageId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *pageId;
/**
* Upon successful completion, the callback's object and error parameters will
* be nil. This query does not fetch an object.
*
* Deletes a page by blog id and page id.
*
* @param blogId NSString
* @param pageId NSString
*
* @return GTLRBloggerQuery_PagesDelete
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
pageId:(NSString *)pageId;
@end
/**
* Gets a page by blog id and page id.
*
* Method: blogger.pages.get
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_PagesGet : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPagesGetWithblogId:pageId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *pageId;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_Page.
*
* Gets a page by blog id and page id.
*
* @param blogId NSString
* @param pageId NSString
*
* @return GTLRBloggerQuery_PagesGet
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
pageId:(NSString *)pageId;
@end
/**
* Inserts a page.
*
* Method: blogger.pages.insert
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PagesInsert : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPagesInsertWithObject:blogId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, assign) BOOL isDraft;
/**
* Fetches a @c GTLRBlogger_Page.
*
* Inserts a page.
*
* @param object The @c GTLRBlogger_Page to include in the query.
* @param blogId NSString
*
* @return GTLRBloggerQuery_PagesInsert
*/
+ (instancetype)queryWithObject:(GTLRBlogger_Page *)object
blogId:(NSString *)blogId;
@end
/**
* Lists pages.
*
* Method: blogger.pages.list
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_PagesList : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPagesListWithblogId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, assign) BOOL fetchBodies;
@property(nonatomic, assign) NSUInteger maxResults;
@property(nonatomic, copy, nullable) NSString *pageToken;
/**
* status
*
* Likely values:
* @arg @c kGTLRBloggerStatusLive Value "LIVE"
* @arg @c kGTLRBloggerStatusDraft Value "DRAFT"
*/
@property(nonatomic, strong, nullable) NSArray<NSString *> *status;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_PageList.
*
* Lists pages.
*
* @param blogId NSString
*
* @return GTLRBloggerQuery_PagesList
*
* @note Automatic pagination will be done when @c shouldFetchNextPages is
* enabled. See @c shouldFetchNextPages on @c GTLRService for more
* information.
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId;
@end
/**
* Patches a page.
*
* Method: blogger.pages.patch
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PagesPatch : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPagesPatchWithObject:blogId:pageId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *pageId;
@property(nonatomic, assign) BOOL publish;
@property(nonatomic, assign) BOOL revert;
/**
* Fetches a @c GTLRBlogger_Page.
*
* Patches a page.
*
* @param object The @c GTLRBlogger_Page to include in the query.
* @param blogId NSString
* @param pageId NSString
*
* @return GTLRBloggerQuery_PagesPatch
*/
+ (instancetype)queryWithObject:(GTLRBlogger_Page *)object
blogId:(NSString *)blogId
pageId:(NSString *)pageId;
@end
/**
* Publishes a page.
*
* Method: blogger.pages.publish
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PagesPublish : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPagesPublishWithblogId:pageId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *pageId;
/**
* Fetches a @c GTLRBlogger_Page.
*
* Publishes a page.
*
* @param blogId NSString
* @param pageId NSString
*
* @return GTLRBloggerQuery_PagesPublish
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
pageId:(NSString *)pageId;
@end
/**
* Reverts a published or scheduled page to draft state.
*
* Method: blogger.pages.revert
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PagesRevert : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPagesRevertWithblogId:pageId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *pageId;
/**
* Fetches a @c GTLRBlogger_Page.
*
* Reverts a published or scheduled page to draft state.
*
* @param blogId NSString
* @param pageId NSString
*
* @return GTLRBloggerQuery_PagesRevert
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
pageId:(NSString *)pageId;
@end
/**
* Updates a page by blog id and page id.
*
* Method: blogger.pages.update
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PagesUpdate : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPagesUpdateWithObject:blogId:pageId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *pageId;
@property(nonatomic, assign) BOOL publish;
@property(nonatomic, assign) BOOL revert;
/**
* Fetches a @c GTLRBlogger_Page.
*
* Updates a page by blog id and page id.
*
* @param object The @c GTLRBlogger_Page to include in the query.
* @param blogId NSString
* @param pageId NSString
*
* @return GTLRBloggerQuery_PagesUpdate
*/
+ (instancetype)queryWithObject:(GTLRBlogger_Page *)object
blogId:(NSString *)blogId
pageId:(NSString *)pageId;
@end
/**
* Gets page views by blog id.
*
* Method: blogger.pageViews.get
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PageViewsGet : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPageViewsGetWithblogId:]
@property(nonatomic, copy, nullable) NSString *blogId;
/**
* range
*
* Likely values:
* @arg @c kGTLRBloggerRangeAll Value "all"
* @arg @c kGTLRBloggerRangeX30days Value "30DAYS"
* @arg @c kGTLRBloggerRangeX7days Value "7DAYS"
*/
@property(nonatomic, strong, nullable) NSArray<NSString *> *range;
/**
* Fetches a @c GTLRBlogger_Pageviews.
*
* Gets page views by blog id.
*
* @param blogId NSString
*
* @return GTLRBloggerQuery_PageViewsGet
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId;
@end
/**
* Deletes a post by blog id and post id.
*
* Method: blogger.posts.delete
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PostsDelete : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostsDeleteWithblogId:postId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *postId;
/**
* Upon successful completion, the callback's object and error parameters will
* be nil. This query does not fetch an object.
*
* Deletes a post by blog id and post id.
*
* @param blogId NSString
* @param postId NSString
*
* @return GTLRBloggerQuery_PostsDelete
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
postId:(NSString *)postId;
@end
/**
* Gets a post by blog id and post id
*
* Method: blogger.posts.get
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_PostsGet : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostsGetWithblogId:postId:]
@property(nonatomic, copy, nullable) NSString *blogId;
/**
* fetchBody
*
* @note If not set, the documented server-side default will be true.
*/
@property(nonatomic, assign) BOOL fetchBody;
@property(nonatomic, assign) BOOL fetchImages;
@property(nonatomic, assign) NSUInteger maxComments;
@property(nonatomic, copy, nullable) NSString *postId;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_Post.
*
* Gets a post by blog id and post id
*
* @param blogId NSString
* @param postId NSString
*
* @return GTLRBloggerQuery_PostsGet
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
postId:(NSString *)postId;
@end
/**
* Gets a post by path.
*
* Method: blogger.posts.getByPath
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_PostsGetByPath : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostsGetByPathWithblogId:path:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, assign) NSUInteger maxComments;
@property(nonatomic, copy, nullable) NSString *path;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_Post.
*
* Gets a post by path.
*
* @param blogId NSString
* @param path NSString
*
* @return GTLRBloggerQuery_PostsGetByPath
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
path:(NSString *)path;
@end
/**
* Inserts a post.
*
* Method: blogger.posts.insert
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PostsInsert : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostsInsertWithObject:blogId:]
@property(nonatomic, copy, nullable) NSString *blogId;
/**
* fetchBody
*
* @note If not set, the documented server-side default will be true.
*/
@property(nonatomic, assign) BOOL fetchBody;
@property(nonatomic, assign) BOOL fetchImages;
@property(nonatomic, assign) BOOL isDraft;
/**
* Fetches a @c GTLRBlogger_Post.
*
* Inserts a post.
*
* @param object The @c GTLRBlogger_Post to include in the query.
* @param blogId NSString
*
* @return GTLRBloggerQuery_PostsInsert
*/
+ (instancetype)queryWithObject:(GTLRBlogger_Post *)object
blogId:(NSString *)blogId;
@end
/**
* Lists posts.
*
* Method: blogger.posts.list
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_PostsList : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostsListWithblogId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *endDate;
/**
* fetchBodies
*
* @note If not set, the documented server-side default will be true.
*/
@property(nonatomic, assign) BOOL fetchBodies;
@property(nonatomic, assign) BOOL fetchImages;
@property(nonatomic, copy, nullable) NSString *labels;
@property(nonatomic, assign) NSUInteger maxResults;
/**
* orderBy
*
* Likely values:
* @arg @c kGTLRBloggerOrderByOrderByUnspecified Value "ORDER_BY_UNSPECIFIED"
* @arg @c kGTLRBloggerOrderByPublished Value "PUBLISHED"
* @arg @c kGTLRBloggerOrderByUpdated Value "UPDATED"
*
* @note If not set, the documented server-side default will be
* kGTLRBloggerOrderByPublished.
*/
@property(nonatomic, copy, nullable) NSString *orderBy;
@property(nonatomic, copy, nullable) NSString *pageToken;
@property(nonatomic, copy, nullable) NSString *startDate;
/**
* status
*
* Likely values:
* @arg @c kGTLRBloggerStatusLive Value "LIVE"
* @arg @c kGTLRBloggerStatusDraft Value "DRAFT"
* @arg @c kGTLRBloggerStatusScheduled Value "SCHEDULED"
*/
@property(nonatomic, strong, nullable) NSArray<NSString *> *status;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_PostList.
*
* Lists posts.
*
* @param blogId NSString
*
* @return GTLRBloggerQuery_PostsList
*
* @note Automatic pagination will be done when @c shouldFetchNextPages is
* enabled. See @c shouldFetchNextPages on @c GTLRService for more
* information.
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId;
@end
/**
* Patches a post.
*
* Method: blogger.posts.patch
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PostsPatch : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostsPatchWithObject:blogId:postId:]
@property(nonatomic, copy, nullable) NSString *blogId;
/**
* fetchBody
*
* @note If not set, the documented server-side default will be true.
*/
@property(nonatomic, assign) BOOL fetchBody;
@property(nonatomic, assign) BOOL fetchImages;
@property(nonatomic, assign) NSUInteger maxComments;
@property(nonatomic, copy, nullable) NSString *postId;
@property(nonatomic, assign) BOOL publish;
@property(nonatomic, assign) BOOL revert;
/**
* Fetches a @c GTLRBlogger_Post.
*
* Patches a post.
*
* @param object The @c GTLRBlogger_Post to include in the query.
* @param blogId NSString
* @param postId NSString
*
* @return GTLRBloggerQuery_PostsPatch
*/
+ (instancetype)queryWithObject:(GTLRBlogger_Post *)object
blogId:(NSString *)blogId
postId:(NSString *)postId;
@end
/**
* Publishes a post.
*
* Method: blogger.posts.publish
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PostsPublish : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostsPublishWithblogId:postId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *postId;
@property(nonatomic, copy, nullable) NSString *publishDate;
/**
* Fetches a @c GTLRBlogger_Post.
*
* Publishes a post.
*
* @param blogId NSString
* @param postId NSString
*
* @return GTLRBloggerQuery_PostsPublish
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
postId:(NSString *)postId;
@end
/**
* Reverts a published or scheduled post to draft state.
*
* Method: blogger.posts.revert
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PostsRevert : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostsRevertWithblogId:postId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *postId;
/**
* Fetches a @c GTLRBlogger_Post.
*
* Reverts a published or scheduled post to draft state.
*
* @param blogId NSString
* @param postId NSString
*
* @return GTLRBloggerQuery_PostsRevert
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
postId:(NSString *)postId;
@end
/**
* Searches for posts matching given query terms in the specified blog.
*
* Method: blogger.posts.search
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_PostsSearch : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostsSearchWithblogId:q:]
@property(nonatomic, copy, nullable) NSString *blogId;
/**
* fetchBodies
*
* @note If not set, the documented server-side default will be true.
*/
@property(nonatomic, assign) BOOL fetchBodies;
/**
* orderBy
*
* Likely values:
* @arg @c kGTLRBloggerOrderByOrderByUnspecified Value "ORDER_BY_UNSPECIFIED"
* @arg @c kGTLRBloggerOrderByPublished Value "PUBLISHED"
* @arg @c kGTLRBloggerOrderByUpdated Value "UPDATED"
*
* @note If not set, the documented server-side default will be
* kGTLRBloggerOrderByPublished.
*/
@property(nonatomic, copy, nullable) NSString *orderBy;
@property(nonatomic, copy, nullable) NSString *q;
/**
* Fetches a @c GTLRBlogger_PostList.
*
* Searches for posts matching given query terms in the specified blog.
*
* @param blogId NSString
* @param q NSString
*
* @return GTLRBloggerQuery_PostsSearch
*/
+ (instancetype)queryWithBlogId:(NSString *)blogId
q:(NSString *)q;
@end
/**
* Updates a post by blog id and post id.
*
* Method: blogger.posts.update
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
*/
@interface GTLRBloggerQuery_PostsUpdate : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostsUpdateWithObject:blogId:postId:]
@property(nonatomic, copy, nullable) NSString *blogId;
/**
* fetchBody
*
* @note If not set, the documented server-side default will be true.
*/
@property(nonatomic, assign) BOOL fetchBody;
@property(nonatomic, assign) BOOL fetchImages;
@property(nonatomic, assign) NSUInteger maxComments;
@property(nonatomic, copy, nullable) NSString *postId;
@property(nonatomic, assign) BOOL publish;
@property(nonatomic, assign) BOOL revert;
/**
* Fetches a @c GTLRBlogger_Post.
*
* Updates a post by blog id and post id.
*
* @param object The @c GTLRBlogger_Post to include in the query.
* @param blogId NSString
* @param postId NSString
*
* @return GTLRBloggerQuery_PostsUpdate
*/
+ (instancetype)queryWithObject:(GTLRBlogger_Post *)object
blogId:(NSString *)blogId
postId:(NSString *)postId;
@end
/**
* Gets one post and user info pair, by post_id and user_id.
*
* Method: blogger.postUserInfos.get
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_PostUserInfosGet : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostUserInfosGetWithuserId:blogId:postId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, assign) NSUInteger maxComments;
@property(nonatomic, copy, nullable) NSString *postId;
@property(nonatomic, copy, nullable) NSString *userId;
/**
* Fetches a @c GTLRBlogger_PostUserInfo.
*
* Gets one post and user info pair, by post_id and user_id.
*
* @param userId NSString
* @param blogId NSString
* @param postId NSString
*
* @return GTLRBloggerQuery_PostUserInfosGet
*/
+ (instancetype)queryWithUserId:(NSString *)userId
blogId:(NSString *)blogId
postId:(NSString *)postId;
@end
/**
* Lists post and user info pairs.
*
* Method: blogger.postUserInfos.list
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_PostUserInfosList : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForPostUserInfosListWithuserId:blogId:]
@property(nonatomic, copy, nullable) NSString *blogId;
@property(nonatomic, copy, nullable) NSString *endDate;
/**
* fetchBodies
*
* @note If not set, the documented server-side default will be false.
*/
@property(nonatomic, assign) BOOL fetchBodies;
@property(nonatomic, copy, nullable) NSString *labels;
@property(nonatomic, assign) NSUInteger maxResults;
/**
* orderBy
*
* Likely values:
* @arg @c kGTLRBloggerOrderByOrderByUnspecified Value "ORDER_BY_UNSPECIFIED"
* @arg @c kGTLRBloggerOrderByPublished Value "PUBLISHED"
* @arg @c kGTLRBloggerOrderByUpdated Value "UPDATED"
*
* @note If not set, the documented server-side default will be
* kGTLRBloggerOrderByPublished.
*/
@property(nonatomic, copy, nullable) NSString *orderBy;
@property(nonatomic, copy, nullable) NSString *pageToken;
@property(nonatomic, copy, nullable) NSString *startDate;
/**
* status
*
* Likely values:
* @arg @c kGTLRBloggerStatusLive Value "LIVE"
* @arg @c kGTLRBloggerStatusDraft Value "DRAFT"
* @arg @c kGTLRBloggerStatusScheduled Value "SCHEDULED"
*/
@property(nonatomic, strong, nullable) NSArray<NSString *> *status;
@property(nonatomic, copy, nullable) NSString *userId;
/**
* view
*
* Likely values:
* @arg @c kGTLRBloggerViewViewTypeUnspecified Value "VIEW_TYPE_UNSPECIFIED"
* @arg @c kGTLRBloggerViewReader Value "READER"
* @arg @c kGTLRBloggerViewAuthor Value "AUTHOR"
* @arg @c kGTLRBloggerViewAdmin Value "ADMIN"
*/
@property(nonatomic, copy, nullable) NSString *view;
/**
* Fetches a @c GTLRBlogger_PostUserInfosList.
*
* Lists post and user info pairs.
*
* @param userId NSString
* @param blogId NSString
*
* @return GTLRBloggerQuery_PostUserInfosList
*
* @note Automatic pagination will be done when @c shouldFetchNextPages is
* enabled. See @c shouldFetchNextPages on @c GTLRService for more
* information.
*/
+ (instancetype)queryWithUserId:(NSString *)userId
blogId:(NSString *)blogId;
@end
/**
* Gets one user by user_id.
*
* Method: blogger.users.get
*
* Authorization scope(s):
* @c kGTLRAuthScopeBlogger
* @c kGTLRAuthScopeBloggerReadonly
*/
@interface GTLRBloggerQuery_UsersGet : GTLRBloggerQuery
// Previous library name was
// +[GTLQueryBlogger queryForUsersGetWithuserId:]
@property(nonatomic, copy, nullable) NSString *userId;
/**
* Fetches a @c GTLRBlogger_User.
*
* Gets one user by user_id.
*
* @param userId NSString
*
* @return GTLRBloggerQuery_UsersGet
*/
+ (instancetype)queryWithUserId:(NSString *)userId;
@end
NS_ASSUME_NONNULL_END
#pragma clang diagnostic pop
| 25.531451 | 126 | 0.701544 | [
"object"
] |
7f8aee5ce0930ce677513f754dfc8b5563c89621 | 22,477 | c | C | H101_acro_only/src/control.c | silver13/H101-dual | 0c81cb19090ff414f6dbf8c622ac401fb0d71103 | [
"MIT"
] | 17 | 2017-03-16T02:34:45.000Z | 2021-12-10T03:31:43.000Z | H101_acro_only/src/control.c | silver13/H101-dual | 0c81cb19090ff414f6dbf8c622ac401fb0d71103 | [
"MIT"
] | 14 | 2017-05-25T22:22:01.000Z | 2021-01-22T16:38:35.000Z | H101_acro_only/src/control.c | silver13/H101-acro | 0c81cb19090ff414f6dbf8c622ac401fb0d71103 | [
"MIT"
] | 16 | 2016-03-30T04:47:21.000Z | 2016-12-08T23:37:59.000Z | /*
The MIT License (MIT)
Copyright (c) 2015 silverx
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <inttypes.h>
#include <math.h>
#include "pid.h"
#include "config.h"
#include "util.h"
#include "drv_pwm.h"
#include "control.h"
#include "defines.h"
#include "drv_time.h"
#include "sixaxis.h"
#include "gestures.h"
extern float throttlehpf(float in);
extern int ledcommand;
extern float rx[4];
extern float gyro[3];
extern int failsafe;
extern char auxchange[AUXNUMBER];
extern char aux[AUXNUMBER];
extern float attitude[3];
extern float looptime;
extern float angleerror[3];
extern float error[PIDNUMBER];
extern float pidoutput[PIDNUMBER];
int onground = 1;
int onground_long = 1;
float thrsum;
float rxcopy[4];
float motormap(float input);
int lastchange;
float yawangle;
float overthrottlefilt;
float underthrottlefilt;
float feedback[3] = {1.0 , 1.0 , 1.0};
#ifdef STOCK_TX_AUTOCENTER
float autocenter[3];
float lastrx[3];
unsigned int consecutive[3];
#endif
extern int pwmdir;
void bridge_sequencer(int dir);
// bridge
int bridge_stage = BRIDGE_WAIT;
int currentdir;
extern int ledcommand;
extern int ledblink;
// for 3d throttle
#ifdef THREE_D_THROTTLE
int throttlesafe_3d = 0;
#endif
extern float apid(int x);
extern void imu_calc(void);
extern void savecal(void);
void control(void)
{
// hi rates
float ratemulti;
float ratemultiyaw;
#ifdef TOGGLE_IN
if ( auxchange[TOGGLE_IN] && !aux[TOGGLE_IN] )
{
ledcommand = 1;
aux[TOGGLE_OUT]=!aux[TOGGLE_OUT];
}
#endif
#ifndef THREE_D_THROTTLE
if ( aux[INVERTEDMODE] )
{
bridge_sequencer(REVERSE); // reverse
}
else
{
bridge_sequencer(FORWARD); // forward
}
#endif
// pwmdir controls hardware directly so we make a copy here
currentdir = pwmdir;
if (aux[RATES])
{
ratemulti = HIRATEMULTI;
ratemultiyaw = HIRATEMULTIYAW;
}
else
{
ratemulti = 1.0f;
ratemultiyaw = 1.0f;
}
for (int i = 0; i < 3; i++)
{
#ifdef STOCK_TX_AUTOCENTER
rxcopy[i] = rx[i] - autocenter[i];
#else
rxcopy[i] = rx[i];
#endif
#ifdef STICKS_DEADBAND
if ( fabsf( rxcopy[ i ] ) <= STICKS_DEADBAND ) {
rxcopy[ i ] = 0.0f;
} else {
if ( rxcopy[ i ] >= 0 ) {
rxcopy[ i ] = mapf( rxcopy[ i ], STICKS_DEADBAND, 1, 0, 1 );
} else {
rxcopy[ i ] = mapf( rxcopy[ i ], -STICKS_DEADBAND, -1, 0, -1 );
}
}
#endif
}
if (currentdir == REVERSE)
{
#ifndef NATIVE_INVERTED_MODE
// invert pitch in inverted mode
rxcopy[PITCH] = - rxcopy[PITCH];
rxcopy[YAW] = - rxcopy[YAW];
#endif
}
// check for acc calibration
int command = gestures2();
if (command)
{
if (command == 3)
{
gyro_cal(); // for flashing lights
//acc_cal();
savecal();
// reset loop time
extern unsigned lastlooptime;
lastlooptime = gettime();
}
else
{
if (command == 2)
{
ledcommand = 1;
aux[CH_AUX1] = 1;
}
if (command == 1)
{
ledcommand = 1;
aux[CH_AUX1] = 0;
}
if (command == 4)
{
ledcommand = 1;
aux[CH_AUX2] = !aux[CH_AUX2];
}
#ifdef PID_GESTURE_TUNING
int blink = 0;
if (command == 5)
{
// Cycle to next pid term (P I D)
blink = next_pid_term();
}
if (command == 6)
{
// Cycle to next axis (Roll Pitch Yaw)
blink = next_pid_axis();
}
if (command == 7)
{
// Increase by 10%
blink = increase_pid();
}
if (command == 8)
{
// Descrease by 10%
blink = decrease_pid();
}
// U D U - Next PID term
// U D D - Next PID Axis
// U D R - Increase value
// U D L - Descrease value
ledblink = blink; //Will cause led logic to blink the number of times ledblink has stored in it.
#endif
}
}
pid_precalc();
// rate mode
error[0] = rxcopy[0] * MAX_RATE * DEGTORAD * ratemulti * feedback[0] - gyro[0];
error[1] = rxcopy[1] * MAX_RATE * DEGTORAD * ratemulti * feedback[1] - gyro[1];
// reduce angle Iterm towards zero
// extern float aierror[3];
// aierror[0] = 0.0f;
// aierror[1] = 0.0f;
error[2] = rxcopy[2] * MAX_RATEYAW * DEGTORAD * ratemultiyaw * feedback[2] - gyro[2];
pid(0);
pid(1);
pid(2);
feedback[0] = 1.0f;
feedback[1] = 1.0f;
feedback[2] = 1.0f;
#ifndef THREE_D_THROTTLE
// map throttle so under 10% it is zero
float throttle = mapf(rx[3], 0, 1, -0.1, 1);
if (throttle < 0)
throttle = 0;
if (throttle > 1.0f)
throttle = 1.0f;
#endif
#ifdef THREE_D_THROTTLE
// this changes throttle so under center motor direction is reversed
// map throttle with zero center
float throttle = mapf(rx[3], 0, 1, -1, 1);
limitf(&throttle, 1.0);
if ( throttle > 0 )
{
bridge_sequencer(FORWARD); // forward
}else
{
bridge_sequencer(REVERSE); // reverse
}
if ( !throttlesafe_3d )
{
if (throttle > 0)
{
throttlesafe_3d = 1;
ledcommand = 1;
}
throttle = 0;
}
throttle = fabsf(throttle);
throttle = mapf (throttle , THREE_D_THROTTLE_DEADZONE , 1, 0 , 1);
if ( failsafe ) throttle = 0;
#endif // end 3d throttle remap
#ifdef AIRMODE_HOLD_SWITCH
if (failsafe || aux[AIRMODE_HOLD_SWITCH] || throttle < 0.001f && !onground_long)
{
onground_long = 0;
#else
// turn motors off if throttle is off and pitch / roll sticks are centered
if (failsafe || (throttle < 0.001f && ( !ENABLESTIX || !onground_long || (fabsf(rx[0]) < (float) ENABLESTIX_TRESHOLD && fabsf(rx[1]) < (float) ENABLESTIX_TRESHOLD && fabsf(rx[2]) < (float) ENABLESTIX_TRESHOLD ))))
{ // motors off
#endif
onground = 1;
if ( onground_long )
{
if ( gettime() - onground_long > ENABLESTIX_TIMEOUT)
{
onground_long = 0;
}
}
extern float GEstG[3];
// check gravity vector to see if inverted
if ( GEstG[2] < 0 ) aux[CH_AUX3] = 1;
else aux[CH_AUX3] = 0;
#ifdef MOTOR_BEEPS
extern void motorbeep( void);
motorbeep();
#endif
thrsum = 0;
for (int i = 0; i <= 3; i++)
{
pwm_set(i, 0);
}
// reset the overthrottle filter
lpf(&overthrottlefilt, 0.0f, 0.72f); // 50hz 1khz sample rate
lpf(&underthrottlefilt, 0.0f, 0.72f); // 50hz 1khz sample rate
#ifdef MOTOR_FILTER
// reset the motor filter
for (int i = 0; i <= 3; i++)
{
motorfilter(0, i);
}
#endif
#ifdef THROTTLE_TRANSIENT_COMPENSATION
// reset hpf filter;
throttlehpf(0);
#endif
#ifdef STOCK_TX_AUTOCENTER
for( int i = 0 ; i <3;i++)
{
if ( rx[i] == lastrx[i] )
{
consecutive[i]++;
}
else consecutive[i] = 0;
lastrx[i] = rx[i];
if ( consecutive[i] > 1000 && fabsf( rx[i]) < 0.1f )
{
autocenter[i] = rx[i];
}
}
#endif
// end motors off / failsafe / onground
}
else
{
// motors on - normal flight
onground_long = gettime();
#ifdef THROTTLE_TRANSIENT_COMPENSATION
throttle += 7.0f * throttlehpf(throttle);
if (throttle < 0)
throttle = 0;
if (throttle > 1.0f)
throttle = 1.0f;
#endif
// throttle angle compensation
#ifdef AUTO_THROTTLE
if (aux[LEVELMODE])
{
// float autothrottle = fastcos(attitude[0] * DEGTORAD) * fastcos(attitude[1] * DEGTORAD);
extern float GEstG[];
float autothrottle;
if ( GEstG[2] < 0 && currentdir == REVERSE)
autothrottle = - GEstG[2] * ( 1/2048.0f);
if ( GEstG[2] > 0 && currentdir == FORWARD)
autothrottle = GEstG[2] * ( 1/2048.0f);
float old_throttle = throttle;
if (autothrottle <= 0.5f)
autothrottle = 0.5f;
throttle = throttle / autothrottle;
// limit to 90%
if (old_throttle < 0.9f)
if (throttle > 0.9f)
throttle = 0.9f;
if (throttle > 1.0f)
throttle = 1.0f;
}
#endif
#ifdef LVC_PREVENT_RESET
extern float vbatt;
if (vbatt < (float) LVC_PREVENT_RESET_VOLTAGE) throttle = 0;
#endif
#ifdef LVC_LOWER_THROTTLE
extern float vbatt_comp;
extern float vbattfilt;
static float throttle_i = 0.0f;
float throttle_p = 0.0f;
// can be made into a function
if (vbattfilt < (float) LVC_LOWER_THROTTLE_VOLTAGE_RAW )
throttle_p = ((float) LVC_LOWER_THROTTLE_VOLTAGE_RAW - vbattfilt);
// can be made into a function
if (vbatt_comp < (float) LVC_LOWER_THROTTLE_VOLTAGE)
throttle_p = ((float) LVC_LOWER_THROTTLE_VOLTAGE - vbatt_comp) ;
if ( throttle_p > 0 )
{
throttle_i += throttle_p * 0.0001f; //ki
}
else throttle_i -= 0.001f;// ki on release
if ( throttle_i > 0.5f) throttle_i = 0.5f;
if ( throttle_i < 0.0f) throttle_i = 0.0f;
throttle_p *= (float) LVC_LOWER_THROTTLE_KP;
if ( throttle_p > 1.0f ) throttle_p = 1.0f;
throttle -= throttle_p + throttle_i;
if ( throttle < 0 ) throttle = 0;
#endif
onground = 0;
float mix[4];
if ( bridge_stage == BRIDGE_WAIT ) onground = 1;
if (currentdir == REVERSE)
{
// inverted flight
pidoutput[ROLL] = -pidoutput[ROLL];
pidoutput[PITCH] = -pidoutput[PITCH];
pidoutput[YAW] = -pidoutput[YAW];
}
#ifdef INVERT_YAW_PID
pidoutput[2] = -pidoutput[2];
#endif
mix[MOTOR_FR] = throttle - pidoutput[0] - pidoutput[1] + pidoutput[2]; // FR
mix[MOTOR_FL] = throttle + pidoutput[0] - pidoutput[1] - pidoutput[2]; // FL
mix[MOTOR_BR] = throttle - pidoutput[0] + pidoutput[1] - pidoutput[2]; // BR
mix[MOTOR_BL] = throttle + pidoutput[0] + pidoutput[1] + pidoutput[2]; // BL
#ifdef INVERT_YAW_PID
// we invert again cause it's used by the pid internally (for limit)
pidoutput[2] = -pidoutput[2];
#endif
// we invert again cause it's used by the pid internally (for limit)
if (currentdir == REVERSE)
{
// inverted flight
pidoutput[ROLL] = -pidoutput[ROLL];
pidoutput[PITCH] = -pidoutput[PITCH];
pidoutput[YAW] = -pidoutput[YAW];
}
#ifdef MIX_LOWER_THROTTLE_3
{
float overthrottle = 0;
for (int i = 0; i < 4; i++)
{
if (mix[i] > overthrottle)
overthrottle = mix[i];
}
overthrottle -=1.0f;
// limit to half throttle max reduction
if ( overthrottle > 0.5f) overthrottle = 0.5f;
if ( overthrottle > 0.0f)
{
for ( int i = 0 ; i < 4 ; i++)
mix[i] -= overthrottle;
}
#ifdef MIX_LOWER_THROTTLE_3_FLASHLED
if ( overthrottle > 0.1f) ledcommand = 1;
#endif
}
#endif
#if ( defined MIX_LOWER_THROTTLE || defined MIX_INCREASE_THROTTLE)
//#define MIX_INCREASE_THROTTLE
// options for mix throttle lowering if enabled
// 0 - 100 range ( 100 = full reduction / 0 = no reduction )
#ifndef MIX_THROTTLE_REDUCTION_PERCENT
#define MIX_THROTTLE_REDUCTION_PERCENT 100
#endif
// lpf (exponential) shape if on, othewise linear
//#define MIX_THROTTLE_FILTER_LPF
// limit reduction and increase to this amount ( 0.0 - 1.0)
// 0.0 = no action
// 0.5 = reduce up to 1/2 throttle
//1.0 = reduce all the way to zero
#ifndef MIX_THROTTLE_REDUCTION_MAX
#define MIX_THROTTLE_REDUCTION_MAX 0.5
#endif
#ifndef MIX_THROTTLE_INCREASE_MAX
#define MIX_THROTTLE_INCREASE_MAX 0.2
#endif
#ifndef MIX_MOTOR_MAX
#define MIX_MOTOR_MAX 1.0f
#endif
float overthrottle = 0;
float underthrottle = 0.001f;
for (int i = 0; i < 4; i++)
{
if (mix[i] > overthrottle)
overthrottle = mix[i];
if (mix[i] < underthrottle)
underthrottle = mix[i];
}
overthrottle -= MIX_MOTOR_MAX ;
if (overthrottle > (float)MIX_THROTTLE_REDUCTION_MAX)
overthrottle = (float)MIX_THROTTLE_REDUCTION_MAX;
#ifdef MIX_THROTTLE_FILTER_LPF
if (overthrottle > overthrottlefilt)
lpf(&overthrottlefilt, overthrottle, 0.82); // 20hz 1khz sample rate
else
lpf(&overthrottlefilt, overthrottle, 0.72); // 50hz 1khz sample rate
#else
if (overthrottle > overthrottlefilt)
overthrottlefilt += 0.005f;
else
overthrottlefilt -= 0.01f;
#endif
// over
if (overthrottlefilt > (float)MIX_THROTTLE_REDUCTION_MAX)
overthrottlefilt = (float)MIX_THROTTLE_REDUCTION_MAX;
if (overthrottlefilt < -0.1f)
overthrottlefilt = -0.1;
overthrottle = overthrottlefilt;
if (overthrottle < 0.0f)
overthrottle = -0.0001f;
// reduce by a percentage only, so we get an inbetween performance
overthrottle *= ((float)MIX_THROTTLE_REDUCTION_PERCENT / 100.0f);
#ifndef MIX_LOWER_THROTTLE
// disable if not enabled
overthrottle = -0.0001f;
#endif
#ifdef MIX_INCREASE_THROTTLE
// under
if (underthrottle < -(float)MIX_THROTTLE_INCREASE_MAX)
underthrottle = -(float)MIX_THROTTLE_INCREASE_MAX;
#ifdef MIX_THROTTLE_FILTER_LPF
if (underthrottle < underthrottlefilt)
lpf(&underthrottlefilt, underthrottle, 0.82); // 20hz 1khz sample rate
else
lpf(&underthrottlefilt, underthrottle, 0.72); // 50hz 1khz sample rate
#else
if (underthrottle < underthrottlefilt)
underthrottlefilt -= 0.005f;
else
underthrottlefilt += 0.01f;
#endif
// under
if (underthrottlefilt < - (float)MIX_THROTTLE_REDUCTION_MAX)
underthrottlefilt = - (float)MIX_THROTTLE_REDUCTION_MAX;
if (underthrottlefilt > 0.1f)
underthrottlefilt = 0.1;
underthrottle = underthrottlefilt;
if (underthrottle > 0.0f)
underthrottle = 0.0001f;
underthrottle *= ((float)MIX_THROTTLE_REDUCTION_PERCENT / 100.0f);
#else
underthrottle = 0.001f;
#endif
if (overthrottle > 0 || underthrottle < 0 )
{ // exceeding max motor thrust
float temp = overthrottle + underthrottle;
for (int i = 0; i < 4; i++)
{
mix[i] -= temp;
}
}
// end MIX_LOWER_THROTTLE
#endif
#ifdef RATELIMITER_ENABLE
// rate limiter if motors limit exceeded
// 50mS lpf to remove vibrations
#define RATELIMITER_FILT_TIME_US 50e3
// reduce rates by half maximum 0.0 - 1.0 higher = more action
#define RATELIMITER_MULTIPLIER_LIMIT 0.5f
// at 1mS loop time 0.01 step takes 50mS to reach 0.5 reduction
#define RATELIMITER_P_TERM 1.0f
// variable for low pass filter
static float feedbackfilt = 1.0f ;
// limit exceeded by this amount
float excess = 0;
// motor thrust used by controls ( for one motor )
float range = (fabsf(pidoutput[0]) + fabsf(pidoutput[1]) +fabsf(pidoutput[2]));
{
float overthrottle = 0.0f;
float underthrottle = 0.01f;
for (int i = 0; i < 4; i++)
{
if (mix[i] > overthrottle)
overthrottle = mix[i];
if (mix[i] < underthrottle)
underthrottle = mix[i];
}
overthrottle -= 1.0f ;
if ( overthrottle > 0 )
excess = overthrottle;
if (underthrottle < 0)
excess += underthrottle;
}
float excess_ratio = RATELIMITER_P_TERM * (fabs(excess)) / range ;
if ( excess_ratio > (float) RATELIMITER_MULTIPLIER_LIMIT ) excess_ratio = (float) RATELIMITER_MULTIPLIER_LIMIT;
if ( excess_ratio < 0.0f ) excess_ratio = 0.0;
lpf( &feedbackfilt , excess_ratio , FILTERCALC( 1e3, RATELIMITER_FILT_TIME_US ) );
for ( int i = 0 ; i < 3 ; i++)
{
feedback[i] = 1.0f - feedbackfilt;
}
// end RATELIMITER_ENABLE
#endif
#ifdef MOTOR_FILTER
for (int i = 0; i < 4; i++)
{
mix[i] = motorfilter(mix[i], i);
}
#endif
#ifdef CLIP_FF
float clip_ff(float motorin, int number);
for (int i = 0; i < 4; i++)
{
mix[i] = clip_ff(mix[i], i);
}
#endif
for (int i = 0; i < 4; i++)
{
float test = motormap(mix[i]);
#ifdef MOTORS_TO_THROTTLE
test = throttle;
// flash leds in valid throttle range
ledcommand = 1;
// Spin all motors if the roll/pitch stick is centered.
// Otherwise select the motors to test by deflecting the roll/pitch stick.
if ( i == MOTOR_FL && ( rx[ROLL] > 0.5f || rx[PITCH] < -0.5f ) ) { test = 0; }
if ( i == MOTOR_BL && ( rx[ROLL] > 0.5f || rx[PITCH] > 0.5f ) ) { test = 0; }
if ( i == MOTOR_FR && ( rx[ROLL] < -0.5f || rx[PITCH] < -0.5f ) ) { test = 0; }
if ( i == MOTOR_BR && ( rx[ROLL] < -0.5f || rx[PITCH] > 0.5f ) ) { test = 0; }
// for battery lvc
mix[i] = test;
#warning "MOTORS TEST MODE"
#endif
#ifdef MOTOR_MIN_ENABLE
if (test < (float) MOTOR_MIN_VALUE)
{
test = (float) MOTOR_MIN_VALUE;
}
#endif
#ifdef MOTOR_MAX_ENABLE
if (test > (float) MOTOR_MAX_VALUE)
{
test = (float) MOTOR_MAX_VALUE;
}
#endif
#ifndef NOMOTORS
//normal mode
if (bridge_stage == BRIDGE_WAIT) {
pwm_set( i , 0 );
} else {
pwm_set( i , test );
}
#else
#warning "NO MOTORS"
#endif
}
thrsum = 0;
for (int i = 0; i < 4; i++)
{
if (mix[i] < 0)
mix[i] = 0;
if (mix[i] > 1)
mix[i] = 1;
thrsum += mix[i];
}
thrsum = thrsum / 4;
} // end motors on
// imu_calc();
}
/////////////////////////////
/////////////////////////////
#ifdef MOTOR_CURVE_6MM_490HZ
// the old map for 490Hz
float motormap(float input)
{
// this is a thrust to pwm function
// float 0 to 1 input and output
// output can go negative slightly
// measured eachine motors and prop, stock battery
// a*x^2 + b*x + c
// a = 0.262 , b = 0.771 , c = -0.0258
if (input > 1)
input = 1;
if (input < 0)
input = 0;
input = input * input * 0.262f + input * (0.771f);
input += -0.0258f;
return input;
}
#endif
#ifdef MOTOR_CURVE_6MM_H101_490HZ
float motormap( float input)
{
// H101 thrust curve for normal thrust direction
// a*x^2 + b*x + c
if (input > 1.0f) input = 1.0f;
if (input < 0) input = 0;
input = input*input*0.277f + input*(0.715f);
input += 0.0102f;
return input;
}
#endif
// 8k pwm is where the motor thrust is relatively linear for the H8 6mm motors
// it's due to the motor inductance cancelling the nonlinearities.
#ifdef MOTOR_CURVE_NONE
float motormap(float input)
{
return input;
}
#endif
#ifdef MOTOR_CURVE_85MM_8KHZ
// Hubsan 8.5mm 8khz pwm motor map
// new curve
float motormap(float input)
{
// Hubsan 8.5mm motors and props
if (input > 1)
input = 1;
if (input < 0)
input = 0;
input = input * input * 0.683f + input * (0.262f);
input += 0.06f;
return input;
}
#endif
#ifdef MOTOR_CURVE_85MM_8KHZ_OLD
// Hubsan 8.5mm 8khz pwm motor map
float motormap(float input)
{
// Hubsan 8.5mm motors and props
if (input > 1)
input = 1;
if (input < 0)
input = 0;
input = input * input * 0.789f + input * (0.172f);
input += 0.04f;
return input;
}
#endif
#ifdef MOTOR_CURVE_85MM_32KHZ
// Hubsan 8.5mm 8khz pwm motor map
float motormap(float input)
{
// Hubsan 8.5mm motors and props
if (input > 1)
input = 1;
if (input < 0)
input = 0;
input = input * input * 0.197f + input * (0.74f);
input += 0.067f;
return input;
}
#endif
#ifdef CUSTOM_MOTOR_CURVE
float motormap(float in)
{
float exp = CUSTOM_MOTOR_CURVE;
if ( exp > 1 ) exp = 1;
if ( exp < -1 ) exp = -1;
if (in > 1.0f) in = 1.0f;
if (in < 0) in = 0;
float ans = in * (in*in * exp + ( 1 - exp ));
if (ans > 1.0f) ans = 1.0f;
if (ans < 0) ans = 0;
return ans;
}
#endif
float hann_lastsample[4];
float hann_lastsample2[4];
// hanning 3 sample filter
float motorfilter(float motorin, int number)
{
float ans = motorin * 0.25f + hann_lastsample[number] * 0.5f + hann_lastsample2[number] * 0.25f;
hann_lastsample2[number] = hann_lastsample[number];
hann_lastsample[number] = motorin;
return ans;
}
float clip_feedforward[4];
// clip feedforward adds the amount of thrust exceeding 1.0 ( max)
// to the next iteration(s) of the loop
// so samples 0.5 , 1.5 , 0.4 would transform into 0.5 , 1.0 , 0.9;
float clip_ff(float motorin, int number)
{
if (motorin > 1.0f)
{
clip_feedforward[number] += (motorin - 1.0f);
//cap feedforward to prevent windup
if (clip_feedforward[number] > .5f)
clip_feedforward[number] = .5f;
}
else if (clip_feedforward[number] > 0)
{
float difference = 1.0f - motorin;
motorin = motorin + clip_feedforward[number];
if (motorin > 1.0f)
{
clip_feedforward[number] -= difference;
if (clip_feedforward[number] < 0)
clip_feedforward[number] = 0;
}
else
clip_feedforward[number] = 0;
}
return motorin;
}
unsigned long bridgetime = 0;
// the bridge sequencer creates a pause between motor direction changes
// that way the motors do not try to instantly go in reverse and have time to slow down
void bridge_sequencer(int dir)
{
if (dir == REVERSE && bridge_stage != BRIDGE_REVERSE)
{
if (bridge_stage == BRIDGE_FORWARD)
{
bridge_stage = BRIDGE_WAIT;
bridgetime = gettime();
pwm_dir(FREE);
extern float ierror[3];
ierror[0] = 0.0; ierror[1] = 0.0; ierror[2] = 0.0;
}
if (bridge_stage == BRIDGE_WAIT)
{
if (gettime() - bridgetime > BRIDGE_TIMEOUT)
{
// timeout has elapsed
bridge_stage = BRIDGE_REVERSE;
pwm_dir(REVERSE);
}
}
}
if (dir == FORWARD && bridge_stage != BRIDGE_FORWARD)
{
if (bridge_stage == BRIDGE_REVERSE)
{
bridge_stage = BRIDGE_WAIT;
bridgetime = gettime();
pwm_dir(FREE);
extern float ierror[3];
ierror[0] = 0.0; ierror[1] = 0.0; ierror[2] = 0.0;
}
if (bridge_stage == BRIDGE_WAIT)
{
if (gettime() - bridgetime > BRIDGE_TIMEOUT)
{
// timeout has elapsed
bridge_stage = BRIDGE_FORWARD;
pwm_dir(FORWARD);
}
}
}
}
| 21.758955 | 214 | 0.62455 | [
"shape",
"vector",
"transform",
"3d"
] |
7f8c47d6d2a1267116702ffdd10efe740149da3a | 2,134 | h | C | guts/guts/debug_tools.h | Emberwalker/ac41001_opengl_cpp | c2f63fb6bb200a44f93e43af00b32a9d7b5df05a | [
"MIT"
] | 1 | 2017-10-31T16:03:47.000Z | 2017-10-31T16:03:47.000Z | guts/guts/debug_tools.h | Emberwalker/ac41001_opengl_cpp | c2f63fb6bb200a44f93e43af00b32a9d7b5df05a | [
"MIT"
] | null | null | null | guts/guts/debug_tools.h | Emberwalker/ac41001_opengl_cpp | c2f63fb6bb200a44f93e43af00b32a9d7b5df05a | [
"MIT"
] | null | null | null | #ifndef GUTS_DEBUG_TOOLS_H
#define GUTS_DEBUG_TOOLS_H
#include <string>
#include <iostream>
#include <vector>
#include <glload/gl_4_1.hpp>
namespace guts {
// Used internally by PrintOpenGLErrors.
// Based on https://stackoverflow.com/a/378165
class OGLStackReporter {
public:
OGLStackReporter(const std::string &caller, const std::string &file,
int line);
bool operator()();
private:
std::string caller_;
std::string file_;
int line_;
};
// Prints out all the current OpenGL errors in the context. Includes file/line
// and calling function in the error message. That allows you to just
// scatter-shot these statements everywhere there *might* be an issue.
#undef PrintOpenGLErrors
#define PrintOpenGLErrors OGLStackReporter(__FUNCTION__,__FILE__,__LINE__)
// Internal. Used by the guts_assert macro.
void __GutsAssert(const std::string &fn, const std::string &file, int ln,
bool condition, const std::string &msg);
// Internal. Used by the guts_assert macro.
[[noreturn]]
void __GutsError(const std::string &fn, const std::string &file, int ln,
const std::string &msg);
} // namespace guts
// Prepend a parameter with __unused to silence 'unused parameter' warnings.
#undef __unused
#ifdef _MSC_VER // MSVC
// Windows doesn't like this.
#define __unused
#else
#define __unused __attribute__((unused))
#endif // _MSC_VER
// Custom assertion method that includes a message, and tells you exactly where
// something failed an assertion.
#undef guts_assert
#define guts_assert(condition, msg) guts::__GutsAssert(__FUNCTION__,__FILE__,__LINE__, condition, msg)
// Error method for probably-never-happen type issues. Unlike guts_assert, this
// is marked as non-returning. Equivalent to calling guts_assert(false, "...");
#undef guts_error
#define guts_error(msg) guts::__GutsError(__FUNCTION__,__FILE__,__LINE__, msg)
// Handy little macro for marking things that aren't quite finished yet.
#undef NOT_IMPLEMENTED
#define NOT_IMPLEMENTED { guts::__GutsError(__FUNCTION__,__FILE__,__LINE__, "Not implemented."); }
#endif //GUTS_DEBUG_TOOLS_H
| 31.382353 | 102 | 0.743205 | [
"vector"
] |
7f8c7393498e79d85e86d71ee1c569f679bfd4de | 2,135 | h | C | include/slaanesh/KeeperOfSecrets.h | rweyrauch/AoSSimulator | d2bfbbe0fab904cc543f1a01e62e0b82cf67c27b | [
"MIT"
] | 5 | 2019-02-01T01:41:19.000Z | 2021-06-17T02:16:13.000Z | include/slaanesh/KeeperOfSecrets.h | rweyrauch/AoSSimulator | d2bfbbe0fab904cc543f1a01e62e0b82cf67c27b | [
"MIT"
] | 2 | 2020-01-14T16:57:42.000Z | 2021-04-01T00:53:18.000Z | include/slaanesh/KeeperOfSecrets.h | rweyrauch/AoSSimulator | d2bfbbe0fab904cc543f1a01e62e0b82cf67c27b | [
"MIT"
] | 1 | 2019-03-02T20:03:51.000Z | 2019-03-02T20:03:51.000Z | /*
* Warhammer Age of Sigmar battle simulator.
*
* Copyright (C) 2019 by Rick Weyrauch - rpweyrauch@gmail.com
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
#pragma once
#include <slaanesh/SlaaneshBase.h>
#include <Weapon.h>
namespace Slaanesh {
class KeeperOfSecrets : public SlaaneshBase {
public:
enum WeaponOption {
Ritual_Knife,
Sinistrous_Hand,
Living_Whip,
Shining_Aegis
};
static Unit *Create(const ParameterList ¶meters);
static void Init();
static std::string ValueToString(const Parameter ¶meter);
static int EnumStringToInt(const std::string &enumString);
static int ComputePoints(const ParameterList& parameters);
KeeperOfSecrets(Host host, WeaponOption weapon, Lore lore, CommandTrait trait, Artefact artefact, bool isGeneral);
~KeeperOfSecrets() override = default;
protected:
size_t getDamageTableIndex() const;
void onWounded() override;
void onRestore() override;
void onStartCombat(PlayerId player) override;
void onEndCombat(PlayerId player) override;
Wounds applyWoundSave(const Wounds &wounds, Unit *attackingUnit) override;
Wounds weaponDamage(const Model* attackingModel, const Weapon *weapon, const Unit *target, int hitRoll, int woundRoll) const override;
private:
WeaponOption m_weapon = Ritual_Knife;
Weapon m_livingWhip,
m_ritualKnifeOrHand,
m_greatblade,
m_impalingClaws;
static bool s_registered;
};
//
// Abilities Implemented
// -------------------------------------------
// Ritual Knife Yes
// Dark Temptations Partial/TODO
// Delicate Precision Yes
// Living Whip Yes
// Shining Aegis Yes
// Sinistrous Hand Partial/TODO
// Cacophonic Choir Yes
// Excess of Violence TODO
//
} // Slannesh
| 26.358025 | 142 | 0.605152 | [
"model"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.