Commit Graph

125 Commits

Author SHA1 Message Date
Behdad Esfahbod 3f08750fa6 Move _POSIX_SOURCE to hb.hh 2018-09-30 18:23:34 +02:00
Behdad Esfahbod 90a0f9fa0c Make TSan happy with make_immutable() 2018-09-26 15:03:07 -04:00
Matt Oliver 24dd6c1a9d src/hb-blob.cc: Fix mmap functionality with UWP. 2018-09-23 07:23:58 -07:00
Behdad Esfahbod c77ae40852 Rename hb-*private.hh to hb-*.hh
Sorry for the noise, downstream custom builders.  Please adjust.
2018-08-25 22:36:36 -07:00
Behdad Esfahbod 3506672ce9 Port _nil objects to Null() machinery
Finally, unified!
2018-08-06 06:17:48 -07:00
Behdad Esfahbod be458eb059 Include more basic internal headers from hb-private.hh 2018-07-10 14:41:04 +02:00
Ebrahim Byagowi d8a7dedc83
Use CreateFileW explicitly and pass wchar_t to it (#1087) 2018-07-04 15:33:39 +04:30
Behdad Esfahbod 2cb075fe26 Fix unused function '_hb_mapped_file_destroy' if no mmap 2018-07-03 13:04:05 +04:30
Ebrahim Byagowi 5d8cafcf6a
Improve nommap naming and use C style comments on create_from_file (#1084) 2018-07-01 01:54:14 +04:30
Ebrahim Byagowi 25970a93aa
armcc compatibility, don't use EINTR if doesn't exist
Fixes #1081
2018-06-28 14:32:36 +04:30
Ebrahim Byagowi 8a51f91b70
Minor on hb_blob_create_from_file, reuse ferror result
Oops
2018-06-28 13:22:21 +04:30
Ebrahim Byagowi 7b4099f35f
Minor, rename blob to data on blob_from_file 2018-06-27 16:54:44 +04:30
Ebrahim Byagowi fa090ed4d4
Minor touches on hb_blob_create_from_file (#1079)
* Handle EINTR on fallback reader
* Increase fallback reader limitation size limitation to 2 << 28
* Ensure _O_BINARY does exist if MMAP is used on Windows
  (maybe superfluous but makes me more confident)
2018-06-27 14:13:26 +04:30
Ebrahim Byagowi 7db2e9ea38
Minor on hb_blob_create_from_file
Add one more "unlikely" annotation and use explicit nullptr check for more consistency.
2018-06-26 10:46:10 +04:30
Ebrahim Byagowi 35ce8f31d3
Unify our pipe reader with the fallback reader (#1068)
And assign one bot to use the path always using NOMMAPFILEREADER token.

It's limited to 200mb so no more fun with using /dev/zero on hb-view!
2018-06-25 22:23:43 +04:30
Ebrahim Byagowi 941f2b8548
Support pipe and friends on hb_blob_create_from_file (#1061)
With this hb-view/hb-shape support pipes and possibly socket and named pipe
also, anything fails just on mmap.

We can later do the same for Windows also.

This however reveals two issues, the fact most of our bots don't have HAVE_MMAP and using
this instead the other fread/fopen reader can make failure on CI. I should look at them separately
this change however is very low risk I believe.
2018-06-18 20:35:40 +04:30
Behdad Esfahbod df01f3e560 1.7.7 2018-06-05 15:18:16 -07:00
Ebrahim Byagowi 65c82179c9
[blob] Use MAP_NORESERVE if available (#1039)
MAP_NORESERVE is not available on macOS for example so set the flag
to zero if not defined on the headers.
2018-05-26 23:50:10 +04:30
Ebrahim Byagowi 8eb53b853d
Minor, make CreateFile compatible with the disabled writable flag
"writable" is not in use and probably we can go in the reverse direction
and remove the flags that are useful for enabled writable, this is just
for the sake of completeness however.
2018-05-11 22:44:44 +04:30
Ebrahim Byagowi 33eb1bd23b
Remove unnecessary headers and definitions of hb-blob (#1028)
It removes io.h and other polyfills which we no longer need as 7e76d74
2018-05-11 14:36:41 +04:30
Ebrahim Byagowi 7e76d746e2
Make hb_blob_create_from_file more portable (#1027)
This makes it compatible with ARMCC which I had access in
a collaboration with @imgtec, thanks!

Basically hb_blob_create_from_file features three code paths,
mmap, Win32 and fallback.

We had fallback implementation even before this but it was relied
to "open" which is not available on some environments. This change
improved the situtation by using only fopen and friends for
fallback path.

Interestingly we could use "open" on Windows but in fact it was
emulated by MSVCRT so I've completely split that from Unix path
now that we have a distinct path for fallback path also.
2018-05-11 13:40:33 +04:30
Behdad Esfahbod 90baf72197 Move some blob functions to methods 2018-05-07 13:38:19 -07:00
Behdad Esfahbod 5c64d61475 Add hb-blob-private.hh
Towards making blob more memory-allocation-friendly
2018-05-07 13:38:19 -07:00
Ebrahim Byagowi 5ad87a93fe
Minor, improve file reading failing condition comment
https://bugzilla.gnome.org/show_bug.cgi?id=659212 for more context
2018-04-25 16:44:04 +04:30
Ebrahim Byagowi 8100380d9e
Minor, fix calloc call order 2018-04-22 10:58:37 +04:30
Ebrahim Byagowi ce17340b23 Add hb_blob_create_from_file, a new API (#926) 2018-04-20 07:59:06 +02:00
Behdad Esfahbod a989f3edec Add hb_blob_copy_writable_or_fail()
New API:
- hb_blob_copy_writable_or_fail()
2018-02-13 22:12:36 -08:00
Bruce Mitchener 90218fa93c Fix typos. 2018-01-31 08:18:15 -08:00
Ting-Wei Lan e3a15d0c6d Update _POSIX_C_SOURCE to the latest version
Defining _POSIX_C_SOURCE to an old version on FreeBSD can cause C99 to
be disabled in libc.
2018-01-12 09:19:41 +01:00
Behdad Esfahbod 40ec3bbb55 Consolidate debug stuff into hb-debug.hh
Part of fixing https://github.com/behdad/harfbuzz/pull/605
2017-11-03 17:18:17 -04:00
Behdad Esfahbod dbdbfe3d7b Use nullptr instead of NULL 2017-10-15 12:11:08 +02:00
Behdad Esfahbod e1b6d92302 Remove cast of functions to (hb_destroy_func_t)
Fixes https://github.com/behdad/harfbuzz/issues/474
2017-10-11 15:51:31 +02:00
Behdad Esfahbod 568a0c60e8 Remove pointless overflow check in pointer math
Fixes https://github.com/behdad/harfbuzz/issues/227
2016-02-18 19:31:51 +07:00
Behdad Esfahbod b8811429b6 Fix Since tags
Fixes https://github.com/behdad/harfbuzz/issues/103
2015-09-03 15:53:22 +04:30
Behdad Esfahbod 2cd5323531 [bindings] Use hb_glib_blob_create() in sample
hb_blob_create() is considered C-only API.
2015-01-06 19:16:38 -08:00
Behdad Esfahbod b91904a40d [bindings] Replace deprecated allow-none with optional and nullable 2015-01-06 15:43:14 -08:00
Behdad Esfahbod b632e7997d Fix up gobject-introspection a bit
Minimal shaping works now!
2015-01-06 14:05:26 -08:00
Behdad Esfahbod 7d5e7613ce Fail blob creation if length overflows or is too large
Fail if blob start plus length overflows; or if blob length
is greater than 2GB.  It takes a while for fonts to get to that
size.  In the mean time, it protects against bugs like this:

  http://www.icu-project.org/trac/ticket/11450

Also avoids some weird issues with 32bit vs 64bit systems
as we accept length as unsigned int.  As such, a length of
-1 will cause overflow on 32bit machines, but happily
accepted on a 64bit machine.  Avoid that.
2014-12-18 18:22:21 -08:00
Behdad Esfahbod 73f7f8919e Define _POSIX_C_SOURCE only if it is not defined
Fixes https://github.com/behdad/harfbuzz/pull/45
2014-07-09 17:17:18 -04:00
Behdad Esfahbod 2a8c49ade0 Remove unnecessary includes 2013-12-11 20:24:20 -05:00
Behdad Esfahbod a8949df487 [introspection] Annotate Unicode / font callbacks
Should move these out of the public header...

We're "clean" of introspection warnings now.  Remaining ones are about
graphite2 / freetype types not being introspectable.
2013-09-13 20:31:07 -04:00
Behdad Esfahbod dfdbe7f932 [introspection] Make hb_blob_create() introspectable 2013-09-12 20:52:20 -04:00
Behdad Esfahbod 085d4291a9 [introspection] Disable constructors for now
Since our types are not associated with their methods, marking
constructors makes them inaccessible from bindings.  Undo for now.
2013-09-12 17:14:33 -04:00
Behdad Esfahbod 288f289997 [docs/introspection] More annotations 2013-09-06 17:30:54 -04:00
Behdad Esfahbod 5f512017ba [docs] Document a few symbols 2013-09-05 16:40:32 -04:00
Behdad Esfahbod c3ba49b6fa Always create sub-blobs in MEMORY_MODE_READONLY
This fixes a design bug with sanitize and sub-blobs that can
cause crashes.  Jonathan and I found and debugged this issue
when we tested a corrupt font with the md5sum / filename:
ea395483d37af0cb933f40689ff7b60a.  Two hours of intense
debugging we found out that the font has overlapping GSUB/GPOS
tables, and as such, sanitizing the second table can modify
the first one, which can cause all kinds of undefined behavior.

The correct way to fix this is to make sure sub-blobs are
always created readonly, since we consider the parent blob
to be a shared resource and can't modify it, even if it *is*
writable.

This essentially makes the READONLY_MAY_MAKE_WRITABLE mode
unused...  Maybe we should simply remove / deprecate it.
2013-02-25 17:06:35 -05:00
Behdad Esfahbod 52c8d1226f Minor 2013-01-14 13:51:46 -06:00
Behdad Esfahbod f88d3bd7e4 Fix build with Sun compiler 2013-01-14 00:33:58 -06:00
Behdad Esfahbod 1bc1cb3603 Make source more digestable for gobject-introspection 2012-06-16 15:21:55 -04:00
Behdad Esfahbod 6220e5fc0d Add ASSERT_POD for most objects 2012-06-06 03:30:09 -04:00
Behdad Esfahbod 0594a24484 Cleanup TRUE/FALSE vs true/false 2012-06-05 20:35:40 -04:00
Behdad Esfahbod f06ab8a426 Better hide nil objects and make them const 2012-06-05 14:49:14 -04:00
Behdad Esfahbod bc71ad4973 Fix atomic-int op on Apple
The OSAtomicAdd32Barrier operator returns the new value, we want the
old value.
2012-03-01 17:30:29 -08:00
Behdad Esfahbod b95324cdd2 Minor 2011-09-21 16:50:39 -04:00
Behdad Esfahbod 33ccc77902 [API] Make set_user_data() functions take a replace parameter
We need this to set data on objects safely without worrying that some
other thread unsets it by setting it at the same time.
2011-08-09 00:43:24 +02:00
Behdad Esfahbod c605bbbb6d Remove C++ guards from source files
Where causing issues for people with MSVC.
2011-08-04 20:00:53 -04:00
Behdad Esfahbod cc06c243d8 Streamline debugging infrastructure even more 2011-07-25 20:34:17 -04:00
Behdad Esfahbod 43ff203d8e Use variadic macros for debugging
Looks *so* much nicer!
2011-07-25 17:35:24 -04:00
Behdad Esfahbod decd4e3e16 Add sugar syntax for debug messages
Buffer debugging coming soon.
2011-07-25 16:47:02 -04:00
Behdad Esfahbod b9452bfc16 Fix compiler warnings with -pedantic 2011-06-14 14:47:07 -04:00
Behdad Esfahbod 4101ca7dbb Plug more leaks
All good now.
2011-05-11 14:30:56 -04:00
Behdad Esfahbod 1c9f8717eb [API] Simplify blob API, remove lock 2011-05-06 22:59:42 -04:00
Behdad Esfahbod a0f337a1cc Remove unused hb_blob_try_writable_inplace() 2011-05-06 19:20:52 -04:00
Behdad Esfahbod b81bd42951 Make hb_mutex_*() macros take a pointer
More intuitive.
2011-05-05 00:21:16 -04:00
Behdad Esfahbod 56eb5ad6f9 Move code around
Mutex (and Windows.h by extension) are fairly isolated now.
2011-05-04 19:27:37 -04:00
Behdad Esfahbod d4141a44b9 [blob] Implement sub_blob() in terms of create()
Fixes problem with uninitialized sub_blob->mutex among other things.

Reported by Bradley Grainger.
2011-05-03 00:19:18 -04:00
Behdad Esfahbod f55272ecde Add hb_mutex_free() and use it
Based on patch by Bradley Grainger.
2011-05-02 20:57:28 -04:00
Behdad Esfahbod 4911062d5b [API] Rename hb_blob_create_empty() to hb_blob_get_empty() 2011-05-02 19:36:39 -04:00
Behdad Esfahbod 5fa849b77d [API] Add _set/get_user_data() for all objects 2011-04-27 21:46:01 -04:00
Behdad Esfahbod 47e71d9661 [object] Remove unnecessary use of macros 2011-04-27 16:41:08 -04:00
Behdad Esfahbod 8be1420f8f [blob] Use HB_FUNC instead of __FUNCTION__ 2011-04-27 16:16:43 -04:00
Behdad Esfahbod fca368c468 Add hb_object_header_t which is the common part of all objects
Makes way for adding arbitrary user_data support.
2011-04-21 18:24:02 -04:00
Behdad Esfahbod 2409d5f8d7 Update Copyright headers 2011-04-21 17:14:28 -04:00
Behdad Esfahbod c57d454acc Rename all private sources and headers to C++ files
So we can liberally use the simple features of C++ that parts of the
codebase is already using.
2011-04-20 18:50:27 -04:00
Behdad Esfahbod f19f4f9b09 Rename hb-blob.c to hb-blob.cc in preparation of more changes 2011-04-20 18:25:56 -04:00