Commit Graph

11461 Commits

Author SHA1 Message Date
Behdad Esfahbod
0983601399 Add back wider cast to IntType
My local clang12 is fine, but many bots are not:

../src/hb-ot-cff1-table.hh: In instantiation of ‘bool CFF::Charset1_2<TYPE>::sanitize(hb_sanitize_context_t*, unsigned int) const [with TYPE = OT::IntType<unsigned char>]’:
../src/hb-ot-cff1-table.hh:554:13:   required from here
../src/hb-ot-cff1-table.hh:377:60: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
       if (unlikely (!ranges[i].sanitize (c) || (num_glyphs < ranges[i].nLeft + 1)))
                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Enabling the extra cast operator mentioned in previous commit to see if
that fixes this case.

Again, I'd be happy to say "use 1u instead of 1" if this was universally
erred on.  But since some compilers happily compile this while others
err, it would be a huge headache. Let's see...

https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 22:33:17 -07:00
Behdad Esfahbod
567cedcc5f Narrow down cast operators on IntType
Say for USHORT, we were implementing casts from and to unsigned.
With this change, we cast from and to uint16_t only.  This allows
compiler more opportunities to catch possible narrowing issues in
the code.

It needed a couple of fixes in the codebase though, because
previously, if a USHORT was participating in arithmetic with signed
numbers, eg. "u + 1", the result would have been unsigned.  With
this change, it would be signed.  The correct fix is to update the
code to read "u + 1u".

That said, I think about conditionally adding back the cast
out to signed/unsigned, to facilitate better type deduction.
But I couldn't think of a real situation where that would help
with anything.  So I didn't add.  Here's what it was:

  template <typename Type2 = hb_conditional<hb_is_signed (Type), signed, unsigned>,
           hb_enable_if (sizeof (Type) < sizeof (Type2))>
  operator hb_type_identity_t<Type2> () const { return v; }

https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 22:32:42 -07:00
Behdad Esfahbod
f4f35a4d5f [constexpr] Use initializer instead of assignment 2021-02-22 22:32:42 -07:00
Behdad Esfahbod
cc16b26ef4 [constexpr] IntType
See https://github.com/harfbuzz/harfbuzz/pull/2875
2021-02-22 21:59:56 -07:00
Behdad Esfahbod
8b2f9adf29 m Simplify Tag operator char* 2021-02-22 17:42:24 -07:00
Behdad Esfahbod
021a1725ed
Merge pull request #2874 from harfbuzz/constexpr2
Some more cleanup towards using constexpr to simplify our internal datastrcutures.

https://github.com/harfbuzz/harfbuzz/pull/2874
2021-02-22 17:40:22 -07:00
Behdad Esfahbod
11c28cb5fa [cmake] Define HAVE_PTHREAD if not on win32
Yeah...
2021-02-22 17:38:53 -07:00
Behdad Esfahbod
b368a0736b [atomic] Remove IBM/AIX implementation
The C++11 implementation shall be enough for everyone.
2021-02-22 17:24:09 -07:00
Behdad Esfahbod
52f9126960 [atomic] Remove Windows implementation
Since we require C++11 now, there's no point to do a macro version check.
Which means we don't hit the MSVC issue defining __cplusplus wrongly.
2021-02-22 17:22:09 -07:00
Behdad Esfahbod
a666fe64a9 [atomic] Comment 2021-02-22 17:21:27 -07:00
Behdad Esfahbod
3528a21e8d [atomic] Remove Apple implementation
Continuation of https://github.com/harfbuzz/harfbuzz/pull/676
2021-02-22 17:19:43 -07:00
Behdad Esfahbod
140797d4a2 [constexpr] hb_atomic_int_t 2021-02-22 17:19:26 -07:00
Behdad Esfahbod
2ec802b42a [object] Simplify reference_count_t 2021-02-22 17:18:47 -07:00
Behdad Esfahbod
4d116ed0f0 [ci] Remove cmake
Apparently(?) our cmake build never bothered setting up pthreads.
So when I removed the busy-loop mutex impl it now doesn't build.

711c241f6c

https://github.com/harfbuzz/harfbuzz/pull/2874#issuecomment-782778263
2021-02-22 17:14:45 -07:00
Behdad Esfahbod
1c693e8c28 [test] Fix unused-var warning 2021-02-22 17:11:36 -07:00
Behdad Esfahbod
12a283d513 m[ft] No need to use atomic ops for cached_x_scale
We have added a mutex since, so no need for atomicity.
2021-02-22 12:51:09 -07:00
Behdad Esfahbod
b39c1f7829 a[build] Fix distcheck 2021-02-20 15:46:17 -07:00
Behdad Esfahbod
a3c35aee30 m Move HB_SCRIPT_MYANMAR_ZAWGYI 2021-02-20 15:45:34 -07:00
Behdad Esfahbod
c55bf55154 Remove HB_CONST_FUNC and HB_PURE_FUNC
They are not necessary for inline functions.
2021-02-20 15:45:12 -07:00
Behdad Esfahbod
cba9893ac5 m[algs] Move roundf() here 2021-02-20 15:44:47 -07:00
Behdad Esfahbod
f0947717ff m[machinery] Move HB_VAR_ARRAY here 2021-02-20 15:44:25 -07:00
Behdad Esfahbod
69464e9da0 [algs] Another try at fixing BEInt constexpr
../src/hb-algs.hh:120:3: error: body of constexpr function ‘constexpr BEInt<Type, 2>::operator Type() const [with Type = short unsigned int]’ not a return-statement
2021-02-20 15:42:44 -07:00
Behdad Esfahbod
ff7bf88192 m[algs] Fix BEInt -Wnarrowing errors 2021-02-20 15:39:29 -07:00
Behdad Esfahbod
a89d9f25b4 m Err on -Wnarrowing instead of -Wc++11-narrowing
On clang, -Wnarrowing is synonym for -Wc++11-narrowing.
On gcc it isn't. So, use the widely-available one
2021-02-20 15:38:05 -07:00
Behdad Esfahbod
e208f80449 Make constexpr BEInt<Type, 2>::operator Type() C++11-compatible
Multiple return values not permitted until C++14
2021-02-20 15:31:43 -07:00
Behdad Esfahbod
c2fc2aa44c [atomic] Remove Solaris intrinsics 2021-02-20 15:20:33 -07:00
Behdad Esfahbod
7099a6dca1 [atomic] Remove old Intel primitives implementation 2021-02-20 15:20:06 -07:00
Behdad Esfahbod
711c241f6c m[mutex] Remove busyloop mutex implemenation
Don't know why I ever added this. :)
2021-02-20 15:16:59 -07:00
Behdad Esfahbod
47f01c0726 m[algs] Move BEInt here 2021-02-20 15:14:50 -07:00
Behdad Esfahbod
e5b7bc424d m Add default value to BEInt<> Size template parameter 2021-02-20 15:14:15 -07:00
Behdad Esfahbod
2caae4a59a m Move class traits 2021-02-20 15:13:52 -07:00
Behdad Esfahbod
c2dbd6cc0f Remove static_assert of sizeof basic sized int types 2021-02-20 15:11:47 -07:00
Behdad Esfahbod
e1706ffecd m [algs] Move flags here 2021-02-20 15:11:26 -07:00
Behdad Esfahbod
017f6b0d24 m Move static_assert_expr<> 2021-02-20 15:11:14 -07:00
Behdad Esfahbod
61f8d0e57d m Rename ASSERT_STATIC_EXPR_ZERO to static_assert_expr 2021-02-20 15:08:19 -07:00
Behdad Esfahbod
59cfffb1af m Change ASSERT_STATIC_EXPR_ZERO template arg type to bool 2021-02-20 15:07:28 -07:00
Behdad Esfahbod
1981d83d7f [constexpr] HB_MARK_AS_FLAG_T 2021-02-20 15:07:14 -07:00
Behdad Esfahbod
a4a99de0eb [constexpr] bswap 2021-02-20 15:07:07 -07:00
Behdad Esfahbod
f8ebe1dacd [constexpr] BEInt 2021-02-20 15:06:12 -07:00
Behdad Esfahbod
2fbd34f89a m[set/map] Add operator bool()
Probably should use in places..
2021-02-19 18:40:48 -07:00
Behdad Esfahbod
bf75a0a03a m[dispatch] Use inline class member initialization
Let's see how bots like this...
2021-02-19 18:40:48 -07:00
Behdad Esfahbod
82928d9cf6 m[blob] Move immutable check to C API boundary
Similarly to 08ed9e3f779253e3b5f01c38d44d0e5db2d5e7aa
2021-02-19 18:40:48 -07:00
Behdad Esfahbod
4020c6b286 m[blob] An empty blob can always be made writable 2021-02-19 18:40:48 -07:00
Behdad Esfahbod
2d39031f7b [buffer/set/map] Move immutable check only to C API boundary
The immutable objects are a concept only enforced by the C API.
So move checks only to that region.

This does assume that the rest of the code is careful not getting
into these internal methods on immutable objects, which something
we do, but have no way of enforcing (currently).

.
2021-02-19 18:40:48 -07:00
Behdad Esfahbod
6d83d44052 m[set] Recover set from error in .reset() 2021-02-19 18:40:48 -07:00
Behdad Esfahbod
445efe8d04 m[vector] Recover vector from error in .reset() 2021-02-19 18:40:48 -07:00
Behdad Esfahbod
21433fa563 m[buffer] In hb_buffer_append() don't change until allocation success 2021-02-19 18:40:48 -07:00
Behdad Esfahbod
0f61a6213a m[vowels] Simplify
If we didn't "process" anything, swap_buffers() becomes a no-op.
2021-02-19 18:40:48 -07:00
Behdad Esfahbod
3b91e0b592 m[buffer] Rename internal variable 2021-02-19 18:40:48 -07:00
Behdad Esfahbod
9fcba109bf [buffer] Make swap_buffers() copy rest 2021-02-19 18:40:48 -07:00