Fix scratch-buffer alignment warnings
This commit is contained in:
parent
c7c4ccf8a1
commit
16f175cb2e
|
@ -186,7 +186,7 @@ struct hb_buffer_t {
|
||||||
HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
|
HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
|
||||||
HB_INTERNAL bool shift_forward (unsigned int count);
|
HB_INTERNAL bool shift_forward (unsigned int count);
|
||||||
|
|
||||||
HB_INTERNAL void *get_scratch_buffer (unsigned int *size);
|
HB_INTERNAL int *get_scratch_buffer (unsigned int *int_size);
|
||||||
|
|
||||||
inline void clear_context (unsigned int side) { context_len[side] = 0; }
|
inline void clear_context (unsigned int side) { context_len[side] = 0; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -152,8 +152,8 @@ hb_buffer_t::shift_forward (unsigned int count)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
int *
|
||||||
hb_buffer_t::get_scratch_buffer (unsigned int *size)
|
hb_buffer_t::get_scratch_buffer (unsigned int *int_size)
|
||||||
{
|
{
|
||||||
have_output = false;
|
have_output = false;
|
||||||
have_positions = false;
|
have_positions = false;
|
||||||
|
@ -161,8 +161,9 @@ hb_buffer_t::get_scratch_buffer (unsigned int *size)
|
||||||
out_len = 0;
|
out_len = 0;
|
||||||
out_info = info;
|
out_info = info;
|
||||||
|
|
||||||
*size = allocated * sizeof (pos[0]);
|
ASSERT_STATIC (sizeof (pos[0]) % sizeof (int) == 0);
|
||||||
return pos;
|
*int_size = allocated * (sizeof (pos[0]) / sizeof (int));
|
||||||
|
return (int *) pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -647,17 +647,20 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
|
||||||
|
|
||||||
buffer->ensure (buffer->len + num_glyphs);
|
buffer->ensure (buffer->len + num_glyphs);
|
||||||
|
|
||||||
/* Testing indicates that CTRunGetGlyphsPtr (almost?) always succeeds,
|
|
||||||
* and so copying data to our own buffer with CTRunGetGlyphs will be
|
|
||||||
* extremely rare. */
|
|
||||||
|
|
||||||
unsigned int scratch_size;
|
unsigned int scratch_size;
|
||||||
char *scratch = (char *) buffer->get_scratch_buffer (&scratch_size);
|
int *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||||
|
|
||||||
#define ALLOCATE_ARRAY(Type, name, len) \
|
#define ALLOCATE_ARRAY(Type, name, len) \
|
||||||
Type *name = (Type *) scratch; \
|
Type *name = (Type *) scratch; \
|
||||||
scratch += (len) * sizeof ((name)[0]); \
|
{ \
|
||||||
scratch_size -= (len) * sizeof ((name)[0]);
|
unsigned int _consumed = DIV_CEIL ((len) * sizeof (Type), sizeof (*scratch)); \
|
||||||
|
assert (_consumed <= scratch_size); \
|
||||||
|
scratch += _consumed; \
|
||||||
|
scratch_size -= _consumed; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Testing indicates that CTRunGetGlyphsPtr, etc (almost?) always
|
||||||
|
* succeed, and so copying data to our own buffer will be rare. */
|
||||||
|
|
||||||
const CGGlyph* glyphs = CTRunGetGlyphsPtr (run);
|
const CGGlyph* glyphs = CTRunGetGlyphsPtr (run);
|
||||||
if (!glyphs) {
|
if (!glyphs) {
|
||||||
|
|
|
@ -243,14 +243,9 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan,
|
||||||
float curradvx = 0., curradvy = 0.;
|
float curradvx = 0., curradvy = 0.;
|
||||||
|
|
||||||
unsigned int scratch_size;
|
unsigned int scratch_size;
|
||||||
char *scratch = (char *) buffer->get_scratch_buffer (&scratch_size);
|
int *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||||
|
|
||||||
#define ALLOCATE_ARRAY(Type, name, len) \
|
uint32_t *chars = (uint32_t *) scratch;
|
||||||
Type *name = (Type *) scratch; \
|
|
||||||
scratch += (len) * sizeof ((name)[0]); \
|
|
||||||
scratch_size -= (len) * sizeof ((name)[0]);
|
|
||||||
|
|
||||||
ALLOCATE_ARRAY (uint32_t, chars, buffer->len);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < buffer->len; ++i)
|
for (unsigned int i = 0; i < buffer->len; ++i)
|
||||||
chars[i] = buffer->info[i].codepoint;
|
chars[i] = buffer->info[i].codepoint;
|
||||||
|
@ -276,9 +271,9 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
scratch = (char *) buffer->get_scratch_buffer (&scratch_size);
|
scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||||
while ((sizeof (hb_graphite2_cluster_t) * buffer->len +
|
while ((DIV_CEIL (sizeof (hb_graphite2_cluster_t) * buffer->len, sizeof (*scratch)) +
|
||||||
sizeof (hb_codepoint_t) * glyph_count) > scratch_size)
|
DIV_CEIL (sizeof (hb_codepoint_t) * glyph_count, sizeof (*scratch))) > scratch_size)
|
||||||
{
|
{
|
||||||
buffer->ensure (buffer->allocated * 2);
|
buffer->ensure (buffer->allocated * 2);
|
||||||
if (unlikely (buffer->in_error)) {
|
if (unlikely (buffer->in_error)) {
|
||||||
|
@ -286,12 +281,23 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan,
|
||||||
gr_seg_destroy (seg);
|
gr_seg_destroy (seg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
scratch = (char *) buffer->get_scratch_buffer (&scratch_size);
|
scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ALLOCATE_ARRAY(Type, name, len) \
|
||||||
|
Type *name = (Type *) scratch; \
|
||||||
|
{ \
|
||||||
|
unsigned int _consumed = DIV_CEIL ((len) * sizeof (Type), sizeof (*scratch)); \
|
||||||
|
assert (_consumed <= scratch_size); \
|
||||||
|
scratch += _consumed; \
|
||||||
|
scratch_size -= _consumed; \
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOCATE_ARRAY (hb_graphite2_cluster_t, clusters, buffer->len);
|
ALLOCATE_ARRAY (hb_graphite2_cluster_t, clusters, buffer->len);
|
||||||
ALLOCATE_ARRAY (hb_codepoint_t, gids, glyph_count);
|
ALLOCATE_ARRAY (hb_codepoint_t, gids, glyph_count);
|
||||||
|
|
||||||
|
#undef ALLOCATE_ARRAY
|
||||||
|
|
||||||
memset (clusters, 0, sizeof (clusters[0]) * buffer->len);
|
memset (clusters, 0, sizeof (clusters[0]) * buffer->len);
|
||||||
|
|
||||||
hb_codepoint_t *pg = gids;
|
hb_codepoint_t *pg = gids;
|
||||||
|
|
|
@ -79,6 +79,9 @@ static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; }
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
static inline Type MAX (const Type &a, const Type &b) { return a > b ? a : b; }
|
static inline Type MAX (const Type &a, const Type &b) { return a > b ? a : b; }
|
||||||
|
|
||||||
|
static inline unsigned int DIV_CEIL (const unsigned int a, unsigned int b)
|
||||||
|
{ return (a + (b - 1)) / b; }
|
||||||
|
|
||||||
|
|
||||||
#undef ARRAY_LENGTH
|
#undef ARRAY_LENGTH
|
||||||
template <typename Type, unsigned int n>
|
template <typename Type, unsigned int n>
|
||||||
|
|
|
@ -729,15 +729,10 @@ _hb_uniscribe_shape (hb_shape_plan_t *shape_plan,
|
||||||
retry:
|
retry:
|
||||||
|
|
||||||
unsigned int scratch_size;
|
unsigned int scratch_size;
|
||||||
char *scratch = (char *) buffer->get_scratch_buffer (&scratch_size);
|
int *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||||
|
|
||||||
/* Allocate char buffers; they all fit */
|
/* Allocate char buffers; they all fit */
|
||||||
|
|
||||||
#define ALLOCATE_ARRAY(Type, name, len) \
|
|
||||||
Type *name = (Type *) scratch; \
|
|
||||||
scratch += (len) * sizeof ((name)[0]); \
|
|
||||||
scratch_size -= (len) * sizeof ((name)[0]);
|
|
||||||
|
|
||||||
#define utf16_index() var1.u32
|
#define utf16_index() var1.u32
|
||||||
|
|
||||||
WCHAR *pchars = (WCHAR *) scratch;
|
WCHAR *pchars = (WCHAR *) scratch;
|
||||||
|
@ -756,6 +751,15 @@ retry:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ALLOCATE_ARRAY(Type, name, len) \
|
||||||
|
Type *name = (Type *) scratch; \
|
||||||
|
{ \
|
||||||
|
unsigned int _consumed = DIV_CEIL ((len) * sizeof (Type), sizeof (*scratch)); \
|
||||||
|
assert (_consumed <= scratch_size); \
|
||||||
|
scratch += _consumed; \
|
||||||
|
scratch_size -= _consumed; \
|
||||||
|
}
|
||||||
|
|
||||||
ALLOCATE_ARRAY (WCHAR, wchars, chars_len);
|
ALLOCATE_ARRAY (WCHAR, wchars, chars_len);
|
||||||
ALLOCATE_ARRAY (WORD, log_clusters, chars_len);
|
ALLOCATE_ARRAY (WORD, log_clusters, chars_len);
|
||||||
ALLOCATE_ARRAY (SCRIPT_CHARPROP, char_props, chars_len);
|
ALLOCATE_ARRAY (SCRIPT_CHARPROP, char_props, chars_len);
|
||||||
|
@ -774,12 +778,13 @@ retry:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On Windows, we don't care about alignment...*/
|
/* All the following types are sized in multiples of sizeof(int). */
|
||||||
unsigned int glyphs_size = scratch_size / (sizeof (WORD) +
|
unsigned int glyphs_size = scratch_size / ((sizeof (WORD) +
|
||||||
sizeof (SCRIPT_GLYPHPROP) +
|
sizeof (SCRIPT_GLYPHPROP) +
|
||||||
sizeof (int) +
|
sizeof (int) +
|
||||||
sizeof (GOFFSET) +
|
sizeof (GOFFSET) +
|
||||||
sizeof (uint32_t));
|
sizeof (uint32_t))
|
||||||
|
/ sizeof (int));
|
||||||
|
|
||||||
ALLOCATE_ARRAY (WORD, glyphs, glyphs_size);
|
ALLOCATE_ARRAY (WORD, glyphs, glyphs_size);
|
||||||
ALLOCATE_ARRAY (SCRIPT_GLYPHPROP, glyph_props, glyphs_size);
|
ALLOCATE_ARRAY (SCRIPT_GLYPHPROP, glyph_props, glyphs_size);
|
||||||
|
|
Loading…
Reference in New Issue