Bug #7156 | CSV storage engine ha_tina.cc fails to compile on Solaris/gcc | ||
---|---|---|---|
Submitted: | 10 Dec 2004 7:53 | Modified: | 1 Sep 2005 17:38 |
Reporter: | Lenz Grimmer | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Compiling | Severity: | S3 (Non-critical) |
Version: | 4.1, 5.0 | OS: | Solaris (Solaris) |
Assigned to: | Jim Winstead | CPU Architecture: | Any |
[10 Dec 2004 7:53]
Lenz Grimmer
[10 Dec 2004 7:56]
Lenz Grimmer
On Linux/alpha (using the Compaq compiler), the error occurs, too: cxx: Warning: examples/ha_tina.h, line 36: declaration requires a typedef name }; -^ cxx: Error: examples/ha_tina.cc, line 612: identifier "MADV_SEQUENTIAL" is undefined (void)madvise(share->mapped_file,share->file_stat.st_size,MADV_SEQUENTIAL); ------------------------------------------------------------^ cxx: Info: 1 error detected in the compilation of "examples/ha_tina.cc".
[10 Dec 2004 7:57]
Lenz Grimmer
And here is the same error as the UnixWare compiler sees it: CC -Kthread -DUNIXWARE_7 -DHAVE_BROKEN_RWLOCK -DMYSQL_SERVER -DDEFAULT_MYSQL_HOME="\"/usr/local/mysql\"" -DDATADIR="\"/usr/local/mysql/data\"" -DSHAREDIR="\"/usr/local/mysql/share/mysql\"" -DHAVE_CONFIG_H -I. -I. -I.. -I../innobase/include -I../include -I../regex -I. -g -O -DSAFE_MUTEX -I/usr/local/include -DNO_CPLUSPLUS_ALLOCA -c -o ha_tina.o `test -f 'examples/ha_tina.cc' || echo './'`examples/ha_tina.cc UX:CC: WARNING: debugging and optimization mutually exclusive; -O disabled "./spatial.h", line 173: warning: support for placement delete is disabled static void operator delete(void *ptr, void *buffer) ^ "examples/ha_tina.h", line 36: warning: declaration requires a typedef name }; ^ "examples/ha_tina.h", line 91: warning: function "handler::read_time(uint, uint, ha_rows)" is hidden by "ha_tina::read_time" -- virtual function override intended? virtual double read_time(ha_rows rows) { DBUG_ASSERT(0); return((double) rows / 20.0+1); } ^ "examples/ha_tina.h", line 123: warning: function "handler::records_in_range(uint, key_range *, key_range *)" is hidden by "ha_tina::records_in_range" -- virtual function override intended? ha_rows records_in_range(int inx, const byte *start_key,uint start_key_len, ^ "examples/ha_tina.cc", line 344: warning: variable "x" was declared but never referenced int x; ^ "examples/ha_tina.cc", line 612: error: identifier "madvise" is undefined (void)madvise(share->mapped_file,share->file_stat.st_size,MADV_SEQUENTIAL); ^ gmake[4]: *** [ha_tina.o] Error 1 gmake[4]: Leaving directory `/home/mysqldev/uw714/mysql-4.1.8/sql'
[4 Jan 2005 8:34]
Andreas Fink
Happens on Sun Solaris 8 SPARC as well. Does not happen on MacOS X 10.3.7
[17 Feb 2005 1:46]
Nick Koston
It appears to happen on Mandrake 7.2 as well.
[11 Mar 2005 3:38]
Greg Earle
In Solaris' <sys/mman.h>, madvise() appears in this block: #ifdef __STDC__ #if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) extern void *mmap(void *, size_t, int, int, int, off_t); extern int munmap(void *, size_t); extern int mprotect(void *, size_t, int); extern int msync(void *, size_t, int); #if (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2)) || defined(__EXTENSIONS__) extern int mlock(const void *, size_t); extern int munlock(const void *, size_t); extern int shm_open(const char *, int, mode_t); extern int shm_unlink(const char *); #endif /* (!defined(_XPG4_2) || (_POSIX_C_SOURCE > 2))... */ /* transitional large file interface version */ #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ !defined(__PRAGMA_REDEFINE_EXTNAME)) extern void *mmap64(void *, size_t, int, int, int, off64_t); #endif /* _LARGEFILE64_SOURCE... */ #else /* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */ extern caddr_t mmap(caddr_t, size_t, int, int, int, off_t); extern int munmap(caddr_t, size_t); extern int mprotect(caddr_t, size_t, int); extern int msync(caddr_t, size_t, int); extern int mlock(caddr_t, size_t); extern int munlock(caddr_t, size_t); extern int mincore(caddr_t, size_t, char *); extern int memcntl(caddr_t, size_t, int, caddr_t, int, int); extern int madvise(caddr_t, size_t, int); #if !defined(_XOPEN_SOURCE) && !defined(_POSIX_C_SOURCE) || \ defined(__EXTENSIONS__) extern int getpagesizes(size_t *, int); /* guard visibility of uint64_t */ #if defined(_LP64) || (__STDC__ == 0 && !defined(_NO_LONGLONG)) extern int meminfo(const uint64_t *, int, const uint_t *, int, uint64_t *, uint_t *); #endif /* defined(_LP64) || (__STDC__ == 0 && !defined(_NO_LONGLONG)) */ #endif /* !defined(_XOPEN_SOURCE) && !defined(_POSIX_C_SOURCE)... */ /* transitional large file interface version */ #ifdef _LARGEFILE64_SOURCE extern caddr_t mmap64(caddr_t, size_t, int, int, int, off64_t); #endif #endif /* (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) */ if one compiles examples/ha_tina.cc with "-E", one sees # 1 "/usr/include/sys/mman.h" 1 3 4 # 34 "/usr/include/sys/mman.h" 3 4 #pragma ident "@(#)mman.h 1.36 98/06/04 SMI" extern "C" { # 117 "/usr/include/sys/mman.h" 3 4 #pragma redefine_extname mmap mmap64 # 137 "/usr/include/sys/mman.h" 3 4 extern void *mmap(void *, size_t, int, int, int, off_t); extern int munmap(void *, size_t); extern int mprotect(void *, size_t, int); extern int msync(void *, size_t, int); extern int mlock(const void *, size_t); extern int munlock(const void *, size_t); extern int shm_open(const char *, int, mode_t); extern int shm_unlink(const char *); extern void *mmap64(void *, size_t, int, int, int, off64_t); # 169 "/usr/include/sys/mman.h" 3 4 extern int mlockall(int); extern int munlockall(void); # 230 "/usr/include/sys/mman.h" 3 4 } Clearly, either _POSIX_C_SOURCE is #define'd and is set to a value larger than 2, or else _XPG4_2 is #define'd somewhere. If you look at Solaris' <sys/feature_tests.h>, you'll see /* * UNIX 95 implementation * * As specified in the following X/Open specifications: * * System Interfaces and Headers, Issue 4, Version 2 * Commands and Utilities, Issue 4, Version 2 * Networking Services, Issue 4 * X/Open Curses, Issue 4 * * application writers wishing to use any functions specified * as X/Open UNIX Extension must define _XOPEN_SOURCE and * _XOPEN_SOURCE_EXTENDED=1. The Sun internal macro _XPG4_2 * should not be used in its place as unexpected results may * occur. */ #if (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1) #define _XPG4_2 #endif /* * UNIX 98 implementation * * As specified in the following X/Open specfications: * * System Interfaces and Headers, Issue 5 * Commands and Utilities, Issue 5 * Networking Services, Issue 5 * X/Open Curses, Issue 4, Version 2 * * application writers wishing to utilize UNIX 98 functionality * must define _XOPEN_SOURCE=500. This turns on UNIX 95 functionality * which is a subset of UNIX 98, and also turns on POSIX Realtime and * POSIX Threads functionality. */ #if (_XOPEN_SOURCE - 0 == 500) #define _XPG5 #define _XPG4_2 #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 199506L #define _POSIX_PTHREAD_SEMANTICS 1 #endif I think it's safe to say that Solaris 7/8/9/10 probably qualifies as UNIX 95 and UNIX 98 compliant, ergo it's probably the case that both of these #defines (_POSIX_C_SOURCE > 2, and _XPG4_2) are #define'd. There must've been a good reason for this; for example, NetBSD's CVS comments for <sys/mman.h> include this entry from 1998: Revision 1.18 / (download) - annotate - [select for diffs] , Sat May 30 22:18:56 1998 UTC (6 years, 9 months ago) by kleink Branch: MAIN Changes since 1.17: +23 -11 lines Diff to previous 1.17 * Per XSH98, provide size_t and const'ify the `addr' arguments to mlock() and munlock(). * Don't make the madvise() declaration and related definitions available to _POSIX_C_SOURCE or _XOPEN_SOURCE. * Remove a bogus comment. Note the apparent incompatibility between madvise() and _POSIX_C_SOURCE/_XOPEN_SOURCE. The ACE (Adaptive Communication Environment) C++ Object-Oriented Network Programming toolkit (http://www.cs.wustl.edu/~schmidt/ACE.html) kludges around this issue in a header file: #if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE > 2) || \ defined (__EXTENSIONS__) [...] // Hack 'cuz _POSIX_C_SOURCE > 2 and -DEXTENSIONS hides this. # include <sys/types.h> extern "C" int madvise(caddr_t, size_t, int); #endif /* _POSIX_C_SOURCE > 2 || __EXTENSIONS__ */ What is strange about ha_tina.cc's usage of madvise() is that the line reads (void)madvise(share->mapped_file,share->file_stat.st_size,MADV_SEQUENTIAL); "share" is listed as "TINA_SHARE *share" in "ha_tina.h", and "mapped_file" is a "byte *"; i.e. neither of the "accepted" declarations for the first argument to madvise() (either caddr_t or void *) are used. I decided to use a shortened version of the ACE kludge: *** sql/examples/ha_tina.cc.dist Sat Feb 12 12:37:31 2005 --- sql/examples/ha_tina.cc Thu Mar 10 19:34:43 2005 *************** *** 604 **** --- 605,611 ---- + #if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE > 2) || \ + defined (__EXTENSIONS__) + // Hack 'cuz _POSIX_C_SOURCE > 2 and -DEXTENSIONS hides this. + # include <sys/types.h> + extern "C" int madvise(caddr_t, size_t, int); + #endif /* _POSIX_C_SOURCE > 2 || __EXTENSIONS__ */ +
[30 Aug 2005 1:34]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/29009
[31 Aug 2005 17:07]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/29117
[1 Sep 2005 17:38]
Jim Winstead
Fixed in 4.1.15 and 5.0.13.
[15 Sep 2005 17:00]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/29942