% cobbled by Orna Agmon from Orr Dunkelman's HAIFUX slides 
\documentclass[a4]{seminar}
\special{! TeXDict begin /landplus90{true}store end } 
\usepackage{slidesec}
\usepackage[dvips]{graphicx}
\input{seminar.bug}
\input{seminar.bg2} 
\usepackage{fancyhdr}

\newcommand{\heading}[1]{\begin{center}\large\bf #1\end{center}}
\newcommand{\bold}{\bf}
\fancyhf{} % Clear all fields
\fancyhead[L]{\small Orna Agmon}
\fancyhead[R]{\small ladypine@vipe.technion.ac.il}
\fancyfoot[L]{\tiny\thedate}
\fancyfoot[C]{\small Portable Programming}
\fancyfoot[R]{\tiny Slide \theslide}
% To avoid that the headers be too close of the top of the page
\renewcommand{\slidetopmargin}{2cm}

\newcommand{\tex}{\TeX{}}
\newcommand{\latex}{\LaTeX{}}
\newcommand{\bslash}{\mbox{$\backslash$}}

% To center horizontally the headers and footers (see seminar.bug)
\renewcommand{\headwidth}{\textwidth}

% To adjust the frame length to the header and footer ones
\autoslidemarginstrue

	
\begin{document}
\pagestyle{fancy}

%%%%%%%%%%%%%%%%%%%%% Title
\begin{slide}	
%\includegraphics{tux.eps}
\center{\Large { Portable Programming }}
\center{Orna Agmon} 
\center{ladypine@vipe.technion.ac.il}
\center{Haifux 26.5.2003}
\end {slide}

\begin{slide}
\slideheading{TOC}
\begin{itemize}
\item Essence of Portability
\item Levels of Portability
\item Portable Programming (mainly C)
\item Portable shell scripts
\item Configuration
\item Documentations
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{Essence of Portability}
Using standards :
\begin{itemize}
\item Verifying the standard behaviour of tools before using them.
\item Relying only on standard behaviour of functions and
tools. Avoiding possibly cool system-special features. 
\item Wrapping tools in order to garranty at least that they do not
crush when accepting an undesired syntax.
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{Essence of Portability}
Using portable tools (languages, compilers, OSes):
\begin{itemize}
\item Widely available
\item Free software
\end{itemize}
Actually laying hands:
 on other systems, compilers, OSes, shells,
architectures, and building and running on them.
\end{slide}


\begin{slide}
\slideheading{Level of Required/ Desired Portability}
\begin{itemize}
\item Many unknown systems or just two known ones? What are expected
future developments?
\item Is the software required to work on other platforms, or also
have its look'n'feel?
\item How system specific is the code?
\end{itemize}
\end{slide}




\begin{slide}
\slideheading{C standards}
\begin{itemize}
\item ISO C ({\bf ANSI C}) since 1989. Widely supported, hence
preferred standard.
\item K\&R (the first book on C by Kernighan and Ritchie) C. Old Standard.
\item C9X. Not widely supported by compilers.
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{Data Types}
\begin{itemize}
\item C types specify minimal sizes only: int is at least 16 bit, long
is at least 32 bit.
\item Many compilers have parameters to define the sizes of variables,
such as `` -i4 -r8''. Those parameters enforce consistensy within a
program.
\item Usage of special types will insure consistency with system
libraries: {\bf size\_t} for sizes, {\bf time\_t} for the return value
of the {\bf time} function.
\item Casting pointers is dangerous. (For example, the space of
one 8-byte real will accomodate 4 2-byte int values on some system,
and 2 4-byte int values on others) 
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{Endianness}
Endianness is architechture dependant.
\begin{itemize}
\item {\bf Little-endian}:
 the least significant byte is at the lowest address in
memory. Examples: Intel, Alpha.
\item {\bf Big-endian}:
 the most significant byte is at the lowest address in
memory. Examples: MIPS, Sparc.
\end{itemize}
Relevant when storing binary data on network storage devices or when
communicating binary data.
\end{slide}

\begin{slide}
\slideheading{Endianness- Solutions}
\begin{itemize}
\item Avoid storing binary data: store compressed ASCII instead.
\item Communicate using wrappers: PVM
\item Another reason to avoid casting of pointers. Avoid endianness
``games'':
For example, do not do in C: 
  int i = 4;
  char c = *(char *) i;. Do not do in fortran an equivalence between
character and integer.
\item Use conversion functions to/from ``Network Endiannes'' (big
endiannes, used in TCP/IP protocols) from/to
``Host endianness''-  (htons, ntohs, htonl, ntohl). Note that the
functions depend on the length of {\bf int} and {\bf long} types.
\end{itemize}
\end{slide}



\begin{slide}
\slideheading{ C Structure Layout }
Compiler dependent. In fortran- common layout.
\begin{itemize}
\item Variables are always in the same order. 
\item However, there may be gaps (``padding'') between variables.
\item Padding may be controlled by a compiler parameter. 
\item Avoid writing or sending structs over networks: do that fieldwise.
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{C Floating point}
\begin{itemize}
\item Existing standard: IEEE-695 
\item Most processors use 64 bits precision for temporary fp
operations. Intel x86 and most of Motorola 68k use 80 bits.
\item Optimization -> fused sequences of multiplication and addition
in high precision. On heavy floating point programs this may
cause a change in the flow of the program. 
\item Most compilers have an option to disable the extended precision
(for example `-ffloat-store' in gcc).
\item Floating point programming should use epsilon values where
required. (
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}



\begin{slide}
\slideheading{Files}
\begin{itemize}
\item Case sensitivity in file names
\item Directory seperators (/ on Unix, : on Mac OS, \verb+\+ on
Windows, DOS)
\item Concept of a single root directory
\item Support of renaming or unlinking open files->Closing of files
\item Per program environment variables
\item Per program current directory
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{Time and Date}
\begin{itemize}
\item The zero date changes (not always 0:00:00, January 1, 1970). Use
ISO 8601 standard: YYYY-MM-DD.
\item The type size\_t, which time returns, changes.
\item asctime returns different values
\end{itemize}
\end{slide}




\begin{slide}
\slideheading{Character sets}
\begin{itemize}
\item Order of characters changes ( ABC..abc, AaBbCc..., Europian
vowels interlaced).  Usages of ord(), chr() is not portable.
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}


\begin{slide}
\slideheading{Windows/Unix Portability}
Various levels of portability
\begin{itemize}
\item Emulating the OS
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{}
\begin{itemize}
\item
\item
\end{itemize}
\end{slide}

\begin{slide}
\slideheading{Good Reading and References}
\begin{itemize}
\item The Autobook: http://sources.redhat.com/autobook/ by Gary
V. Vaughan, Ben Elliston, Tom Tromey  and Ian Lance Taylor  
\item Perlport: Writing Portable Perl
http://www.perl.com/language/newdocs/pod/perlport.html
\item PVM http://www.epm.ornl.gov/pvm/pvm\_home.html
\end{itemize}
\end{slide}





\end{document}

