From: Date: September 28 2000 6:15pm Subject: Re: porting to Darwin/Mac OS X List-Archive: http://lists.mysql.com/internals/12 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" ; format="flowed" Hi Monty, >Wht is the difference between the thread implementation in rhapsody >and darwin; As you know, MySQL compiles and works on rhapsodi. Darwin has a POSIX IEEE 1003.1c pthreads implementation. I don't know enough about the standard to know if Darwin complies 100% but 'POSIX IEEE 1003.1c' is documented in the headers... Again, I think pthread_kill is not included in that spec. What defines do I have to set in order to avoid the use of pthread_kill? I ran configure (after certain modifications to recognize 'darwin') and it noticed that pthread_kill was NOT available -- but when I did the 'make' pthread_kill was still being called. Is this a mistake? >Doesn't mysqladmin shutdown work if you don't have any connected >clients? I am quite sure this works on rhapsodi. I never got this to work even in rhapsody -- but I don't think I ever tried the binary dist. I had built it myself... Here's a list of the issues for building under Darwin. I also included my current patch file which gets things to build. You'll note that I'm NOT using the 'HAVE_CTHREADS_WRAPPER' like rhapsody. Instead I made a new section called 'HAVE_DARWIN_THREADS'. Hopefully this is just temporary until things get cleaned up. Anyway, the list: 1 - 'darwin' needs to be added to config.guess and config.sub 2 - A compiler option '-O6' is added to the build; this doesn't seem to be a standard gcc switch; only pgcc under linux uses it. This doesn't cause the build to fail, just a bunch of annoying warnings. I didn't make any changes w.r.t. this. 3 - The check for 'ps' doesn't work because under Darwin when the shell executes a script the only thing that shows up in 'ps' is the shell, not the script. I posted some messages on the Darwin list to see if anyone has any solution to this. Otherwise someone more knowledgeable will have to special-case Darwin in configure to force the BSD style FIND_PROC. 4 - Some compiler flags for building with Darwin's gcc. Mainly '-traditional-cpp' needs to be on to build correctly. 5 - The whole pthread issue. See my first paragraph at the beginning of this message. 6 - A minor change in sql/sql_cache.cc which doesn't build under Darwin. Hopefully this can be merged into mysql right away. Here's the patch file (don't apply this blindly since configure.in forces FIND_PROC to use BSD style if all other checks fail): diff -Naur mysql-3.23.24-beta/config.guess mysql-3.23.24-beta-darwin/config.guess --- mysql-3.23.24-beta/config.guess Fri Sep 8 00:50:24 2000 +++ mysql-3.23.24-beta-darwin/config.guess Tue Sep 26 10:54:21 2000 @@ -987,6 +987,9 @@ *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 diff -Naur mysql-3.23.24-beta/config.sub mysql-3.23.24-beta-darwin/config.sub --- mysql-3.23.24-beta/config.sub Fri Sep 8 00:50:22 2000 +++ mysql-3.23.24-beta-darwin/config.sub Tue Sep 26 10:54:21 2000 @@ -919,7 +919,8 @@ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -openstep* | -oskit*) + | -interix* | -uwin* | -rhapsody* | -darwin* | -openstep* \ + | -oskit*) # Remember, each alternative MUST END IN *, to match a version number. ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ diff -Naur mysql-3.23.24-beta/configure.in mysql-3.23.24-beta-darwin/configure.in --- mysql-3.23.24-beta/configure.in Fri Sep 8 00:50:24 2000 +++ mysql-3.23.24-beta-darwin/configure.in Tue Sep 26 11:11:44 2000 @@ -331,7 +331,8 @@ then FIND_PROC="$PS \$\$PID | grep mysqld > /dev/null" else - AC_MSG_ERROR([Could not find the right ps switches. Which OS is this ?. See the Installation chapter in the Reference Manual.]) + FIND_PROC="$PS -uaxww | grep mysqld | grep \" \$\$PID \" > /dev/null" +# AC_MSG_ERROR([Could not find the right ps switches. Which OS is this ?. See the Installation chapter in the Reference Manual.]) fi AC_SUBST(FIND_PROC) AC_MSG_RESULT("$FIND_PROC") @@ -648,6 +649,14 @@ then echo "Using --with-named-thread=-lpthread" with_named_thread="-lpthread" + fi + ;; + *darwin*) + if test "$ac_cv_prog_gcc" = "yes" + then + CFLAGS="$CFLAGS -traditional-cpp -DHAVE_DARWIN_THREADS " + CXXFLAGS="$CXXFLAGS -traditional-cpp -DHAVE_DARWIN_THREADS " + with_named_curses="" fi ;; *rhapsody*) diff -Naur mysql-3.23.24-beta/include/my_pthread.h mysql-3.23.24-beta-darwin/include/my_pthread.h --- mysql-3.23.24-beta/include/my_pthread.h Fri Sep 8 00:50:23 2000 +++ mysql-3.23.24-beta-darwin/include/my_pthread.h Tue Sep 26 10:54:10 2000 @@ -361,6 +361,16 @@ #define pthread_condattr_destroy pthread_condattr_delete #endif +#ifdef HAVE_DARWIN_THREADS +#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) +#define pthread_kill(A,B) pthread_dummy(0) +#define pthread_condattr_init(A) pthread_dummy(0) +#define pthread_condattr_destroy(A) pthread_dummy(0) +#define pthread_signal(A,B) pthread_dummy(0) +#undef sigset +#define sigset(A,B) pthread_signal((A),(void (*)(int)) (B)) +#endif + #ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */ #define pthread_cond_destroy(A) pthread_dummy(0) #define pthread_mutex_destroy(A) pthread_dummy(0) diff -Naur mysql-3.23.24-beta/sql/sql_cache.cc mysql-3.23.24-beta-darwin/sql/sql_cache.cc --- mysql-3.23.24-beta/sql/sql_cache.cc Fri Sep 8 00:50:24 2000 +++ mysql-3.23.24-beta-darwin/sql/sql_cache.cc Tue Sep 26 10:54:18 2000 @@ -22,7 +22,7 @@ #define SQL_CACHE_LENGTH 300 HASH sql_cache; -LEX lex_array_static[SQL_CACHE_LENGTH]; +static LEX lex_array_static[SQL_CACHE_LENGTH]; LEX * lex_array = lex_array_static; int last_lex_array_item = SQL_CACHE_LENGTH - 1;