How to Convert the Code


To add or isolate code that implements Interix-specific features, surround it with #ifdef __INTERIX , such as in the following example:

 #ifdef __INTERIX (void) fcntl(fd, F_SETFL, fcntl(fd, F_GETFD)  FD_CLOEXEC)); #else (void) ioctl(fd, FIOCLEX, NULL); #endif 

The __INTERIX macro is automatically defined to be true (1) by the c89 compiler interface and by the gcc compiler. The _POSIX_ macro is defined to be true (1) by c89 . The c89 interface also passes the /Za option to the Microsoft Visual C++ compiler, which defines __STDC__ , unless -N nostdc is specified. When -N nostdc is defined, the ANSI-only mode in the Visual C++ compiler is disabled and Microsoft extensions are allowed. The default is ANSI C mode.

The cc compiler interface defines the symbols __INTERIX and unix to be true. (The unix macro is defined because many applications intended to be compiledon multiple platforms use this macro to call out features found on UNIX systems.) The cc interface also passes the /Ze option, which enables language extensions.

The Interix header files are structured to align with the Single UNIX Specification. For example, string and memory functions that occur in POSIX.1 are in string.h. String and memory functions that are in the Single UNIX Specification, but notin POSIX.1, are in strings.h.

The include files are also structured to restrict the API namespace. If the macro _POSIX_SOURCE value is defined to be 1 before the first header file is included,the program is restricted to the POSIX namespace. It contains only those APIs specified in the POSIX standards. This can be restrictive .

To get all of the APIs provided with the Interix Software Development Kit (SDK), define the _ALL_SOURCE value as 1 before the first header file is included, as shown in the following example:

 #define _ALL_SOURCE 1 #include <unistd.h> 

If the source is not defined, the default is the more restrictive _POSIX_SOURCE .

Table 10.1 lists the header files that are included with Interix in the /usr/include directory and compares them with the header files found in the Linux and Solaris variants.

Table 10.1: Interix Header Files in /usr/include, with Linux and Solaris Variants

Header

Interix

Linux

Solaris

ar.h

¼

¼

¼

assert.h

¼

¼

¼

cpio.h

¼

¼

¼

ctype .h

¼

¼

¼

curses .h

¼

¼

¼

db.h

¼

¼

 

dirent.h

¼

¼

¼

dlfcn.h

¼

¼

¼

err.h

¼

¼

sys/err.h

errno.h

¼

¼

¼

eti.h

¼

¼

¼

excpt.h

¼

   

fcntl.h

¼

¼

¼

features.h

¼

¼

¼

float.h

¼

   

fnmatch .h

¼

¼

¼

form.h

¼

¼

¼

fts.h

¼

¼

¼

ftw.h

¼

¼

¼

grp.h

¼

¼

¼

libgen.h

¼

¼

¼

limits.h

¼

¼

¼

locale.h

¼

¼

¼

malloc.h

¼

¼

¼

math.h

¼

¼

¼

memory.h

¼

¼

¼

menu.h

¼

¼

¼

mpool.h

¼

   

ndbm.h

¼

 

¼

netdb.h

¼

¼

¼

new.h

¼

   

nl_types.h

¼

¼

¼

nl_types_private.h

¼

   

panel.h

¼

¼

¼

paths.h

¼

¼

 

poll.h

¼

¼

¼

pty.h

¼

¼

 

pwcache.h

¼

   

pwd.h

¼

¼

¼

regex.h

¼

¼

¼

search.h

¼

¼

¼

setjmp.h

¼

¼

¼

signal.h

¼

¼

¼

stdarg.h

¼

 

¼

stddef.h

¼

¼

¼

stdio.h

¼

¼

¼

stdlib.h

¼

¼

¼

string.h

¼

¼

¼

strings.h

¼

¼

¼

stropts.h

¼

¼

¼

syslog.h

¼

¼

¼

tar.h

¼

¼

¼

term .h

¼

¼

¼

termios.h

¼

¼

¼

time.h

¼

¼

¼

tzfile.h

¼

 

¼

ucontext.h

¼

¼

¼

ulimit.h

¼

¼

¼

unctrl.h

¼

¼

¼

unistd.h

¼

¼

¼

utime .h

¼

¼

¼

utmpx.h

¼

¼

¼

va_list.h

¼

   

varargs .h

¼

 

¼

vis.h

¼

 

¼

wait.h

¼

¼

¼

wchar .h

¼

¼

¼

xti.h

¼

 

¼

Table 10.2 lists the header files that are included with Interix in the /usr/include/sys directory and compares them with the header files found in the Linux and Solaris variants.

Table 10.2: Interix Header Files in /usr/include/sys, with Linux and Solaris Variants

Header

Interix

Linux

Solaris

cdefs.h

¼

¼

 

dir.h

¼

¼

 

endian.h

¼

   

errno.h

¼

¼

¼

fault.h

¼

 

¼

fcntl.h

¼

¼

¼

file.h

¼

 

¼

fsid.h

¼

 

¼

ioctl.h

¼

 

¼

ipc.h

¼

¼

¼

mkdev.h

¼

 

¼

mman.h

¼

¼

¼

msg.h

¼

¼

¼

param.h

¼

¼

¼

procfs.h

¼

¼

¼

queue.h

¼

¼

 

reg.h

¼

¼

¼

regset.h

¼

   

resource.h

¼

¼

¼

select.h

¼

 

¼

sem.h

¼

¼

¼

shm.h

¼

¼

¼

siginfo.h

¼

 

¼

signal.h

¼

¼

¼

socket.h

¼

¼

¼

stat.h

¼

¼

¼

statvfs .h

¼

¼

¼

stropts.h

¼

¼

¼

syscall.h

¼

¼

¼

syslog.h

¼

¼

¼

termios.h

¼

¼

¼

time.h

¼

¼

¼

timeb.h

¼

¼

¼

times.h

¼

¼

¼

types.h

¼

¼

¼

ucontext.h

¼

¼

¼

uio.h

¼

¼

¼

un.h

¼

¼

¼

user .h

¼

¼

¼

utsname .h

¼

¼

¼

wait.h

¼

¼

¼




UNIX Application Migration Guide
Unix Application Migration Guide (Patterns & Practices)
ISBN: 0735618380
EAN: 2147483647
Year: 2003
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net