Difference between revisions of "Standard library"

From Embedded Xinu
Jump to navigation Jump to search
(Added reference to K&R book; Added summary of <stdarg.h> header)
m (Fixed code tag in summary of <stdarg.h>)
Line 18: Line 18:
  
 
== Variable Argument Lists <stdarg.h> ==
 
== Variable Argument Lists <stdarg.h> ==
Functions with a variable number of unknown type arguments rely on functions in the <code>stdarg.h</code> header to obtain the arguments provided to the function.  A variable of type <code>va_list</code> must be defined within the function to hold the variable argument list.  The variable holding the variable argument list must be initialized using the <code>va_start(va_list ap, ''lastarg'')</code> function, where <code>''lastarg''</code> is the name of the argument prior to the variable argument list in the function signature.  Arguments are obtained from the variable argument list using <code>va_arg(va_list ap, ''type'')</code>, where <code>''type''</code> specifies the expected type of the next argument in the list.  When argument reading is complete, the function <code>va_end(va_list ap)<code> is called, providing the variable argument list as an argument.
+
Functions with a variable number of unknown type arguments rely on functions in the <code>stdarg.h</code> header to obtain the arguments provided to the function.  A variable of type <code>va_list</code> must be defined within the function to hold the variable argument list.  The variable holding the variable argument list must be initialized using the <code>va_start(va_list ap, ''lastarg'')</code> function, where <code>''lastarg''</code> is the name of the argument prior to the variable argument list in the function signature.  Arguments are obtained from the variable argument list using <code>va_arg(va_list ap, ''type'')</code>, where <code>''type''</code> specifies the expected type of the next argument in the list.  When argument reading is complete, the function <code>va_end(va_list ap)</code> is called, providing the variable argument list as an argument.
  
 
== Signals <signal.h> ==
 
== Signals <signal.h> ==

Revision as of 14:49, 31 July 2007

Clockimportant.png This article or section needs to be updated.
Parts of this article or section have been identified as no longer being up to date.
Please update the article to reflect recent changes, and remove this template when finished.

The Embedded XINU standard library contains a portion of the functions defined by the ANSI standard. The functions parallel the ANSI standard C library as close as possible.

Input and Output <stdio.h>

The input and output functions are currently being tested and augmented.

Character Class Tests <ctype.h>

The character class functions are currently being tested and augmented.

String Functions <string.h>

The string functions are currently being tested and augmented.

Utility Functions <stdlib.h>

The utility functions are currently being tested and augmented.

Diagnostics <assert.h>

A macro ASSERT(int expression) is defined in kernel.h. No assert.h header file is included in the Embedded XINU standard library.

Variable Argument Lists <stdarg.h>

Functions with a variable number of unknown type arguments rely on functions in the stdarg.h header to obtain the arguments provided to the function. A variable of type va_list must be defined within the function to hold the variable argument list. The variable holding the variable argument list must be initialized using the va_start(va_list ap, lastarg) function, where lastarg is the name of the argument prior to the variable argument list in the function signature. Arguments are obtained from the variable argument list using va_arg(va_list ap, type), where type specifies the expected type of the next argument in the list. When argument reading is complete, the function va_end(va_list ap) is called, providing the variable argument list as an argument.

Signals <signal.h>

Signals are not currently implemented in the XINU standard library. However, this portion of the library would be a beneficial addition for future releases. The header signal.h provides functionality for handling conditions that arise during execution including termination and error conditions.

Date and Time Functions <time.h>

Dates and times are not currently used in Embedded XINU. However, this portion of the library would be a beneficial addition for future releases. The header time.h provides functions for date and time formatting and determining current date and time. This header would be more useful after the network driver is complete and Embedded XINU is able to synchronize with an time server.

Implementation-defined Limits <limits.h>

The header limits.h defines maximum and minimum values for the integral C types. The constants defined are set according to the 32-bit Mips architecture of the supported platforms.

Char

  • Bits in a character = 8
  • Maximum value of a char = +127
  • Minimum value of a char = -128
  • Maximum value of a signed char = +127
  • Minimum value of a signed char = -128
  • Maximum value of an unsigned char (uchar) = 255

Int

  • Maximum value of an int = +2147483647
  • Minimum value of an int = -2147483648
  • Maximum value of an unsigned int = 4294967295

Long

  • Maximum value of a long = +2147483647
  • Minimum value of a long = -2147483648
  • Maximum value of an unsigned long (ulong) = 4294967295

Short

  • Maximum value of a short = +32767
  • Minimum value of a short = -32768
  • Maximum value of an unsigned short (ushort</code) = 65535

Not Implemented Headers

Some of the ANSI standard library headers are not included in the XINU standard library, nor are there reasons to add these headers. The following headers have been excluded due to architectural limitations and lack of feasibility:

  • math.h
  • float.h
  • setjmp.h
  • locale.h
  • errno.h
  • stddef.h

References

  1. Brian Kernighan and Dennis Ritchie. The C Programming Language, second edition. Prentice Hall.