SAS/C Proprietary Functions

This document lists all SAS/C proprietary functions that are not part of the C/C++ standards but are available in SAS/C 6.58.

Startup Code Options

SAS/C provides several startup code options and files:

Startup Files

File Description Usage
`c.o` Standard C startup code Default startup for most applications
`crt0.o` Alternative C runtime startup Used with some linker configurations
`crtbegin.o` C++ startup code (if C++ support available) For C++ applications
`crtend.o` C++ cleanup code For C++ applications

Startup Options

Option Description Effect
`-nostartup` Don't link startup code Manual startup code required
`-nostdlib` Don't link standard library Minimal linking
`-static` Static linking Include all libraries statically
`-shared` Shared library mode Create shared library
`-resident` Resident program Make program resident in memory

Application-Specific Startup Configurations

1. Native Amiga Command (Minimal Standard C)

Use Case: AmigaDOS commands that need maximum performance and minimal overhead, handling their own arguments with ReadArgs, workbench startup, and ctrl-c signals.

Startup Code: c.o (default) with CheckAbort=nocheckabort

Entry Point: main(int argc, char argv) or custom entry point

Compiler Options:

- CheckAbort=nocheckabort (disables Control-C checking for performance)

- StartUp=none or -nostartup (for minimal startup)

- -nostdlib (for minimal linking)

- -resident (for residentable executables if needed)

Static Libraries:

- lib:sc.lib (SAS/C standard library)

- lib:amiga.lib (Amiga library)

- lib:mathieeedoubbas.lib (math library if needed)

Why Use This: Disabling Control-C checking (nocheckabort) removes all calls to __chkabort function, which normally checks for Control-C interrupts during I/O operations. This provides significant performance improvement for I/O-intensive programs that don't need user interruption.

Example:

`bash

sc CheckAbort=nocheckabort -nostartup -nostdlib -resident mycommand.c -o mycommand

`

2. Standard C Application with main(argc, argv)

Use Case: Standard C applications using main() with command line arguments and normal Control-C handling.

Startup Code: c.o (default)

Entry Point: main(int argc, char argv)

Compiler Options:

- StartUp=c (default)

- CheckAbort=checkabort (default - enables Control-C checking)

- -resident (for residentable executables)

Static Libraries:

- lib:sc.lib (SAS/C standard library)

- lib:amiga.lib (Amiga library)

- lib:mathieeedoubbas.lib (math library if needed)

Why Use This: Standard configuration with full Control-C support. The checkabort option (default) enables Control-C checking during I/O operations, allowing users to interrupt the program.

Example:

`bash

sc -resident myapp.c -o myapp

`

3. Heavyweight Unix/POSIX/Linux Command Port

Use Case: Ports of Unix/POSIX/Linux commands requiring extensive standard library support and full Control-C handling.

Startup Code: c.o (default)

Entry Point: main(int argc, char argv)

Compiler Options:

- StartUp=c (default)

- CheckAbort=checkabort (default - enables Control-C checking)

- -resident (for residentable executables)

- LargeData (for large data model if needed)

Static Libraries:

- lib:sc.lib (SAS/C standard library)

- lib:amiga.lib (Amiga library)

- lib:mathieeedoubbas.lib (math library)

- Additional POSIX libraries as needed

Why Use This: Full-featured configuration for complex applications that need all standard library features and proper signal handling.

Example:

`bash

sc -resident LargeData myunixport.c -o myunixport

`

4. Custom Startup Module

Use Case: Applications requiring custom startup behavior or integration with specific Amiga subsystems.

Startup Code: Custom startup module

Entry Point: Custom entry point

Compiler Options:

- StartUp=module-name (specify custom startup module)

- -nostdlib (for minimal linking)

Why Use This: When you need custom startup behavior that differs from the standard c.o startup. The module name is automatically prefixed with lib: and suffixed with .o unless it contains a colon, forward slash, or period.

Example:

`bash

sc StartUp=mycustom -nostdlib myapp.c -o myapp

`

Startup Code Features

- Automatic library opening: SAS/C startup code can automatically open required Amiga libraries

- Stack setup: Initializes stack and stack pointer

- BSS clearing: Zeroes uninitialized data segments

- Constructor calls: Calls C++ constructors (if applicable)

- Environment setup: Sets up environment variables and arguments

- Signal handling: Initializes signal handlers

- Floating point: Sets up floating point environment

- Control-C handling: The CheckAbort option controls whether the program checks for Control-C interrupts during I/O operations

- checkabort (default): Enables Control-C checking, calls __chkabort function during I/O

- nocheckabort: Disables Control-C checking, replaces __chkabort calls with dummy function for performance

Character Type Functions (Non-Standard)

Function Header Description Portability
isascii ctype.h Check if character is ASCII character SAS/C
iscsym ctype.h Check if character is C symbol character SAS/C
iscsymf ctype.h Check if character is C symbol lead character SAS/C
toascii ctype.h Convert character to ASCII character SAS/C

String Functions (Non-Standard)

Function Header Description Portability
strdup string.h Duplicate string SAS/C
strndup string.h Duplicate string with length limit SAS/C
strcasecmp string.h Case-insensitive string comparison SAS/C
strncasecmp string.h Case-insensitive string comparison with length limit SAS/C
strlwr string.h Convert string to lowercase SAS/C
strupr string.h Convert string to uppercase SAS/C
strrev string.h Reverse string SAS/C
strset string.h Set all characters in string SAS/C
strnset string.h Set characters in string with length limit SAS/C

Conversion Functions (Non-Standard)

Function Header Description Portability
itoa stdlib.h Convert integer to string SAS/C
ltoa stdlib.h Convert long integer to string SAS/C
ultoa stdlib.h Convert unsigned long to string SAS/C
ecvt stdlib.h Convert double to string (engineering notation) SAS/C
fcvt stdlib.h Convert double to string (fixed notation) SAS/C
gcvt stdlib.h Convert double to string (general notation) SAS/C

Mathematical Functions (Non-Standard)

Function Header Description Portability
j0 math.h Bessel function of first kind, order 0 SAS/C
j1 math.h Bessel function of first kind, order 1 SAS/C
jn math.h Bessel function of first kind, order n SAS/C
y0 math.h Bessel function of second kind, order 0 SAS/C
y1 math.h Bessel function of second kind, order 1 SAS/C
yn math.h Bessel function of second kind, order n SAS/C
erf math.h Error function SAS/C
erfc math.h Complementary error function SAS/C
gamma math.h Gamma function SAS/C
lgamma math.h Natural logarithm of gamma function SAS/C
hypot math.h Hypotenuse SAS/C
cbrt math.h Cube root SAS/C
expm1 math.h Exponential minus 1 SAS/C
log1p math.h Natural logarithm of 1+x SAS/C
logb math.h Extract exponent SAS/C
scalb math.h Scale by power of 2 SAS/C
copysign math.h Copy sign SAS/C
nextafter math.h Next representable value SAS/C
remainder math.h Remainder function SAS/C
drem math.h Double remainder SAS/C
finite math.h Check if finite SAS/C
isnan math.h Check if not-a-number SAS/C
isinf math.h Check if infinite SAS/C

Memory Functions (Non-Standard)

Function Header Description Portability
memccpy string.h Copy memory until character SAS/C
repmem string.h Replicate values through a block SAS/C
sizmem stdlib.h Get the memory pool size SAS/C
getmem stdlib.h Get a memory block (short) SAS/C (OLD)
lsbrk stdlib.h Allocate memory SAS/C (OLD)
rbrk stdlib.h Release memory SAS/C (OLD)
rlsmem stdlib.h Release a memory block SAS/C (OLD)
rlsml stdlib.h Release a memory block SAS/C (OLD)

I/O Functions (Non-Standard)

Function Header Description Portability
fdopen stdio.h Associate file pointer with file descriptor SAS/C
fileno stdio.h Get file descriptor from file pointer SAS/C
pclose stdio.h Close pipe SAS/C
popen stdio.h Open pipe SAS/C
tempnam stdio.h Generate temporary filename SAS/C
asprintf stdio.h Allocate and format string SAS/C
vasprintf stdio.h Allocate and format string (va_list) SAS/C
dprintf stdio.h Formatted output to file descriptor SAS/C
vdprintf stdio.h Formatted output to file descriptor (va_list) SAS/C

File Functions (Non-Standard)

Function Header Description Portability
access unistd.h Check file access SAS/C
chmod sys/stat.h Change file permissions SAS/C
chown unistd.h Change file owner SAS/C
link unistd.h Create hard link SAS/C
symlink unistd.h Create symbolic link SAS/C
readlink unistd.h Read symbolic link SAS/C
unlink unistd.h Remove file SAS/C
rmdir unistd.h Remove directory SAS/C
mkdir sys/stat.h Create directory SAS/C
stat sys/stat.h Get file status SAS/C
fstat sys/stat.h Get file status by descriptor SAS/C
lstat sys/stat.h Get file status (don't follow symlinks) SAS/C
utime utime.h Set file access and modification times SAS/C
utimes sys/time.h Set file access and modification times SAS/C

Process Functions (Non-Standard)

Function Header Description Portability
fork unistd.h Create child process SAS/C
execve unistd.h Execute program SAS/C
execl unistd.h Execute program with list of arguments SAS/C
execlp unistd.h Execute program with PATH search SAS/C
execv unistd.h Execute program with vector of arguments SAS/C
execvp unistd.h Execute program with PATH search and vector SAS/C
wait sys/wait.h Wait for child process SAS/C
waitpid sys/wait.h Wait for specific child process SAS/C
getpid unistd.h Get process ID SAS/C
getppid unistd.h Get parent process ID SAS/C
getuid unistd.h Get user ID SAS/C
getgid unistd.h Get group ID SAS/C
setuid unistd.h Set user ID SAS/C
setgid unistd.h Set group ID SAS/C
setpgid unistd.h Set process group ID SAS/C
getpgid unistd.h Get process group ID SAS/C
setsid unistd.h Create session and set process group ID SAS/C
getsid unistd.h Get session ID SAS/C

System Functions (Non-Standard)

Function Header Description Portability
uname sys/utsname.h Get system information SAS/C
sysconf unistd.h Get system configuration SAS/C
pathconf unistd.h Get path configuration SAS/C
fpathconf unistd.h Get file path configuration SAS/C
getpagesize unistd.h Get system page size SAS/C
getdtablesize unistd.h Get descriptor table size SAS/C
brk unistd.h Change data segment size SAS/C
sbrk unistd.h Increment data segment size SAS/C
mmap sys/mman.h Map memory SAS/C
munmap sys/mman.h Unmap memory SAS/C
mprotect sys/mman.h Change memory protection SAS/C
msync sys/mman.h Synchronize memory with physical storage SAS/C
mlock sys/mman.h Lock memory SAS/C
munlock sys/mman.h Unlock memory SAS/C
mlockall sys/mman.h Lock all memory SAS/C
munlockall sys/mman.h Unlock all memory SAS/C

Random Number Functions (Non-Standard)

Function Header Description Portability
random stdlib.h Generate random number SAS/C
srandom stdlib.h Seed random number generator SAS/C
initstate stdlib.h Initialize random number state SAS/C
setstate stdlib.h Set random number state SAS/C
drand48 stdlib.h Generate double random number SAS/C
erand48 stdlib.h Generate double random number SAS/C
lrand48 stdlib.h Generate long random number SAS/C
nrand48 stdlib.h Generate long random number SAS/C
mrand48 stdlib.h Generate signed long random number SAS/C
jrand48 stdlib.h Generate signed long random number SAS/C
srand48 stdlib.h Seed 48-bit random number generator SAS/C
seed48 stdlib.h Seed 48-bit random number generator SAS/C
lcong48 stdlib.h Set 48-bit random number generator parameters SAS/C

Screen Control Functions (Non-Standard)

Function Header Description Portability
clrscr conio.h Clear screen SAS/C
gotoxy conio.h Move cursor to position SAS/C
wherex conio.h Get cursor X position SAS/C
wherey conio.h Get cursor Y position SAS/C
textcolor conio.h Set text color SAS/C
textbackground conio.h Set background color SAS/C
textattr conio.h Set text attributes SAS/C
window conio.h Define text window SAS/C
gotoxy conio.h Move cursor to position SAS/C
clreol conio.h Clear to end of line SAS/C
delline conio.h Delete line SAS/C
insline conio.h Insert line SAS/C
putch conio.h Put character SAS/C
getch conio.h Get character SAS/C
getche conio.h Get character with echo SAS/C
kbhit conio.h Check if key pressed SAS/C

String Manipulation Functions (Non-Standard)

Function Header Description Portability
strtok_r string.h Thread-safe string tokenizer SAS/C
strsep string.h Extract token from string SAS/C
strsignal string.h Get signal description SAS/C
strerror_r string.h Thread-safe error message SAS/C
strcoll_l string.h Locale-aware string comparison SAS/C
strxfrm_l string.h Locale-aware string transformation SAS/C
strftime_l time.h Locale-aware time formatting SAS/C
strptime time.h Parse time string SAS/C

System Variables and Constants (Non-Standard)

Variable/Constant Header Description Portability
environ unistd.h Environment variables array SAS/C
optarg unistd.h Option argument SAS/C
optind unistd.h Option index SAS/C
opterr unistd.h Option error flag SAS/C
optopt unistd.h Option character SAS/C
_argc stdlib.h Argument count SAS/C
_argv stdlib.h Argument vector SAS/C
_environ stdlib.h Environment variables SAS/C
_fmode stdlib.h File mode SAS/C
_osmajor stdlib.h Operating system major version SAS/C
_osminor stdlib.h Operating system minor version SAS/C
_osbuild stdlib.h Operating system build number SAS/C
_osver stdlib.h Operating system version SAS/C
_winmajor stdlib.h Windows major version SAS/C
_winminor stdlib.h Windows minor version SAS/C
_winver stdlib.h Windows version SAS/C

Summary

SAS/C provides extensive proprietary functionality beyond the C standard library, including:

- Amiga-specific functions: Integration with AmigaDOS, Intuition, and other Amiga subsystems

- UNIX compatibility functions: Many functions from UNIX systems for portability

- Extended I/O functions: Additional file and console I/O capabilities

- Memory management extensions: Advanced memory allocation and management

- String manipulation extensions: Comprehensive string processing functions

- System integration: Deep integration with Amiga hardware and software

- 680x0-specific functions: Direct access to Motorola 680x0 processor features

- Flexible startup options: Multiple startup code configurations for different application types

These proprietary functions make SAS/C a powerful development environment for Amiga systems, providing both standard C compliance and extensive platform-specific capabilities.