/* Generic streaming support for various data types.
- Copyright (C) 2011-2013 Free Software Foundation, Inc.
+ Copyright (C) 2011-2015 Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@google.com>
This file is part of GCC.
#ifndef GCC_DATA_STREAMER_H
#define GCC_DATA_STREAMER_H
-#include "vec.h"
#include "lto-streamer.h"
/* Data structures used to pack values and bitflags into a vector of
void streamer_write_gcov_count (struct output_block *, gcov_type);
void streamer_write_string (struct output_block *, struct lto_output_stream *,
const char *, bool);
-unsigned streamer_string_index (struct output_block *, const char *,
- unsigned int, bool);
void streamer_write_string_with_length (struct output_block *,
struct lto_output_stream *,
const char *, unsigned int, bool);
unsigned HOST_WIDE_INT);
void streamer_write_hwi_stream (struct lto_output_stream *, HOST_WIDE_INT);
void streamer_write_gcov_count_stream (struct lto_output_stream *, gcov_type);
+void streamer_write_data_stream (struct lto_output_stream *, const void *,
+ size_t);
/* In data-streamer-in.c */
-const char *string_for_index (struct data_in *, unsigned int, unsigned int *);
const char *streamer_read_string (struct data_in *, struct lto_input_block *);
const char *streamer_read_indexed_string (struct data_in *,
struct lto_input_block *,
lto_append_block (obs);
/* Write the actual character. */
- *obs->current_pointer = c;
- obs->current_pointer++;
+ char *current_pointer = obs->current_pointer;
+ *(current_pointer++) = c;
+ obs->current_pointer = current_pointer;
obs->total_size++;
obs->left_in_block--;
}
&& range < 0x7fffffff);
val -= min;
- streamer_write_char_stream (obs, val & 255);
- if (range >= 0xff)
- streamer_write_char_stream (obs, (val >> 8) & 255);
- if (range >= 0xffff)
- streamer_write_char_stream (obs, (val >> 16) & 255);
- if (range >= 0xffffff)
- streamer_write_char_stream (obs, (val >> 24) & 255);
+ streamer_write_uhwi_stream (obs, (unsigned HOST_WIDE_INT) val);
}
/* Input VAL into OBS and verify it is in range MIN...MAX that is supposed
HOST_WIDE_INT max)
{
HOST_WIDE_INT range = max - min;
- HOST_WIDE_INT val = streamer_read_uchar (ib);
+ unsigned HOST_WIDE_INT uval = streamer_read_uhwi (ib);
gcc_checking_assert (range > 0 && range < 0x7fffffff);
- if (range >= 0xff)
- val |= ((HOST_WIDE_INT)streamer_read_uchar (ib)) << 8;
- if (range >= 0xffff)
- val |= ((HOST_WIDE_INT)streamer_read_uchar (ib)) << 16;
- if (range >= 0xffffff)
- val |= ((HOST_WIDE_INT)streamer_read_uchar (ib)) << 24;
- val += min;
+ HOST_WIDE_INT val = (HOST_WIDE_INT) (uval + (unsigned HOST_WIDE_INT) min);
if (val < min || val > max)
lto_value_range_error (purpose, val, min, max);
return val;