predefined macros for various BSD-based systems?
От | Tom Lane |
---|---|
Тема | predefined macros for various BSD-based systems? |
Дата | |
Msg-id | 14462.1273896902@sss.pgh.pa.us обсуждение исходный текст |
Ответы |
Re: predefined macros for various BSD-based systems?
(Robert Haas <robertmhaas@gmail.com>)
Re: predefined macros for various BSD-based systems? (Peter Eisentraut <peter_e@gmx.net>) Re: predefined macros for various BSD-based systems? (Giles Lean <giles.lean@pobox.com>) Re: predefined macros for various BSD-based systems? (Bruce Momjian <bruce@momjian.us>) |
Список | pgsql-hackers |
The recently added contrib/pg_upgrade code contains this bit: /* * scandir() is originally from BSD 4.3, which had the third argument as * non-const. Linux and other C librarieshave updated it to use a const. * http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2005-12/msg00214.html * * Here we try to guess which libc'sneed const, and which don't. The net * goal here is to try to suppress a compiler warning due to a prototype * mismatch of const usage. Ideally we would do this via autoconf, but * autoconf doesn't have a suitable builtin testand it seems overkill * to add one just to avoid a warning. */ #elif defined(freebsd) || defined(bsdi) || defined(__darwin__) || defined(openbsd) /* no const */ return scandir(dirname,namelist, (int (*) (struct dirent *)) selector, NULL); #else /* use const */ return scandir(dirname, namelist, selector, NULL); This drew my attention a couple days ago because it was picking the wrong alternative on OS X, which was because the as-committed coding was "defined(darwin)", which is not how that symbol is spelled. I fixed that, but I am now thinking that the other three checks are equally tin-eared. In particular, I see that buildfarm members ermine (FreeBSD) and spoonbill (OpenBSD) are reporting warnings here, which proves that those two platforms don't predefine "freebsd" or "openbsd" respectively. Does anyone know if they define "__freebsd__" or "__freebsd" etc? I'm not even too sure what "bsdi" is, but I'm suspicious of that branch too. A search of our code finds contrib/pg_upgrade/file.c: 248: #elif defined(freebsd) || defined(bsdi) || defined(__darwin__) || defined(openbsd) src/backend/utils/misc/ps_status.c: 67: #elif (defined(BSD) || defined(__bsdi__) || defined(__hurd__)) && !defined(__darwin__) src/include/port.h: 355: #if defined(bsdi) || defined(netbsd) src/port/fseeko.c: 20: #if defined(__bsdi__) || defined(__NetBSD__) src/port/fseeko.c: 24: #ifdef bsdi src/port/fseeko.c: 47: #ifdef bsdi src/port/fseeko.c: 55: #ifdef bsdi src/port/fseeko.c: 66: #ifdef bsdi src/port/fseeko.c: 76: #ifdef bsdi src/port/fseeko.c: 87: #ifdef bsdi which leaves one with not a lot of warm fuzzies that we know how to spell the symbol for either bsdi or netbsd. (Oh, and shouldn't this pg_upgrade check be looking for netbsd too?) In the "darwin" case we aren't really making any assumptions, because we actually define __darwin__ in port/darwin.h. I suppose that at least some of the *BSD herd really do predefine some of the symbols being attributed to them here, but I would like to see something authoritative about which and what. regards, tom lane
В списке pgsql-hackers по дате отправления: