diff options
Diffstat (limited to 'Distrib')
-rw-r--r-- | Distrib/PortingIssues.mdwn | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/Distrib/PortingIssues.mdwn b/Distrib/PortingIssues.mdwn index f982ca09..e88c5021 100644 --- a/Distrib/PortingIssues.mdwn +++ b/Distrib/PortingIssues.mdwn @@ -47,21 +47,13 @@ An example with `fpathconf`: If you get Bad File Descriptor error when trying to read from a file (or accessing it at all), check the `open()` invocation. The second argument is the access method. If it is a hard coded number instead of a symbol defined in the standard header files, the code is screwed and should be fixed to either use `O_RDONLY`, `O_WRONLY` or `O_RDWR`. This bug was observed in the `fortunes` and `mtools` packages for example. -## <a name="PATH_MAX_tt_"> `PATH_MAX` </a> +## <a name="PATH_MAX_MAX_PATH_MAXPATHLEN_tt_"> </a> `PATH_MAX / MAX_PATH / MAXPATHLEN` -Every unconditionalized use of `PATH_MAX` is a POSIX incompatibility. If there is no upper limit on the length of a path, this symbol is not defined in any header file. Instead, you need to either use a different implementation that does not rely on the length of a string or use `sysconf()` to query the length at runtime. If `sysconf()` returns -1, you have to use `realloc()` to allocate the needed memory dynamically. - -## <a name="MAX_PATH_tt_"> `MAX_PATH` </a> - -same as `PATH_MAX` - -## <a name="MAXPATHLEN_tt_"> `MAXPATHLEN` </a> - -same as `PATH_MAX` +Every unconditionalized use of `PATH_MAX`, `MAX_PATH = or =MAXPATHLEN` is a POSIX incompatibility. If there is no upper limit on the length of a path (as its the case for GNU), this symbol is not defined in any header file. Instead, you need to either use a different implementation that does not rely on the length of a string or use `sysconf()` to query the length at runtime. If `sysconf()` returns -1, you have to use `realloc()` to allocate the needed memory dynamically. ## <a name="MAXHOSTNAMELEN_tt_"> `MAXHOSTNAMELEN` </a> -same as `PATH_MAX`. When you find a `gethostname()` funcion, which acts on a static buffer, you can replace it with Neal's [xgethostname function](http://ftp.walfield.org/pub/people/neal/xgethostname/) which returns the hostname as a dynamic buffer. For example: +Same as `PATH_MAX`. When you find a `gethostname()` function, which acts on a static buffer, you can replace it with Neal's [xgethostname function](http://ftp.walfield.org/pub/people/neal/xgethostname/) which returns the hostname as a dynamic buffer. For example: Buggy code: @@ -93,7 +85,7 @@ Replace with `RLIMIT_NOFILE` ## <a name="GNU_specific_define_tt_"> </a> GNU specific `#define` -If you need to include specific code for the Hurd using `#if` ... `#endif`, then you can use the `__GNU__` symbol to do so. But think (at least) thrice! before doing so. In most situations, this is completely unnecessary and will create more problems than it may solve. Better ask on the mailing list how to do it right if you can't think of a better solution. +If you need to include specific code for GNU/Hurd using `#if` ... `#endif`, then you can use the `__GNU__` symbol to do so. But think (at least) thrice! before doing so. In most situations, this is completely unnecessary and will create more problems than it may solve. Better ask on the mailing list how to do it right if you can't think of a better solution. ## <a name="sys_errlist_tt_vs_strerror_tt_"> `sys_errlist[]` vs. `strerror()` </a> @@ -153,6 +145,20 @@ The autoconf check for `AC_HEADER_TERMIO` tryes to check for termios, but it's o Some packages use an erroneous dependency on `libc6-dev`. This is incorrect because `libc6` is specific to GNU/Linux. The corresponding package for GNU is `libc0.3-dev` but other OSes will have different ones. You can locate the problem in the `debian/control` file of the source tree. Typical solutions include detecting the OS using `dpkg-architecture` and hardcoding the soname, or better, use a logical OR. eg: `libc6-dev | libc0.3-dev | libc-dev`. The `libc-dev` is a virtual package that works for any soname but you have to put it only as the last option. +## <a name="Third_argument_in_ioctl_TIOCFLUS"> </a> Third argument in ioctl (TIOCFLUSH, etc) + +Broken arguments for ioctl's which might work on other systems will cause segfault on GNU, because they are pasted to and from a Hurd server RPC. + +For example, TIOCFLUSH wants an \*int, but will run on GNU/Linux if you pass it a 0. The solution in this case is to declare and assign an int, eg: + +int out = 0; + +and pass its address to ioctl: + +ioctl (fd, TIOCFLUSH, &out); + +see <http://mail.gnu.org/archive/html/bug-inetutils/2001-08/msg00015.html> for an example (TIOCFLUSH in telnet) + ---- ## <a name="ChangeLog"> ChangeLog </a> @@ -178,3 +184,7 @@ Added broken libc6 dependency Text formatting. -- Ognyan Kulev - 12 Mar 2003 + +Added ioctl entry. + +-- [[Main/RobertMillan]] - 19 Mar 2003 |