[MDEV-4553] NetBSD patches for MariaDB 5.5.30 Created: 2013-05-21  Updated: 2013-06-14  Resolved: 2013-05-27

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.5.30
Fix Version/s: 5.5.32

Type: Bug Priority: Major
Reporter: Anthony Howe Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: None
Environment:

NetBSD 6.1 (and 5.1 being checked)


Attachments: File mariadb-5.5.30-netbsd.patch    
Issue Links:
Relates
relates to MDEV-20339 FreeBSD VM builder Open

 Description   

The attached file fixes some compile time errors with respect to NetBSD 6.1 (and 5.1). Also its recommended for GCC that the option -Wno-char-subscripts be used to silence annoying compiler warnings about using a char for an array subscript (GCC folks need a life).



 Comments   
Comment by Anthony Howe [ 2013-05-24 ]

Note that these changes probably have to be carried forward into the MariaDB 10 series.

Comment by Vladislav Vaintroub [ 2013-05-24 ]

Can you clarify the purpose of (intptr_t) casting in threadpool_unix code? I do not have NetBSD here thus I ask.

I'm asking about it, because udata, the last parameter of EV_SET macro is listed as void *

The only relevant place I have found that mentions NetBSD being different is here
http://ftp.ics.uci.edu/pub/centos0/ics-custom-build/BUILD/dovecot-1.1.7/src/lib/ioloop-kqueue.c, in this piece of code

/* kevent.udata's type just has to be different in NetBSD than in
FreeBSD and OpenBSD.. */
#ifdef _NetBSD_

  1. define MY_EV_SET(a, b, c, d, e, f, g) \
    EV_SET(a, b, c, d, e, f, (intptr_t)g)
    #else
  2. define MY_EV_SET(a, b, c, d, e, f, g) \
    EV_SET(a, b, c, d, e, f, g)
    #endif

If this is lke the comment says I'd rather port the above hack from ioloop-kqueue.c, than implement casting void* as inrteger types elsewhere

Comment by Anthony Howe [ 2013-05-24 ]

NetBSD (5.1, 6.1) appears to allow for udata to be either an int or a pointer. From /usr/include/sys/event.h

#define EV_SET(kevp, a, b, c, d, e, f) \
do

{ \ (kevp)->ident = (a); \ (kevp)->filter = (b); \ (kevp)->flags = (c); \ (kevp)->fflags = (d); \ (kevp)->data = (e); \ (kevp)->udata = (f); \ }

while (/* CONSTCOND */ 0)

struct kevent {
uintptr_t ident; /* identifier for this event */
uint32_t filter; /* filter for event */
uint32_t flags; /* action flags for kqueue */
uint32_t fflags; /* filter flag value */
int64_t data; /* filter data value */
intptr_t udata; /* opaque user data identifier */
};

If you create you replace the EV_SET macro, be sure to #undef the previous one.

Removing one of the casts and compiling causes this compile error; from NetBSD 5.1 - the 6.1 is at home and unreachable just now, but had similar build problem:

[ 58%] Building CXX object sql/CMakeFiles/sql.dir/threadpool_unix.cc.o
/usr/local/src/mariadb-5.5.30/sql/item.h: In constructor 'Item_direct_ref_to_ident::Item_direct_ref_to_ident(Item_ident*)':
/usr/local/src/mariadb-5.5.30/sql/item.h:3008: warning: dereferencing type-punned pointer will break strict-aliasing rules
/usr/local/src/mariadb-5.5.30/sql/item.h:3012: warning: dereferencing type-punned pointer will break strict-aliasing rules
/usr/local/src/mariadb-5.5.30/sql/gcalc_slicescan.h: In member function 'Gcalc_scan_iterator::point** Gcalc_scan_iterator::point::next_ptr()':
/usr/local/src/mariadb-5.5.30/sql/gcalc_slicescan.h:400: warning: dereferencing type-punned pointer will break strict-aliasing rules
/usr/local/src/mariadb-5.5.30/sql/threadpool_unix.cc: In function 'int io_poll_start_read(int, int, void*)':
/usr/local/src/mariadb-5.5.30/sql/threadpool_unix.cc:297: error: invalid conversion from 'void*' to '__intptr_t'
/usr/local/src/mariadb-5.5.30/sql/threadpool_unix.cc: In function 'int io_poll_disassociate_fd(int, int)':
/usr/local/src/mariadb-5.5.30/sql/threadpool_unix.cc:315: warning: converting to non-pointer type 'int' from NULL

Comment by Vladislav Vaintroub [ 2013-05-24 ]

Thanks. I checked I have to fix it the same way as it was done in my previous comment in ioloop-keueue.c source. If I would just apply your patch, compilation would fail on every BSD except NetBSD

Ok, now I have a question about _func_ in your patch. What was the reason the code is there? #if _STDC_VERSION_ < 199901L would be true? IS this a special compiler, or compiler setting?

Comment by Anthony Howe [ 2013-05-24 ]

Without the fix I get a warning for every compiled .c like:

[ 4%] Building C object strings/CMakeFiles/strings.dir/bchange.c.o
In file included from /usr/local/src/mariadb-5.5.30/strings/strings_def.h:20,
from /usr/local/src/mariadb-5.5.30/strings/bchange.c:39:
/usr/local/src/mariadb-5.5.30/include/my_global.h:1441:1: warning: "_func_" redefined
In file included from /usr/include/pthread.h:35,
from /usr/local/src/mariadb-5.5.30/include/my_global.h:285,
from /usr/local/src/mariadb-5.5.30/strings/strings_def.h:20,
from /usr/local/src/mariadb-5.5.30/strings/bchange.c:39:
/usr/include/sys/cdefs.h:248:1: warning: this is the location of the previous definition

As I recall _func_ came in ANSI C90, but you have

#if _STDC_VERSION_ < 199901L

Don't you mean

#if _STDC_VERSION_ >= 199901L

??

I greped for _STDC_VERSION_ and there are several references, but no #define. Checking the GCC predefines shown below I don't see the macro defined:

gcc -O0 -g -Wall -Wno-char-subscripts -m32 -I./../../include -dM -E -xc /dev/null
#define _DBL_MIN_EXP_ (-1021)
#define _FLT_MIN_ 1.17549435e-38F
#define _CHAR_BIT_ 8
#define _WCHAR_MAX_ 2147483647
#define _DBL_DENORM_MIN_ 4.9406564584124654e-324
#define _FLT_EVAL_METHOD_ 2
#define _DBL_MIN_10_EXP_ (-307)
#define _FINITE_MATH_ONLY_ 0
#define _GNUC_PATCHLEVEL_ 3
#define _SHRT_MAX_ 32767
#define _LDBL_MAX_ 1.18973149535723176502e+4932L
#define _UINTMAX_TYPE_ long long unsigned int
#define _LDBL_MAX_EXP_ 16384
#define _SCHAR_MAX_ 127
#define _USER_LABEL_PREFIX_
#define _STDC_HOSTED_ 1
#define _LDBL_HAS_INFINITY_ 1
#define _DBL_DIG_ 15
#define _FLT_EPSILON_ 1.19209290e-7F
#define _NetBSD_ 1
#define _LDBL_MIN_ 3.36210314311209350626e-4932L
#define _unix_ 1
#define _DECIMAL_DIG_ 21
#define _LDBL_HAS_QUIET_NAN_ 1
#define _GNUC_ 4
#define _DBL_MAX_ 1.7976931348623157e+308
#define _DBL_HAS_INFINITY_ 1
#define _DBL_MAX_EXP_ 1024
#define _LONG_LONG_MAX_ 9223372036854775807LL
#define __GXX_ABI_VERSION 1002
#define _FLT_MIN_EXP_ (-125)
#define _DBL_MIN_ 2.2250738585072014e-308
#define _DBL_HAS_QUIET_NAN_ 1
#define _tune_i386_ 1
#define _REGISTER_PREFIX_
#define _NO_INLINE_ 1
#define __i386 1
#define _FLT_MANT_DIG_ 24
#define _VERSION_ "4.1.3 20080704 prerelease (NetBSD nb2 20081120)"
#define i386 1
#define _i386_ 1
#define _SIZE_TYPE_ unsigned int
#define _ELF_ 1
#define _FLT_RADIX_ 2
#define _LDBL_EPSILON_ 1.08420217248550443401e-19L
#define _LDBL_DIG_ 18
#define _FLT_HAS_QUIET_NAN_ 1
#define _FLT_MAX_10_EXP_ 38
#define _LONG_MAX_ 2147483647L
#define _FLT_HAS_INFINITY_ 1
#define _LDBL_MANT_DIG_ 64
#define _WCHAR_TYPE_ int
#define _FLT_DIG_ 6
#define _INT_MAX_ 2147483647
#define _FLT_MAX_EXP_ 128
#define _DBL_MANT_DIG_ 53
#define _WINT_TYPE_ int
#define _LDBL_MIN_EXP_ (-16381)
#define _LDBL_MAX_10_EXP_ 4932
#define _DBL_EPSILON_ 2.2204460492503131e-16
#define _INTMAX_MAX_ 9223372036854775807LL
#define _FLT_DENORM_MIN_ 1.40129846e-45F
#define _FLT_MAX_ 3.40282347e+38F
#define _FLT_MIN_10_EXP_ (-37)
#define _INTMAX_TYPE_ long long int
#define _GNUC_MINOR_ 1
#define _DBL_MAX_10_EXP_ 308
#define _LDBL_DENORM_MIN_ 3.64519953188247460253e-4951L
#define _STDC_ 1
#define _PTRDIFF_TYPE_ int
#define _LDBL_MIN_10_EXP_ (-4931)
#define _GNUC_GNU_INLINE_ 1

Comment by Anthony Howe [ 2013-05-24 ]

From /usr/include/sys/cdefs.h

/*

  • C99 defines _func_ predefined identifier, which was made available
  • in GCC 2.95.
    */
    #if !(_STDC_VERSION_ >= 199901L)
    #if _GNUC_PREREQ_(2, 6)
    #define _func_ _PRETTY_FUNCTION_
    #elif _GNUC_PREREQ_(2, 4)
    #define _func_ _FUNCTION_
    #else
    #define _func_ ""
    #endif
    #endif /* !(_STDC_VERSION_ >= 199901L) */
Comment by Vladislav Vaintroub [ 2013-05-24 ]

" As I recall _func_ came in ANSI C90, but you have

#if _STDC_VERSION_ < 199901L

Don't you mean

#if _STDC_VERSION_ >= 199901L

??"

Hmm,no, not really. _func_ is a C99 feature ,which is what _STDC_VERSION_ tests is. But ok, your GCC compiler does not announce itself as C99, but system headers compensate for that. Ok, thanks for the info.

Comment by Vladislav Vaintroub [ 2013-05-27 ]

Hi,
could you lease check if patch here http://bazaar.launchpad.net/~maria-captains/maria/5.5-mdev4553/revision/3779 solves compilation problems (it should, but I'd prefer someone with readl NetBSD machine test it .

Comment by Anthony Howe [ 2013-05-27 ]

The _func_ patch doesn't appear to work (NetBSD 6.1, gcc 4.5.3), many of these warnings...

Scanning dependencies of target strings
[ 4%] Building C object strings/CMakeFiles/strings.dir/bchange.c.o
In file included from /usr/local/src/mariadb-5.5.30/strings/strings_def.h:20:0,
from /usr/local/src/mariadb-5.5.30/strings/bchange.c:39:
/usr/local/src/mariadb-5.5.30/include/my_global.h:1453:0: warning: "_func_" redefined
/usr/include/sys/cdefs.h:353:0: note: this is the location of the previous definition
[ 4%] Building C object strings/CMakeFiles/strings.dir/bmove_upp.c.o
In file included from /usr/local/src/mariadb-5.5.30/strings/strings_def.h:20:0,
from /usr/local/src/mariadb-5.5.30/strings/bmove_upp.c:38:
/usr/local/src/mariadb-5.5.30/include/my_global.h:1453:0: warning: "_func_" redefined
/usr/include/sys/cdefs.h:353:0: note: this is the location of the previous definition
[ 4%] Building C object strings/CMakeFiles/strings.dir/ctype-big5.c.o
In file included from /usr/local/src/mariadb-5.5.30/strings/strings_def.h:20:0,
from /usr/local/src/mariadb-5.5.30/strings/ctype-big5.c:30:
/usr/local/src/mariadb-5.5.30/include/my_global.h:1453:0: warning: "_func_" redefined
/usr/include/sys/cdefs.h:353:0: note: this is the location of the previous definition
[ 4%] Building C object strings/CMakeFiles/strings.dir/ctype-bin.c.o
In file included from /usr/local/src/mariadb-5.5.30/strings/strings_def.h:20:0,
from /usr/local/src/mariadb-5.5.30/strings/ctype-bin.c:22:
/usr/local/src/mariadb-5.5.30/include/my_global.h:1453:0: warning: "_func_" redefined
/usr/include/sys/cdefs.h:353:0: note: this is the location of the previous definition

My suggested fix was better.

Comment by Vladislav Vaintroub [ 2013-05-27 ]

I might overlook something trivial, but how

#if (_STDC_VERSION_ < 199901L) && !defined(_func_)
as in my patch is the very same as

#if _STDC_VERSION_ < 199901L

  1. ifndef _func_

as in your patch? Could you please clarify?

Thanks,
Vladislav

Comment by Anthony Howe [ 2013-05-27 ]

You version falls through to the #else line 1453, whereas my version enters the #if _STDC_VERSION_ < 199901L section before applying #ifndef _func_.

Comment by Anthony Howe [ 2013-05-27 ]

Alternatively should work too:

#ifndef _func_
#if (_STDC_VERSION_ < 199901L)

  1. if _GNUC_ >= 2
  2. define _func_ _FUNCTION_
  3. else
  4. define _func_ "<unknown>"
  5. endif
    #elif defined(_MSC_VER)
  6. if _MSC_VER < 1300
  7. define _func_ "<unknown>"
  8. else
  9. define _func_ _FUNCTION_
  10. endif
    #elif defined(_BORLANDC_)
  11. define _func_ _FUNC_
    #else
  12. define _func_ "<unknown>"
    #endif
    #endif /* _func_ */
Comment by Vladislav Vaintroub [ 2013-05-27 ]

Yes, I like this most.

Generated at Thu Feb 08 06:57:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.