[racket] flock() stops racket-5.1.1 build on Solaris x86

From: Tim Brown (tim.brown at cityc.co.uk)
Date: Mon May 23 07:52:12 EDT 2011

Hi all,

My never ending battle to get racket to play nice with Solaris continues:

uname -a:  SunOS ... 5.10 Generic_138889-03 i86pc i386 i86pc

racket:    racket-5.1.1-src-unix.tgz  -- exhibits error
            racket-5.1.-src-unix.tgz   -- exhibits error
            racket-5.0.2-src-unix.tgz  -- does not exhibit error

configure: ../configure --srcdir=.. --prefix=/usr/local CC=gcc CXX=g++
            (I'm using a target-specific build directory)

gcc:       gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)

Racket tries to use flock(... LOCK_EX / LOCK_SH / LOCK_NB / LOCK_UN ...).
During build, this throws: "implicit declaration of function `flock'" and
"`LOCK_EX' undeclared (first use in this function)".

gcc -I./.. -I../../../racket/src/../include -g -O2  -Wall 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c ../../../racket/src/port.c -o 
../../../racket/src/port.c: In function `try_lock':
../../../racket/src/port.c:4701: warning: implicit declaration of function 
../../../racket/src/port.c:4701: error: `LOCK_EX' undeclared (first use in 
this function)
../../../racket/src/port.c:4701: error: (Each undeclared identifier is 
reported only once
../../../racket/src/port.c:4701: error: for each function it appears in.)
../../../racket/src/port.c:4701: error: `LOCK_SH' undeclared (first use in 
this function)
../../../racket/src/port.c:4701: error: `LOCK_NB' undeclared (first use in 
this function)
../../../racket/src/port.c: In function `scheme_file_unlock':
../../../racket/src/port.c:4808: error: `LOCK_UN' undeclared (first use in 
this function)
gmake[6]: *** [port.o] Error 1

Solaris seems to take quite a dim view of flock(); from man flock():
>      Use of these interfaces should be restricted to only  appli-
>      cations  written  on BSD platforms.  Use of these interfaces
>      with any of the system libraries or in multi-thread applica-
>      tions is unsupported.

In fact flock() and LOCK_xx are defined in /usr/ucbinclude/sys/file.h;
which is included with /usr/ucb/cc (which I don't want to build racket

STREAMS and STREAM fds on Solaris use fcntl(F_GETLK/F_SETLK, F_SETLKW)
and their 64-bit counterparts F_GETLK64 etc. However, these need a pointer
to a lock structure to be managed/associated with the fd, and I'm not sure
what the best means to do this would be (there seems to be a neat solution
to a lot of the things in racket -- best left to the authors IMHO).

Personally, I'm not bothered (today, at the moment) with file locking, so
I'll Q&D patch try_lock with:

#if defined(UNIX_FILE_SYSTEM) && !defined(sun)
#if defined(UNIX_FILE_SYSTEM) && defined(sun)
   *_errid = ENOTSUP;
   return 0;

and scheme_file_unlock with:

int ok = 0, errid = ENOTSUP;
#if defined(UNIX_FILE_SYSTEM) && !defined(sun)

But is there any chance of a proper fcntl-based solution, then that would
be appreciated.



Tim Brown <tim.brown at cityc.co.uk>  | City Computing Limited            |
T: +44 20 8770 2110                | City House, Sutton Park Road      |
F: +44 20 8770 2130                | Sutton, Surrey, SM1 2AE, GB       |
BEAUTY:  What's in your eye when you have a bee in your hand           |
City Computing Limited registered in London No. 1767817.
Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
VAT number 372 8290 34.

Posted on the users mailing list.