From a6dae1f935a3086db9a27ce3c091334ca2bc7d33 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] More coverage, based on unresolved symbols in inkscape and pidgen. --- crossreport/crossreport.pl | 341 ++++++++++++++++++++++++++++++----- crossreport/mingw32-crossreport.spec | 4 +- 2 files changed, 297 insertions(+), 48 deletions(-) diff --git a/crossreport/crossreport.pl b/crossreport/crossreport.pl index 756adaa..000af0a 100755 --- a/crossreport/crossreport.pl +++ b/crossreport/crossreport.pl @@ -20,6 +20,11 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. use strict; +use utf8; + +# This removes "Wide character in print" warning. Perl should do +# the right thing based on the locale, but it doesn't, so ... +binmode STDOUT, ":utf8"; use Getopt::Long; use Pod::Usage; @@ -153,9 +158,12 @@ my $suggest_portability_library = my $warning_about_read_write_on_sockets = "If you are using read/write on sockets, then this won't work on\n". "Windows. You should use recv/send instead.\n"; +my $ifdef_win32 = + "Use #ifndef WIN32 ... #else ... #endif around the Linux/Windows API\n". + "differences to ensure that your code continues to compile on Linux.\n"; my %report = ( - "open" => + open => "Program uses POSIX open/close/read/write/... APIs. You should be\n". "aware that Win32 provides functions with the same name which do not\n". "have POSIX semantics. Simple file operations will be fine, but you\n". @@ -166,11 +174,11 @@ my %report = ( "$suggest_portability_library". "\n". "$warning_about_read_write_on_sockets", - "close" => '@open', - "read" => '@open', - "write" => '@open', + close => '@open', + read => '@open', + write => '@open', - "socket" => + socket => "Program uses Berkeley sockets API. Windows has a reasonable facsimile\n". "called Winsock. However it has some annoying API differences, in\n". "particular: (1) You have to use WSAGetLastError instead of errno,\n". @@ -178,37 +186,41 @@ my %report = ( "sockets, (4) a multitude of small API differences, (5) you have to\n". "initialize Winsock before using it by calling WSAStartup.\n". "\n". + "$ifdef_win32". + "\n". "$suggest_portability_library". "\n". "$warning_about_read_write_on_sockets", - "socketpair" => '@socket', - "accept" => '@socket', - "bind" => '@socket', - "connect" => '@socket', - "listen" => '@socket', - "getsockopt" => '@socket', - "setsockopt" => '@socket', - "shutdown" => '@socket', - - "ioctl" => + socketpair => '@socket', + accept => '@socket', + bind => '@socket', + connect => '@socket', + listen => '@socket', + getsockopt => '@socket', + setsockopt => '@socket', + shutdown => '@socket', + + ioctl => "Program uses fcntl or ioctl system calls. Only a tiny fraction of\n". "the functionality of these system calls is available in Windows,\n". "often with differences in semantics.\n". "\n". "$suggest_portability_library", - "fcntl" => '@ioctl', + fcntl => '@ioctl', - "select" => + select => "The select/poll/etc system calls are not available on Windows. You\n". "have to use WSAWaitForMultipleEvents instead.\n". "\n". + "$ifdef_win32". + "\n". "$suggest_portability_library", - "poll" => '@select', - "epoll_create" => '@select', - "epoll_ctl" => '@select', - "epoll_wait" => '@select', + poll => '@select', + epoll_create => '@select', + epoll_ctl => '@select', + epoll_wait => '@select', - "fork" => + fork => "You cannot use fork to create new processes under Windows. You have\n". "to replace calls to fork/exec with CreateProcess or CreateThread.\n". "\n". @@ -221,53 +233,251 @@ my %report = ( "CreateProcess, but nothing like as rich as what is available in\n". "Unix.\n". "\n". + "$ifdef_win32". + "\n". "For server programs, we suggest using a portability library tuned\n". "for the needs of servers, such as Apache Portable Runtime.\n", - "execl" => '@fork', - "execlp" => '@fork', - "execle" => '@fork', - "execv" => '@fork', - "execvp" => '@fork', - "execve" => '@fork', - - "usleep" => + execl => '@fork', + execlp => '@fork', + execle => '@fork', + execv => '@fork', + execvp => '@fork', + execve => '@fork', + + usleep => "usleep/nanosleep system calls do not exist on Windows. You should\n". "replace this with one of the Win32 equivalents such as Sleep.\n". "\n". + "$ifdef_win32". + "\n". "$suggest_portability_library", - "nanosleep" => '@usleep', + nanosleep => '@usleep', - "dup" => + dup => "dup/dup2 may not work as expected in Win32.\n". "\n". "$suggest_portability_library", - "dup2" => '@dup2', + dup2 => '@dup2', - "getopt_long" => + getopt_long => "GNU getopt_long is not available in Windows.\n". "\n". "$suggest_portability_library", - "__stack_chk_fail" => + __stack_chk_fail => "The -fstack-protector option may not work with the Fedora MinGW\n". "cross-compiler at this time.\n", + + fopen => + "fopen/fclose/... work for simple file operations on Windows. If you\n". + "are using binary files, you must add the 'b' character to the fopen\n". + "call, otherwise Windows will try to do line-end translation. The\n". + "'b' works on Linux (it is silently ignored).\n", + fclose => '@fopen', + fread => '@fopen', + fwrite => '@fopen', + fseek => '@fopen', + fgetpos => '@fopen', + feof => '@fopen', + fflush => '@fopen', + fseek => '@fopen', + + getenv => + "clearenv/getenv/putenv/setenv/unsetenv and direct access to environ\n". + "should be used with care under Windows. Commonly available environment\n". + "variables may not exist in Windows, and Windows does not have any\n". + "simple mechanism for setting environment variables.\n". + "\n". + "$suggest_portability_library", + clearenv => '@getenv', + putenv => '@getenv', + setenv => '@getenv', + unsetenv => '@getenv', + + tmpfile => + "tmpfile is available on Windows, but the function is deprecated by\n". + "Microsoft in favour of a secure but proprietary replacement\n". + "(tmpfile_s). You might consider using the replacement function on\n". + "Windows.\n". + "\n". + "$ifdef_win32", + + rename => + "rename is available on Windows, but it may not have the atomic\n". + "properties found on some Unix variants. Do not rely on this as a\n". + "replacement for file locking.\n", + + scanf => + "scanf/sscanf is available on Windows, but behaves differently: it does\n". + "not automatically skip whitespace before %-specifiers. If your code\n". + "relies on this, then you may need to modify it.\n". + "\n". + "See: http://msdn.microsoft.com/en-us/library/kwwtf9ch(VS.71).aspx\n", + sscanf => '@scanf', + + signal => + "Signal handling under Windows is very different/limited compared to\n". + "Unix. It is likely that your code will need careful inspection if\n". + "it does anything non-trivial with signals.\n". + "\n". + "See: http://msdn.microsoft.com/en-us/library/xdkz3x12(VS.71).aspx\n", + sigaction => '@signal', + kill => '@signal', + + popen => + "popen/pclose exist in a some form under Windows (as _popen/\n". + "_pclose), but have many limitations and you should generally avoid\n". + "using them.\n". + "\n". + "See: http://msdn.microsoft.com/en-us/library/96ayss4b(VS.80).aspx\n". + "\n". + "$suggest_portability_library", + pclose => '@popen', + + mkdir => + "mkdir exists in several different forms on various platforms.\n". + "\n". + "$suggest_portability_library", + + strtoll => + "stroll/strtold/strtoul/strtoull do not exist on Windows.\n". + "\n". + "$suggest_portability_library", + strtold => '@strtoll', + strtoul => '@strtoll', + strtoull => '@strtoull', + + system => + "You should be careful using the 'system' call on Windows. It exists\n". + "but the commands that it runs are quite different. Available commands,\n". + "paths, shells, redirection, directory separators, etc. are all likely\n". + "to be incompatible with Linux.\n", + + rand => + "The standard random functions are useless in Windows since they return\n". + "only a very limited range of numbers and do not have good randomness.\n". + "\n". + "$suggest_portability_library", + srand => '@rand', + + regcomp => + "Win32 does not have POSIX regular expression parsing (regcomp/\n". + "regexec/etc.) Use an external regular expression library instead.\n", + regexec => '@regcomp', + regfree => '@regcomp', + + wait => + "Win32 does not support wait/waitpid system calls. You will have to\n". + "rewrite code that depends on waiting & PIDs using Win32 specific APIs.\n". + "\n". + "$ifdef_win32". + "\n". + "$suggest_portability_library", + waitpid => '@wait', + waitid => '@wait', + wait4 => '@wait', + + + + + + ); +# Additional reports, so we can match by regular expression. +# Returns a string, or undef if no match. + +sub report_extra +{ + local $_ = shift; # Symbol. + + if (m/^X[A-Z][A-Za-z0-9]+$/) { + return + "X11 is not available on Windows, and in general your program\n". + "will not be talking to an X server. Replace any X11 calls with\n". + "calls to a higher-level portable library like Gtk or Qt.\n"; + } + + if (m/^dbus_$/) { + return + "The DBus API has proven problematic to port to Windows in the\n". + "past. For the latest information about this, contact the\n". + "Fedora MinGW mailing list.\n"; + } + + return undef; +} + # List of symbols for which there is no known problem. my %no_report = ( + __assert_fail => 1, + __dynamic_cast => 1, + __errno_location => 1, __libc_start_main => 1, + _IO_getc => 1, + _IO_putc => 1, + _Unwind_Resume => 1, _exit => 1, + abort => 1, + acos => 1, # XXX any incompatibility in math library calls? + asin => 1, + atan => 1, + atan2 => 1, + cabs => 1, + calloc => 1, + ceil => 1, + ceilf => 1, + cos => 1, + exit => 1, + fgetc => 1, + fgets => 1, + floor => 1, + floorf => 1, + fmod => 1, fputc => 1, + fputs => 1, free => 1, - fwrite => 1, malloc => 1, + memchr => 1, + memcpy => 1, + memmove => 1, + memset => 1, + perror => 1, + recv => 1, + send => 1, + setlocale => 1, + sqrt => 1, + sin => 1, strcasecmp => 1, strchr => 1, strcmp => 1, + strcpy => 1, + strdup => 1, + strftime => 1, + strlen => 1, + strncmp => 1, + strncpy => 1, + strrchr => 1, + strspn => 1, + strstr => 1, + strtod => 1, strtol => 1, + tan => 1, ); +sub no_report_extra +{ + local $_ = shift; + + return 1 if m/^__cxa_/; + return 1 if m/^operator new\(/; + return 1 if m/^operator new\[/; + return 1 if m/^__\w+_chk$/; + return 1 if m/^gtk_x11_/; + return 0 +} + sub report_start { my $time = time (); @@ -277,7 +487,11 @@ sub report_start my $days = floor (($time - $sym_time) / 86400); print < - 1-1 +* Wed Feb 11 2009 Richard W.M. Jones - 2-1 - Initial RPM release. -- 1.8.3.1