





			XENIX to MS-DOS: A Cross Development System



		 D.1  Introduction

		 The XENIX system provides a variety  of  tools	 to
		 create	programs that can be executed under control
		 of the	MS-DOS operating system.  The MS-DOS  cross
		 development  system  lets you create, compile,	and
		 link MS-DOS  programs	on  the	 XENIX	system	and
		 transfer  these  programs  to an MS-DOS system	for
		 execution and debugging.

		 The complete development system consists of:

		   The C program compiler cc

		   The 8086 assembler as

		   The MS-DOS linker dosld

		   The MS-DOS libraries (in /usr/lib/dos )

		   The MS-DOS include files (in /usr/include/dos )
  
		   The dos commands

		 The heart of the cross	development system  is	the
		 command.   The	 command  provides a special option
		 that directs  the  compiler  to  create  code	for
		 execution  under  MS-DOS.  When is given, uses	the
		 special MS-DOS	 include  files	 and  libraries	 to
		 create	 a program.  The resulting program file	has
		 the correct format for	 execution  on	any  MS-DOS
		 system.

		 The command uses the commands	to  carry  out	the
		 last part of the compilation process, the creation
		 of  the  executable  program  file.   invokes	the
		 command  only	when  8086 assembly language source
		 files are given  in  the  command  line.  In  most
		 cases,	 invokes  and  automatically.  You can also




								D-1






















	      invoke them directly  when  you  need  to	 perform
	      special tasks.

	      The last step in the cross development process  is
	      to  transfer  the	 executable  program files to an
	      MS-DOS system.  Since MS-DOS  programs  cannot  be
	      executed or debugged on the XENIX	system,	you must
	      copy the resulting programs to MS-DOS file systems
	      before  attempting  execution.   You  can	 do this
	      using the	XENIX dos commands.	For example, the
	      command lets you copy files back and forth between
	      XENIX  and  MS-DOS  disks.   This	 means	you  can
	      transfer program files from the XENIX system to an
	      MS-DOS system, or	copy source files from an MS-DOS
	      system to	XENIX.


	      D.2  Creating Source Files

	      You can create program source files  using  either
	      XENIX or MS-DOS text editors.  The most convenient
	      way is to	use a XENIX editor, such as  since  this
	      means you	do not have to transfer	the source files
	      from the MS-DOS system to	XENIX each time	you make
	      changes to the files.

	      When creating  source  files,  you  should  follow
	      these simple rules:

	       	Use the	standard  C  language  format  for  your
		source files.  MS-DOS source files have	the same
		format as XENIX	source	files.	 In  fact,  many
		MS-DOS programs, if compiled without the option,
		can be executed	on the XENIX system.


	       	Use the	MS-DOS naming  conventions  when  giving
		file and directory names within	a program; e.g.,
		use ``\'' instead  of  ``/''  for  the	pathname
		separator.   Since  the	 compiler does not check



	      D-2


















			XENIX to MS-DOS: A Cross Development System



		   names, failure to follow  the  conventions  will
		   cause errors	when the program is executed.


		   Use only the	MS-DOS include	files  and  library
		   functions.	Most   MS-DOS	include	 files	and
		   functions   are   identical	 to   their   XENIX
		   counterparts.     Others    have   only   slight
		   differences.	  For  a  complete  list   of	the
		   available  MS-DOS  include  files and functions,
		   and a description  of  the  differences  between
		   them	 and  the  corresponding  XENIX	 files	and
		   functions, see section 8 of this appendix.



		 If  you  use  a  function  that  does	not  exist,
		 displays  an  error  message and leaves the linked
		 output	file incomplete.


		 D.2  Compiling	an MS-DOS Source File

		 You can compile an MS-DOS source file by using	the
		 option	of the XENIX command.  The command line	has
		 the form

			 cc -dos options filename  ...

		 where	options	 are  other  command  options	(as
		 described  in	Chapter	 2  of	the  XENIX C User's
		 Guide), and filename is the  name  of	the  source
		 file  you  wish to compile. You can give more than
		 one source file if desired.  Each source  filename
		 must end with the ``.c'' extension.

		 The command compiles each source file	separately,
		 creating  an object file for each file, then links
		 all object files together with	the  appropriate  C
		 libraries.    The  object  files  created  by	the



								D-3






















	      command  have  the   same	  base	 name	as   the
	      corresponding source file, but end with the ``.o''
	      extension	instead	of the	``.c''	extension.   The
	      resulting	 program file also has the name	a.out if
	      no name is explicitly given.

	      For example, the command

		   cc -dos test.c

	      compiles the source file test.c  and  creates  the
	      object file test.o.  It then calls which links the
	      object  file  with  functions  from   the	  MS-DOS
	      libraries.   The	resulting  program file	is named
	      a.out.

	      You can use any number of	options	in  the	 command
	      line.   The options work as described in Chapter 2
	      of the C User's Guide.  For example, you	may  use
	      the   option  to	explicitly  name  the  resulting
	      program file, or the option to create object files
	      without  creating	 a program file.  In some cases,
	      the default values for  an  option  are  different
	      than when	compiling for XENIX.  In particular, the
	      default directory	for library files given	with the
	      option   is  /usr/lib/dos.   Note	 that  the  (for
	      ``profiling'') option cannot be used.


	      D.3  Using Assembly Language Source Files

	      You can direct to	assemble 8086 assembly	language
	      source files by including	the files in the command
	      line.  Like  C  source  files,  assembly	language
	      source  files  may contain only calls to functions
	      in the  MS-DOS  libraries.   The	filename  of  an
	      assembly	language  source  file must end	with the
	      ``.s'' extension.

	      When an assembly language	source	file  is  given,



	      D-4


















			XENIX to MS-DOS: A Cross Development System



		 automatically	invokes	 the  8086  assembler.	The
		 assembler creates  an	object	file  that  can	 be
		 linked	with any other object file created by

		 You can invoke	the assembler directly by using	the
		 command.   The	command	creates	an object file just
		 as the	command, but does not create an	 executable
		 file.	 For  a	 description of	the command and	its
		 options, see in the XENIX Reference Manual.


		 D.4  Creating and Linking Object Files

		 You  can  link	 MS-DOS	 object	 files	 previously
		 created  by or	by giving the names of the files in
		 the command line.  The	object files must have been
		 created  with	or  with  using	the option.  Object
		 files created without using the option	 cannot	 be
		 linked	 to  MS-DOS programs.  The object filenames
		 must end with the ``.o'' extension.

		 When  an  object  file	 is  given,   automatically
		 invokes  (the MS-DOS linker) which links the given
		 object	files with the appropriate C libraries.	 If
		 there are no errors, creates an executable program
		 file named a.out.

		 You can invoke	the linker directly  by	 using	the
		 command.   The	 command  creates an MS-DOS program
		 file just as the  command,  but  does	not  accept
		 source	 files.	  For  a description of	the command
		 and  its  options,  see  in  the  XENIX  Reference
		 Manual.    MS-DOS  programs  created  by  and	are
		 completely compatible with the	MS-DOS	system	and
		 can  be  executed  on	any  such  system.   MS-DOS
		 programs cannot be executed on	the XENIX system.






								D-5























	      D.5  Running and Debugging an MS-DOS Program

	      You can debug an MS-DOS  program	by  transferring
	      the program file to an MS-DOS system and using the
	      MS-DOS debugger, to load and execute the	program.
	      The  following  section  explains	 how to	transfer
	      program files between systems. For  a  description
	      of the program, see the appropriate MS-DOS manual.


	      D.6  Transferring	Programs Between Systems

	      You can transfer programs	between	XENIX and MS-DOS
	      systems by using MS-DOS floppy disks and the XENIX
	      command.	The command lets you copy  files  to  an
	      MS-DOS floppy disk.

	      The command has the form

		      doscp -r file-1 dev:file-2

	      where is the required ``raw''  option,  file-1  is
	      the  name	 of  the MS-DOS	program	file you wish to
	      transfer,	dev is the  full  pathname  of	a  XENIX
	      system  floppy  disk drive, and file-2 is	the full
	      pathname of the new program  file	 on  the  MS-DOS
	      disk.   The  new	filename  must have the	``.exe''
	      extension.  The option ensures  that  the	 program
	      file is copied byte for byte.

	      To transfer a program file  to  a	 MS-DOS	 system,
	      follow these steps:

	      1.  Insert  a  formatted  MS-DOS  diskette  into a 
		  XENIX system floppy disk drive.

	      2.  Use  the  command to  copy the program file to 
		  the disk.   For  example, to  copy the program 
		  file a.out to the file  test.exe on the MS-DOS 
                  disk in the floppy drive /dev/dvf0, type



	      D-6


















			XENIX to MS-DOS: A Cross Development System



		      doscp -r a.out  /dev/dvf0:/test.exe

		 Remove	the floppy disk	from the drive.

		 You can now insert the	floppy disk into the floppy
		 disk  drive  of  the  MS-DOS system and invoke	the
		 program  just	as  you	 would	any  other   MS-DOS
		 program. MS-DOS program files that do not end with
		 the .EXE or .COM extension cannot  be	loaded	for
		 execution under MS-DOS.  When transferring program
		 files from XENIX to MS-DOS, you must make sure	you
		 rename	 a.out files to	an appropriate .EXE or .COM
		 file.

		 On some XENIX systems,	you may	be able	 to  create
		 an  MS-DOS  partition	on the system hard disk	and
		 copy  MS-DOS  program	files  to  this	  partition
		 instead  of  to  floppy  disks.   To  execute	the
		 program, you must reboot the system,  loading	the
		 MS-DOS	operating system from the MS-DOS partition.

		 D.7  Creating MS-DOS Libraries

		 You can create	a library of your own MS-DOS object
		 files	by  using  the	XENIX command.	The command
		 copies	object files created by	the compiler  to  a
		 given archive file.  The command has the form

			 ar archive filename ...

		 where archive is the name of an archive file,	and
		 filename is the name of the MS-DOS object file	you
		 wish to add  to  the  library.	  MS-DOS  libraries
		 created  on  the  XENIX  system are not compatible
		 with libraries	created	on the MS-DOS system.  This
		 means	you cannot copy	the libraries to the MS-DOS
		 system	and expect them	to  work  with	the  MS-DOS
		 command.




								D-7























	      D.8  Common Run-Time Routines

	      The sections below list routines from the	MS-DOS C
	      library  that  are  compatible with XENIX	and UNIX
	      System V routines.  Routines specific to	the  MS-
	      DOS environment are also listed.


	      D.9  Common Routines

	      The following is a list of the common routines for
	      MS-DOS   and   XENIX.   The  MS-DOS  routines  are
	      compatible with the XENIX	 routines  by  the  same
	      names,  except that routines marked by an	asterisk
	      (*) have a slightly different operation or meaning
	      in  the  MS-DOS  environment  than  they	do under
	      XENIX.  These differences	are fully  described  in
	      later  sections  of  this	appendix.  Math	routines
	      marked with a dagger (-) implement UNIX System  V-
	      style error returns on MS-DOS.






















	      D-8



















			XENIX to MS-DOS: A Cross Development System



		abort*	   ctime   fprintf  isascii   putchar strdup
		abs	   dup	   fputc    iscntrl   puts    strlen
		access*    dup2    fputs    isdigit   putw    strncat
		acos-	   ecvt    fread*   isgraph   qsort   strncmp
		asctime    execl*  free	    islower   rand    strncpy
		asin-	   execle* freopen* isprint   read*   strpbrk
		assert	   execlp* frexp    ispunct   realloc strrchr
		atan-	   execv*  fscanf   isspace   rewind  strspn
		atan2-	   execve* fseek*   isupper   sbrk    strtok
		atof	   execvp* fstat*   isxdigit  scanf   swab
		atoi	   exit    ftell*   ldexp-    setbuf  system*
		atol	   exp	   ftime*   localtime setjmp  tan-
		bessel-  --fabs    fwrite*  locking*  signal* tanh-
		bsearch    fclose  gcvt	    log-      sin-    time
		cabs	   fcvt    getc	    log10-    sinh-   toascii
		calloc	   fdopen  getchar  longjmp   sprintf tolower
		ceil	   feof    getcwd   lseek*    sqrt-   toupper
		chdir*	   ferror  getenv   malloc    srand   tzset
		chmod*	   fflush  getpid*  mktemp    sscanf  tolower
		chsize	   fgetc   gets	    modf      stat*   toupper
		clearerr   fgets   getw	    open*     strcat  umask*
		close	   fileno  gmtime   perror    strchr  ungetc
		cos-	   floor   hypot    pow-      strcmp  unlink*
		cosh-	   fmod    isalnum  printf    strcpy  utime*
		creat*	   fopen*  isalpha  putc      strcspn write*

                 * Operates  differently  or  has  different meaning
                   under MS-DOS than under XENIX.

		 - Implements UNIX System V-style error returns.

		 -- Doesn't correspond to single function but to six
		    functions named and j0, j1, jn, y0, y1, and yn.

		 D.10  Common Routines

		 The  XENIX-compatible	routines  listed   in	the
		 previous  section  are	 also  compatible  with	the
		 routines by  the  same	 names	in  UNIX  System  V


								D-9























	      environments.   In  addition, the	following MS-DOS
	      routines	are  compatible	 with  UNIX   System   V
	      routines	by the same name. These	routines are not
	      implemented on XENIX:


	      matherr	  memccpy     memchr	 memcmp
	      memcpy	  memset      putenv

	      Note that	most of	the math functions in the MS-DOS
	      library  implement  error	 handling  in  the  same
	      manner as	the UNIX System	V routines by  the  same
	      name.   The math routines	marked with a dagger (-)
	      in the list of  common  routines	for  MS-DOS  and
	      XENIX (see  Section 9)  implement  System  V-style
	      error handling.


	      D.11  Routines Specific to MS-DOS

	      The routines listed below	are  available	only  in
	      the  MS-DOS C library. Programmers who are writing
	      code to be ported	to XENIX  systems  should  avoid
	      using these routines:


	      bdos        flushall isatty    segread	strnset
	      cgets       FPOFF	   itoa	     setmode	strrev
	      cprintf     FPSEG	   kbhit     sopen	strset
	      cputs	  fputchar labs	     spawnl	strupr
	      cscanf	  getch	   itoa	     spawnle	tell
	      dosexterr	  getche   mkdir     spawnlp	ultoa
	      eof	  inp	   movedata  spawnv	ungetch
	      exit	  int86	   outp	     spawnve
	      fcloseall	  int86x   putch     spawnvp
	      fgetchar	  intdos   rename    strcmpi
	      filelength  intdosx  rmdir     strlwr





	      D-10



















			XENIX to MS-DOS: A Cross Development System



		 D.12  Common System-Wide Variables

		 The sections below list system-wide variables that
		 are used in the MS-DOS	C library and are also used
		 in XENIX and UNIX environments.

		 These variables are set either	by  the	 super-user
		 or  the  XENIX	 kernel	 (with the exception of	the
		 variable). Hence, while they  can  be	referenced,
		 they cannot be	altered.

		 The variables specific	to the	MS-DOS	environment
		 are also listed.


		 D.13  Common Variables

		 The following is a list of  system-wide  variables
		 used in the run-time library and available in both
		 the MS-DOS and	XENIX environments:


		 daylight    environ	 errno	   syserrlist
		 sysnerr     timezone	 tzname


		 Not all values	of errno  available  on	 XENIX	are
		 used by the MS-DOS run-time library.


		 D.14  Common Variables

		 The XENIX-compatible system-wide variables  listed
		 in  Section 10 are also available in UNIX System V
		 environments.	 There  are  no  additional  common 
		 variables for MS-DOS and UNIX System V.






							       D-11























	      D.15  Variables Specific to MS-DOS

	      The following global variables are available  only
	      in  the  MS-DOS  C  library.   Programmers who are
	      writing code to be ported	to XENIX systems  should
	      avoid using these	variables:


	      doserrno
	      fmode

	      osmajor
	      osminor

	      psp


	      D.16  Common Include Files

	      Structure	definitions,  return  value  types,  and
	      manifest	constants  used	 in  the descriptions of
	      some  of	the  common  routines  may   vary   from
	      environment to environment and are therefore fully
	      defined  in  a  set  of  include	files  for  each
	      environment.  Include  files provided with the MS-
	      DOS C library are	compatible with	include	files by
	      the  same	 names	on  XENIX and UNIX systems. Some
	      additional  include  files  are  compatible   with
	      include  files  by  the same name	in UNIX	System V
	      environments.

	      Sections 16 and 18 list the MS-DOS  include  files
	      that are compatible with XENIX  and  UNIX System V
	      The  include  files  that  apply  only  to  MS-DOS
	      environments are listed in section 19.







	      D-12



















			XENIX to MS-DOS: A Cross Development System



		 D.17  Common Include Files

		 The following MS-DOS include files are	 compatible
		 with  the  XENIX  (and	 UNIX) include files by	the
		 same name:


		 assert.h     setjmp.h		sys\stat.h
		 ctype.h      signal.h		sys\timeb.h
		 errno.h      stdio.h		sys\types.h
		 fcntl.h      time.h
		 math.h	      sys\locking.h


		 D.18  Common Include Files

		 The  XENIX-compatible	include	 files	listed	 in
		 section 17 are	also compatible  with  the  include
		 files  by  the  same  names  in  UNIX   System   V
		 environments.	 In  addition,	the  names  of	the
		 following MS-DOS include files	correspond to  UNIX
		 System	  V  include  files;  however,	the  MS-DOS
		 include files may not contain	all  the  constants
		 and types defined in the corresponding	UNIX System
		 V include files.

		 malloc.h memory.h search.h string.h



		 D.19  Include Files Specific to MS-DOS

		 The following include files are used only  in	MS-
		 DOS  environments  and	do not have counterparts on
		 XENIX and UNIX	systems.


		 conio.h      io.h	    stdlib.h
		 direct.h     process.h	    sys\utime.h
		 dos.h	      share.h	    v2tov3.h



							       D-13






















	      D.20  Differences	Between	Common Routines

	      Sections  8  through  11  explain how  the  MS-DOS
	      routines	in  the	 common  library  for  XENIX and
	      MS-DOS  differ from  their   XENIX   counterparts.
	      These  descriptions  are	intended  to  be used in
	      conjunction with the more	detailed descriptions of
	      MS-DOS functions provided	in the reference section
	      of the MS-DOS C Run-Time Library	Reference,,  and
	      with the descriptions of the XENIX routines in the
	      XENIX Programmer's and User's Reference Guides.


	      D.21  abort

	      The MS-DOS version of the	routine	 terminates  the
	      process  by  a call to an	exit routine rather than
	      through a	signal.	  Control  is  returned	 to  the
	      parent  (calling)	process	with an	exit status of 3
	      and the message Abnormal	program	 termination  is
	      printed to standard error.  No core dump occurs on
	      MS-DOS.


	      D.22  access

	      The routine checks the access  to	 a  given  file.
	      Under  MS-DOS, the real and effective user IDs are
	      non-existent.  The permission (access) setting can
	      be any combination of the	following values.

		 Value	 Meaning

		 04	 Read

		 02	 Write

		 00	 Check for existence




	      D-14



















			XENIX to MS-DOS: A Cross Development System



		 The Execute access mode (01) is not implemented.

		 In case of  error,  only  the	EACCES	and  ENOENT
		 values	may be returned	for errno on MS-DOS.


		 D.23  chdir

		 In case of error, only	the  ENOENT  value  may	 be
		 returned for errno on MS-DOS.


		 D.24  chmod

		 The  routine  can   set   the	 ``owner''   access
		 permissions  for  a  given  file,  but	 all  other
		 permission  settings  are   ignored.	 The   mode
		 argument   can	  be   any  one	 of  the  constant-
		 expressions shown in the left	column	below;	the
		 equivalent  XENIX  value  is  shown  in  the right
		 column.


		 Constant-Express Meaning	  	XENIX Value

		 SIREAD		  Read by owner	   	0400
		 SIWRITE	  Write by owner   	0200
		 SIREAD	| SIWRITE Read write by owner   0000

		 The and constants are defined	in  the	 sys\stat.h
		 include  file.	  Note	that the OR operator (|) is
		 used to combine these constants to form  read	and
		 write permission.

		 If write permission is	 not  given,  the  file	 is
		 treated  as  a	 read-only file.  Giving write-only
		 permission is allowed,	but has	 no  effect;  under
		 MS-DOS, all files are readable.




							       D-15























	      In case of error,	only the  ENOENT  value	 may  be
	      returned for errno on MS-DOS.


	      D.25  creat

	      The routine creates a  new  file	or  prepares  an
	      existing	 file  for  writing.   If  the	file  is
	      created, the access permissions are set as defined
	      by  the mode argument.  Only ``owner'' permissions
	      are allowed (see above).

	      In case of error,	only  the  EACCES,  EMFILE,  and
	      ENOENT values may	be returned for	errno on MS-DOS.

	      Use of the routine is preferred over when	creating
	      or   opening   files  in	both  MS-DOS  and  XENIX
	      environments.


	      D.26  exec

	      The MS-DOS versions of the  and  routines	 overlay
	      the  calling process, as in the XENIX environment.
	      If there is not enough memory for	the new	process,
	      the  routine  will  fail and return to the calling
	      process.	 Otherwise,  the  new	process	  begins
	      execution.

	      Under MS-DOS, the	exec routines do not:

	       	Use the	close-on-exec  flag  to	 determine  open
		files for the new
		process.

	       	Disable	profiling for the new process (profiling
		is not available under MS-DOS).





	      D-16



















			XENIX to MS-DOS: A Cross Development System



		   Pass	on signal settings to  the  child  process.
		   Under MS-DOS, all signals (including	signals	set
		   to be ignored) are reset to the default  in	the
		   child process.

		 The combined size of all arguments (including	the
		 program  name)	in an routine under MS-DOS must	not
		 exceed	128 bytes.

		 In case  of  error,  the  E2BIG,  EACCES,  ENOENT,
		 ENOEXEC,  and	ENOMEM	values	may be returned	for
		 errno on MS-DOS.  In addition,	 the  EMFILE  value
		 may be	used; under MS-DOS, the	file must be opened
		 to determine whether it is executable.


		 D.27  fopen, freopen

		 The MS-DOS  versions  of  the	and  routines  open
		 stream	  files	 just  as  they	 do  in	 the  XENIX
		 environment.  However,	under MS-DOS the  following
		 additional   values   for   the  type	string	are
		 available.

		    Value   Meaning

		    t	    Opens the file in text mode.  Opening a
			    file in this mode causes translation of
			    carriage	return/linefeed	    (CR-LF)
			    character  combinations  into  a single
			    linefeed (LF) on input.  Similarly,	 on
			    output,  linefeeds	are translated into
			    CR-LF combinations.

		    b	    Opens the file in  binary  mode.   This
			    mode suppresses translation.

		 See the MS-DOS	reference pages	in the	C  Run-Time
		 Library Reference.



							       D-17























	      and routines to obtain  more  information	 on  the
	      default mode setting.

	      The MS-DOS and XENIX versions  of	 these	routines
	      also differ in their interpretation of append mode
	      (a or a+).  When append mode is specified	 in  the
	      MS-DOS   version	 of   or  the  file  pointer  is
	      repositioned to the end of  the  file  before  any
	      write  operation.	 Thus, all write operations take
	      place at the end of the file.

	      In the XENIX versions, all write	operations  take
	      place at the current position of the file	pointer.
	      In append	mode,  the  file  pointer  is  initially
	      positioned at the	end of the file, but if	the file
	      pointer is later	repositioned,  write  operations
	      take  place at the new position rather than at the
	      end of the file.


	      D.28  fread

	      The MS-DOS routine uses the low-level function  to
	      carry  out  read	operations. If the file	has been
	      opened in	text mode, replaces each CR-LF pair read
	      from  the	 file  with  a single LF character.  The
	      number of	bytes returned is the  number  of  bytes
	      remaining	 after	the  the  CR-LF	 pairs have been
	      replaced.	 Thus, the return value	may  not  always
	      correspond  to  the  actual  number of bytes read.
	      This is considered normal	and has	no  implications
	      for detecting the	end of the file.


	      D.29  fseek

	      The MS-DOS version of the	routine	moves  the  file
	      pointer  to  the	given  position,  just as in the
	      XENIX environment.  However, for streams opened in
	      text   mode,  has	 limited  use  because	carriage



	      D-18


















			XENIX to MS-DOS: A Cross Development System



		 return-linefeed translations can cause	to  produce
		 unexpected    results.	    The	  only	 operations
		 guaranteed to work on streams opened in text  mode
		 are:  seeking	with  an offset	of zero	relative to
		 any of	the origin  values,  or	 seeking  from	the
		 beginning   of	 the  file  with  an  offset  value
		 returned from a call to ftell


		 D.30  fstat

		 MS-DOS	does not make as much information available
		 for  file  handles  as	it does	for full pathnames;
		 thus, the MS-DOS version of  returns  less  useful
		 information  than  the	routine. The MS-DOS routine
		 can detect device files, but it must not  be  used
		 with directories.

		 The structure returned	by contains  the  following
		 members.






















							       D-19























		 Member	      Meaning

		 stmode	      User read	and write  bits	 reflect
			      the   file's  permission	setting.
			      The  bit	is  set	 for  a	 device;
			      otherwise, the bit is set.

		 stino	      Not used.

		 stdev	      Either drive number  of  the  disk
			      containing  the  file, or	the file
			      handle in	the case of a device.

		 strdev	      Either drive number  of  the  disk
			      containing  the  file, or	the file
			      handle in	the case of a device.

		 stnlink      Always 1.

		 stuid	      Not used.

		 stgid	      Not used.

		 stsize	      Size of the file in bytes.

		 statime      Time of last modification	of file.

		 stmtime      Time of last modification	of  file
			      (same as statime).

		 stctime      Time of last modification	of  file
			      (same as statime and stmtime).

	      In case of error,	only  the  EBADF  value	 may  be
	      returned for errno on MS-DOS.







	      D-20



















			XENIX to MS-DOS: A Cross Development System



		 D.31  ftell

		 The MS-DOS version of the routine gets	the current
		 file  pointer	position,  just	 as  in	 the  XENIX
		 environment. However, for streams opened  in  text
		 mode,	the  value  returned by	may not	reflect	the
		 physical  byte	 offset,  since	 text  mode  causes
		 carriage return-linefeed translation.	The routine
		 can be	used in	conjunction  with  the	routine	 to
		 remember and return to	file locations correctly.


		 D.32  ftime

		 Unlike	the system time	on XENIX systems,  the	MS-
		 DOS  system time does not include the concept of a
		 default time zone.  Instead, ftime uses the  value
		 of  an	 MS-DOS	 environment  variable	named TZ to
		 determine the time zone.  The	user  can  set	the
		 default  time zone by setting the TZ variable.	 If
		 TZ is not explicitly set, the	default	 time  zone
		 corresponds  to  the  Pacific	Time Zone.  See	the
		 reference page	for in the XENIX  Reference  Manual
		 for details on	the TZ variable.


		 D.33  fwrite

		 The MS-DOS routine uses the low-level function	 to
		 carry out write operations. If	the file was opened
		 in text mode, every linefeed (LF) character in	the
		 output	 is  replaced by a carriage return-linefeed
		 (CR-LF) pair before being written.  This does	not
		 affect	the return value.


		 D.34  getpid

		 The  routine  returns	a  process-unique   number.
		 Although  the	number	may  be	 used  to  uniquely



							       D-21






















	      identify the process, it does not	have
	      the same meaning as the process ID returned by  in
	      the XENIX
	      environment.


	      D.35  locking

	      The MS-DOS  and  XENIX  versions	of  the	 routine
	      differ in	several	respects, as listed below.

	        Under MS-DOS, it is not	possible to lock a  file
		only against write access; locking a region of a
		file prevents both reading and writing	in  that
		region.	  This	means that setting LKRLCK in the
		locking	call is	equivalent  to	setting	 LKLOCK,
		and  setting  LKNBRLCK	is equivalent to setting
		LKNBLCK.

	        On MS-DOS, specifying LKLOCK or	LKRLCK will  not
		cause  a  program  to  wait  until the specified
		region of a file is unlocked.	Instead,  up  to
		ten  attempts  are  made  to  lock the file (one
		attempt	per  second).	If  the	 lock  is  still
		unsuccessful   after  10  seconds,  the	 locking
		function returns an error value.  On  XENIX,  if
		the  first attempt at locking fails, the locking
		process	  sleeps   (suspends   execution)    and
		periodically  wakes  to	 attempt the lock again.
		There is no limit on the number	of attempts, and
		the process can	continue indefinitely.

	        On MS-DOS, locking of overlapping regions  of  a
		file is	not allowed.

	        On MS-DOS, if more than	one region of a	file  is
		locked,	 only  one  region  can	be unlocked at a
		time, and the region must correspond to	a region
		that  was  previously locked.  You cannot unlock
		more than one region at	 a  time,  even	 if  the



	      D-22


















			XENIX to MS-DOS: A Cross Development System



		   regions are adjacent.


		   D.36	 lseek

		   In case of error,  only  the	 EBADF	and  EINVAL
		   values may be returned for errno on MS-DOS.


		   D.37	 open

		   The routine opens a	file  handle  for  a  named
		   file,   just	  as   in  the	XENIX  environment.
		   However, two	additional  oflag  values  and	are
		   available and the and values	are not	available.

		   The flag causes the file to be opened in  binary
		   mode,  regardless  of  the default mode setting.
		   Similarly, the flag causes the file to be opened
		   in text mode.

		   In case  of	error,	only  the  EACCES,  EEXIST,
		   EMFILE,  and	ENOENT values may be used for errno
		   on MS-DOS.


		   D.38	 read

		   The	MS-DOS	version	 of   the   routine   reads
		   characters from the file given by a file handle,
		   just	as in the XENIX	environment.   However,	 if
		   the	file has been opened in	text mode, replaces
		   each	CR-LF pair read	from the file with a single
		   LF  character.   The	number of bytes	returned is
		   the number of bytes remaining after the the	CR-
		   LF  pairs  have been	replaced.  Thus, the return
		   value may not always	correspond with	the  actual
		   number of bytes read.  This is considered normal
		   and has no implications for	detecting  an  end-
		   of-file condition.



							       D-23























                 for errno on MS-DOS.


                 D.39  signal

                 The MS-DOS version of the routine can only  handle
                 the  signal.   In MS-DOS, is defined to be INT 23H
                 (the Control-C signal).

                 On MS-DOS, child processes executed through the or
                 routines do not inherit the signal settings of the
                 parent process.  All  signal  settings  (including
                 signals  set  to  be ignored) are reset to the de-
                 fault settings in the child process.

                 The MS-DOS version  of SIGNAL uses only the EINVAL 
                 for ERRNO.

                 D.40  stat

                 The  routine  returns  a  structure  defining  the
                 current  status  of  the  given file or directory.
                 The structure members returned by have the follow-
                 ing names and meanings on MS-DOS.


















                 D-24                                              




















			XENIX to MS-DOS: A Cross Development System



                 Value        Meaning

                 stmode       User read and write  bits  reflect
                              the   file's  permission  setting.
                              The bit is set for a device;  oth-
                              erwise, the bit is set.

                 stino        Not used.

                 stdev        Drive number of the disk  contain-
                              ing the file.

                 strdev       Drive number of the disk  contain-
                              ing the file.

                 stnlink      Always 1.

                 stuid        Not used.

                 stgid        Not used.

                 stsize       Size of the file in bytes.

                 statime      Time of last modification of file.

                 stmtime      Time of last modification of  file
                              (same as statime).

                 stctime      Time of last modification of  file
                              (same as statime and stmtime).

              In case of error, only the ENOENT value may be re-
              turned for errno on MS-DOS.


              D.41  system

              The routine passes the given string to the operat-
              ing  system  for execution.  For MS-DOS to execute



                                                            D-25























                 this string, the full pathname  of  the  directory
                 containing  COMMAND.COM  must  be  assigned to the
                 COMSPEC or PATH environment  variable.   The  call
                 returns  an  error  if COMMAND.COM cannot be found
                 using these variables.

                 In case of error, only the E2BIG, ENOENT,  ENOEXEC
                 and  ENOMEM  values  may  be returned for errno on
                 MS-DOS.


                 D.42  umask

                 The routine can set a mask for ``owner'' read  and
                 write  access permissions only.  All other permis-
                 sions are ignored.  (See  the  discussion  of  the
                 routine above for details.)


                 D.43  unlink

                 The MS-DOS version of the routine  always  deletes
                 the  given  file.  Since MS-DOS does not implement
                 multiple links to the same file, unlinking a  file
                 is the same as deleting it.

                 In case of  error,  only  the  EACCES  and  ENOENT
                 values may be returned for errno on MS-DOS.


                 D.44  utime

                 The MS-DOS routine sets the file modification time
                 only;  MS-DOS  does not maintain a separate access
                 time.

                 In case of error, the EACCES and ENOENT values may
                 be returned for errno on MS-DOS.  In addition, the
                 EMFILE value may be used; under MS-DOS,  the  file
                 must be opened to set the modification time.



                 D-26



















			XENIX to MS-DOS: A Cross Development System



              D.45  write

              The routine writes a specified number  of  charac-
              ters  to  the file named by the given file handle,
              just as in the XENIX environment. However, if  the
              file  has been opened in text mode, every linefeed
              (LF) character in the output is replaced by a car-
              riage  return-linefeed  (CR-LF)  pair before being
              written.  This does not affect the return value.

              In case of error, only the EBADF and ENOSPC values
              may be returned for errno on MS-DOS.






























                                                            D-27























                 Appendix D


                 XENIX to MS-DOS: A Cross Development System
                 __________________________________________________



                 D.1  Introduction  D-1

                 D.9  Common Routines  D-8

                 D.10 Common Routines  D-9

                 D.11 Routines Specific to MS-DOS  D-10

                 D.13 Common Variables  D-11

                 D.14 Common Variables  D-11

                 D.15 Variables Specific to MS-DOS  D-12

                 D.16 Common Include Files  D-12

                 D.17 Common Include Files  D-13

                 D.18 Include Files Specific to MS-DOS  D-13

                 D.21 abort  D-14

                 D.22 access  D-14

                 D.23 chdir  D-15

                 D.24 chmod  D-15

                 D.25 creat  D-16

                 D.26 exec  D-16



























              D.27 fopen, freopen  D-17

              D.28 fread  D-18

              D.29 fseek  D-18

              D.30 fstat  D-19

              D.31 ftell  D-21

              D.32 ftime  D-21

              D.33 fwrite  D-21

              D.34 getpid  D-21

              D.35 locking  D-22

              D.36 lseek  D-23

              D.37 open  D-23

              D.38 read  D-23

              D.39 signal  D-24

              D.40 stat  D-24

              D.41 system  D-25

              D.42 umask  D-26

              D.43 unlink  D-26

              D.44 utime  D-26

              D.45 write  D-27



















