freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] LFS support in builds/unix/ftsystem.c


From: Kenny Simpson
Subject: Re: [ft-devel] LFS support in builds/unix/ftsystem.c
Date: Sat, 21 Dec 2013 15:30:01 -0500

nevermind...  looks like this needs some #defining too...  will keep poking at it.

-Kenny


On Sat, Dec 21, 2013 at 3:18 PM, Kenny Simpson <address@hidden> wrote:
Here is the compile-tested patch for using O_CLOEXEC:

diff --git a/builds/unix/ftsystem.c b/builds/unix/ftsystem.c
index 7f7b3ac..1cb86e6 100644
--- a/builds/unix/ftsystem.c
+++ b/builds/unix/ftsystem.c
@@ -238,7 +238,11 @@
       return FT_THROW( Invalid_Stream_Handle );
 
     /* open the file */
+#ifdef O_CLOEXEC
+    file = open( filepathname, O_RDONLY | O_CLOEXEC );
+#else
     file = open( filepathname, O_RDONLY );
+#endif
     if ( file < 0 )
     {
       FT_ERROR(( "FT_Stream_Open:" ));
@@ -251,6 +255,7 @@
     /* since it avoids some (possible) access control      */
     /* issues and cleans up the kernel file table a bit.   */
     /*                                                     */
+#ifndef O_CLOEXEC
 #ifdef F_SETFD
 #ifdef FD_CLOEXEC
     (void)fcntl( file, F_SETFD, FD_CLOEXEC );
@@ -258,6 +263,7 @@
     (void)fcntl( file, F_SETFD, 1 );
 #endif /* FD_CLOEXEC */
 #endif /* F_SETFD */
+#endif /* !O_CLOEXEC */
 
     if ( fstat( file, &stat_buf ) < 0 )
     {

Let me know if I need to state anything about this being in the public domain, copyright assignment, etc...

-Kenny



On Sat, Dec 21, 2013 at 3:07 PM, Kenny Simpson <address@hidden> wrote:
Sorry for the delay... I looked into the autoconf stuff, but I got lost with the build system in freetype.
I see a jamfile, Makefile, CMakeList, etc... so I'm a bit lost as to which one(s) to care about.

One other thing I noticed was open+fcntl to set cloexec.  Would you be open to the use of #ifdef O_CLOEXEC in the file to use it if present, otherwise fall back to the existing fcntl() path?

-Kenny


On Sat, Nov 23, 2013 at 3:21 AM, Werner LEMBERG <address@hidden> wrote:

> Its been a while since I've fought with LFS issues and had thought
> them a thing of the past... let me know if there is an approved way
> to add this fix to freetype.

It would be great if you find some time to work on this.  I must admit
that I know the LFS acronym, but that's it :-)

For FreeType's Unix support, I suggest the following route:

  . Use the `AC_SYS_LARGEFILE' autoconf macro (in `configure.raw') to
    get the necessary compiler flags and macro definitions.

  . Use the `_LARGE_FILES' and `_FILE_OFFSET_BITS' macros (defined by
    `AC_SYS_LARGEFILE') where necessary to add new code.

Ideally, I would like to have a generic solution (cf. the
`FT_SIZEOF_INT' stuff in `ftconfig.h'), but I guess that this is not
possible due to the need of setting compiler flags for LFS support...


    Werner




reply via email to

[Prev in Thread] Current Thread [Next in Thread]